Update tests after making changes to profile loading

This commit is contained in:
ionutboangiu
2022-01-21 15:23:29 +02:00
committed by Dan Christian Bogos
parent ba47460b64
commit d9704ef00a
3 changed files with 39 additions and 24 deletions

View File

@@ -224,9 +224,9 @@ func testPreloadITVerifyRateProfile(t *testing.T) {
func testPreloadITVerifyAccounts(t *testing.T) {
expAcc := &utils.Account{
Tenant: utils.CGRateSorg,
ID: "1001",
FilterIDs: []string{},
Tenant: utils.CGRateSorg,
ID: "1001",
Opts: map[string]interface{}{},
Weights: []*utils.DynamicWeight{
{
Weight: 20,
@@ -261,6 +261,7 @@ func testPreloadITVerifyAccounts(t *testing.T) {
},
},
AttributeIDs: []string{"attr1", "attr2"},
Opts: map[string]interface{}{},
},
"VoiceBalance": {
ID: "VoiceBalance",
@@ -271,6 +272,7 @@ func testPreloadITVerifyAccounts(t *testing.T) {
},
Type: utils.MetaVoice,
Units: utils.NewDecimal(int64(time.Hour), 0),
Opts: map[string]interface{}{},
},
},
ThresholdIDs: []string{"*none"},
@@ -288,10 +290,10 @@ func testPreloadITVerifyAccounts(t *testing.T) {
func testPreloadITVerifyActionProfiles(t *testing.T) {
var reply *engine.ActionProfile
expected := &engine.ActionProfile{
Tenant: "cgrates.org",
ID: "ONE_TIME_ACT",
FilterIDs: []string{},
Schedule: utils.MetaASAP,
Tenant: "cgrates.org",
ID: "ONE_TIME_ACT",
Weight: 10,
Schedule: utils.MetaASAP,
Targets: map[string]utils.StringSet{
"*accounts": {
"1001": {},
@@ -303,6 +305,7 @@ func testPreloadITVerifyActionProfiles(t *testing.T) {
ID: "TOPUP",
TTL: 0,
Type: utils.MetaAddBalance,
Opts: map[string]interface{}{},
Diktats: []*engine.APDiktat{
{
Path: "*balance.TestBalance.Value",
@@ -314,6 +317,7 @@ func testPreloadITVerifyActionProfiles(t *testing.T) {
ID: "SET_BALANCE_TEST_DATA",
TTL: 0,
Type: utils.MetaSetBalance,
Opts: map[string]interface{}{},
Diktats: []*engine.APDiktat{
{
Path: "*balance.TestDataBalance.Type",
@@ -325,6 +329,7 @@ func testPreloadITVerifyActionProfiles(t *testing.T) {
ID: "TOPUP_TEST_DATA",
TTL: 0,
Type: utils.MetaAddBalance,
Opts: map[string]interface{}{},
Diktats: []*engine.APDiktat{
{
Path: "*balance.TestDataBalance.Value",
@@ -336,6 +341,7 @@ func testPreloadITVerifyActionProfiles(t *testing.T) {
ID: "SET_BALANCE_TEST_VOICE",
TTL: 0,
Type: utils.MetaSetBalance,
Opts: map[string]interface{}{},
Diktats: []*engine.APDiktat{
{
Path: "*balance.TestVoiceBalance.Type",
@@ -347,6 +353,7 @@ func testPreloadITVerifyActionProfiles(t *testing.T) {
ID: "TOPUP_TEST_VOICE",
TTL: 0,
Type: utils.MetaAddBalance,
Opts: map[string]interface{}{},
Diktats: []*engine.APDiktat{
{
Path: "*balance.TestVoiceBalance.Value",

View File

@@ -111,14 +111,14 @@
{"tag": "Schedule", "path": "Schedule", "type": "*variable", "value": "~*req.4"},
// {"tag": "TargetType", "path": "TargetType", "type": "*variable", "value": "~*req.5"},
{"tag": "TargetIDs", "path": "Targets[<~*req.5>]", "type": "*variable", "value": "~*req.6"},
{"tag": "ActionID", "path": "Actions[<~*req.7>].ID", "type": "*variable", "value": "~*req.7"},
{"tag": "ActionFilterIDs", "path": "Actions[<~*req.7>].FilterIDs", "type": "*variable", "value": "~*req.8"},
{"tag": "ActionBlocker", "path": "Actions[<~*req.7>].Blocker", "type": "*variable", "value": "~*req.9"},
{"tag": "ActionTTL", "path": "Actions[<~*req.7>].TTL", "type": "*variable", "value": "~*req.10"},
{"tag": "ActionType", "path": "Actions[<~*req.7>].Type", "type": "*variable", "value": "~*req.11"},
{"tag": "ActionOpts", "path": "Actions[<~*req.7>].Opts", "type": "*variable", "value": "~*req.12"},
{"tag": "ActionPath", "path": "Actions[<~*req.7>].Diktats.Path", "type": "*variable", "value": "~*req.13"},
{"tag": "ActionValue", "path": "Actions[<~*req.7>].Diktats.Value", "type": "*variable", "value": "~*req.14"},
// {"tag": "ActionID", "path": "Actions.ID", "type": "*variable", "value": "~*req.7","new_branch":true},
{"tag": "ActionFilterIDs", "path": "Actions[<~*req.7>].FilterIDs", "type": "*variable", "value": "~*req.8", "filters": ["*notempty:~*req.7:"]},
{"tag": "ActionBlocker", "path": "Actions[<~*req.7>].Blocker", "type": "*variable", "value": "~*req.9", "filters": ["*notempty:~*req.7:"]},
{"tag": "ActionTTL", "path": "Actions[<~*req.7>].TTL", "type": "*variable", "value": "~*req.10", "filters": ["*notempty:~*req.7:"]},
{"tag": "ActionType", "path": "Actions[<~*req.7>].Type", "type": "*variable", "value": "~*req.11", "filters": ["*notempty:~*req.7:"]},
{"tag": "ActionOpts", "path": "Actions[<~*req.7>].Opts", "type": "*variable", "value": "~*req.12", "filters": ["*notempty:~*req.7:"]},
{"tag": "ActionPath", "path": "Actions[<~*req.7>].Diktats.Path", "type": "*variable", "value": "~*req.13","new_branch":true, "filters": ["*notempty:~*req.7:"]},
{"tag": "ActionValue", "path": "Actions[<~*req.7>].Diktats.Value", "type": "*variable", "value": "~*req.14", "filters": ["*notempty:~*req.7:"]},
],
},
],

View File

@@ -1887,18 +1887,26 @@ func TestRateSIntervalCost(t *testing.T) {
func TestRateProfile(t *testing.T) {
rp := RateProfile{Rates: make(map[string]*Rate)}
exp := RateProfile{
Tenant: "cgrates.org",
ID: ID,
FilterIDs: []string{"fltr1", "*string:~*req.Account:1001"},
Weights: DynamicWeights{{}},
Tenant: "cgrates.org",
ID: ID,
FilterIDs: []string{"fltr1", "*string:~*req.Account:1001"},
Weights: DynamicWeights{
{
Weight: 10,
},
},
MinCost: NewDecimal(10, 0),
MaxCost: NewDecimal(10, 0),
MaxCostStrategy: "strategy",
Rates: map[string]*Rate{
"rat1": {
ID: "rat1",
FilterIDs: []string{"fltr1"},
Weights: DynamicWeights{{}},
ID: "rat1",
FilterIDs: []string{"fltr1"},
Weights: DynamicWeights{
{
Weight: 20,
},
},
ActivationTimes: "* * * * *",
Blocker: true,
IntervalRates: []*IntervalRate{{
@@ -1930,7 +1938,7 @@ func TestRateProfile(t *testing.T) {
if err := rp.Set([]string{FilterIDs}, "fltr1;*string:~*req.Account:1001", false, EmptyString); err != nil {
t.Error(err)
}
if err := rp.Set([]string{Weights}, "", false, EmptyString); err != nil {
if err := rp.Set([]string{Weights}, ";10", false, EmptyString); err != nil {
t.Error(err)
}
if err := rp.Set([]string{MinCost}, "10", false, EmptyString); err != nil {
@@ -1950,7 +1958,7 @@ func TestRateProfile(t *testing.T) {
if err := rp.Set([]string{Rates, "rat1", FilterIDs}, "fltr1", false, EmptyString); err != nil {
t.Error(err)
}
if err := rp.Set([]string{Rates, "rat1", Weights}, "", false, EmptyString); err != nil {
if err := rp.Set([]string{Rates, "rat1", Weights}, ";20", false, EmptyString); err != nil {
t.Error(err)
}
if err := rp.Set([]string{Rates, "rat1", ActivationTimes}, "* * * * *", false, EmptyString); err != nil {