Update TPTests after removing directions

This commit is contained in:
TeoV
2019-03-27 10:11:16 +02:00
committed by Dan Christian Bogos
parent dc1876a038
commit c9ad00ec3a
9 changed files with 33 additions and 76 deletions

View File

@@ -139,7 +139,6 @@ func testTPActionsSetTPAction(t *testing.T) {
BalanceId: "BalID",
BalanceUuid: "BalUuid",
BalanceType: "*data",
Directions: "*out",
Units: "10",
ExpiryTime: "*unlimited",
Filter: "",
@@ -159,7 +158,6 @@ func testTPActionsSetTPAction(t *testing.T) {
BalanceId: "BalID",
BalanceUuid: "BalUuid",
BalanceType: "*monetary",
Directions: "*out",
Units: "120",
ExpiryTime: "*unlimited",
Filter: "",
@@ -216,7 +214,6 @@ func testTPActionsUpdateTPAction(t *testing.T) {
BalanceId: "BalID",
BalanceUuid: "BalUuid",
BalanceType: "*data",
Directions: "*out",
Units: "10",
ExpiryTime: "*unlimited",
Filter: "",
@@ -236,7 +233,6 @@ func testTPActionsUpdateTPAction(t *testing.T) {
BalanceId: "BalID",
BalanceUuid: "BalUuid",
BalanceType: "*monetary",
Directions: "*out",
Units: "120",
ExpiryTime: "*unlimited",
Filter: "",
@@ -256,7 +252,6 @@ func testTPActionsUpdateTPAction(t *testing.T) {
BalanceId: "BalID",
BalanceUuid: "BalUuid",
BalanceType: "*voice",
Directions: "*out",
Units: "102400",
ExpiryTime: "*unlimited",
Filter: "",

View File

@@ -145,7 +145,6 @@ func testTPActionTriggersSetTPActionTriggers(t *testing.T) {
ActivationDate: "",
BalanceId: "",
BalanceType: "*monetary",
BalanceDirections: "*out",
BalanceDestinationIds: "FS_USERS",
BalanceWeight: "",
BalanceExpirationDate: "",
@@ -155,7 +154,6 @@ func testTPActionTriggersSetTPActionTriggers(t *testing.T) {
BalanceSharedGroups: "",
BalanceBlocker: "",
BalanceDisabled: "",
MinQueuedItems: 3,
ActionsId: "LOG_WARNING",
Weight: 10,
},
@@ -170,7 +168,6 @@ func testTPActionTriggersSetTPActionTriggers(t *testing.T) {
ActivationDate: "",
BalanceId: "",
BalanceType: "*monetary",
BalanceDirections: "*out",
BalanceDestinationIds: "FS_USERS",
BalanceWeight: "",
BalanceExpirationDate: "",
@@ -180,7 +177,6 @@ func testTPActionTriggersSetTPActionTriggers(t *testing.T) {
BalanceSharedGroups: "",
BalanceBlocker: "",
BalanceDisabled: "",
MinQueuedItems: 3,
ActionsId: "LOG_WARNING",
Weight: 10,
},
@@ -232,7 +228,6 @@ func testTPActionTriggersUpdateTPActionTriggers(t *testing.T) {
ActivationDate: "",
BalanceId: "",
BalanceType: "*monetary",
BalanceDirections: "*out",
BalanceDestinationIds: "FS_USERS",
BalanceWeight: "",
BalanceExpirationDate: "",
@@ -242,7 +237,6 @@ func testTPActionTriggersUpdateTPActionTriggers(t *testing.T) {
BalanceSharedGroups: "",
BalanceBlocker: "",
BalanceDisabled: "",
MinQueuedItems: 3,
ActionsId: "LOG_WARNING",
Weight: 10,
},
@@ -257,7 +251,6 @@ func testTPActionTriggersUpdateTPActionTriggers(t *testing.T) {
ActivationDate: "",
BalanceId: "",
BalanceType: "*monetary",
BalanceDirections: "*out",
BalanceDestinationIds: "FS_USERS",
BalanceWeight: "",
BalanceExpirationDate: "",
@@ -267,7 +260,6 @@ func testTPActionTriggersUpdateTPActionTriggers(t *testing.T) {
BalanceSharedGroups: "",
BalanceBlocker: "",
BalanceDisabled: "",
MinQueuedItems: 3,
ActionsId: "LOG_WARNING",
Weight: 10,
},
@@ -282,7 +274,6 @@ func testTPActionTriggersUpdateTPActionTriggers(t *testing.T) {
ActivationDate: "",
BalanceId: "",
BalanceType: "",
BalanceDirections: "",
BalanceDestinationIds: "",
BalanceWeight: "",
BalanceExpirationDate: "",
@@ -292,7 +283,6 @@ func testTPActionTriggersUpdateTPActionTriggers(t *testing.T) {
BalanceSharedGroups: "",
BalanceBlocker: "",
BalanceDisabled: "",
MinQueuedItems: 5,
ActionsId: "LOG_WARNING",
Weight: 10,
},

View File

@@ -130,9 +130,7 @@ func testTPAlsPrfSetTPAlsPrf(t *testing.T) {
Attributes: []*utils.TPAttribute{
&utils.TPAttribute{
FieldName: "FL1",
Initial: "In1",
Substitute: "Al1",
Append: true,
},
},
Weight: 20,
@@ -170,15 +168,11 @@ func testTPAlsPrfUpdateTPAlsPrf(t *testing.T) {
tpAlsPrf.Attributes = []*utils.TPAttribute{
&utils.TPAttribute{
FieldName: "FL1",
Initial: "In1",
Substitute: "Al1",
Append: true,
},
&utils.TPAttribute{
FieldName: "FL2",
Initial: "In2",
Substitute: "Al2",
Append: false,
},
}
var result string
@@ -204,15 +198,11 @@ func testTPAlsPrfGetTPAlsPrfAfterUpdate(t *testing.T) {
Attributes: []*utils.TPAttribute{
&utils.TPAttribute{
FieldName: "FL2",
Initial: "In2",
Substitute: "Al2",
Append: false,
},
&utils.TPAttribute{
FieldName: "FL1",
Initial: "In1",
Substitute: "Al1",
Append: true,
},
},
Weight: 20,

View File

@@ -129,7 +129,6 @@ func testTPDispatcherSetTPDispatcher(t *testing.T) {
ExpiryTime: "",
},
Strategy: utils.MetaFirst,
Hosts: []string{"localhost"},
Weight: 10,
}
@@ -163,7 +162,6 @@ func testTPDispatcherGetFilterIds(t *testing.T) {
}
func testTPDispatcherUpdateTPDispatcher(t *testing.T) {
tpDispatcher.Hosts = []string{"localhost", "192.168.56.203"}
var result string
if err := tpDispatcherRPC.Call("ApierV1.SetTPDispatcher", tpDispatcher, &result); err != nil {
t.Error(err)
@@ -184,7 +182,6 @@ func testTPDispatcherGetTPDispatcherAfterUpdate(t *testing.T) {
ExpiryTime: "",
},
Strategy: utils.MetaFirst,
Hosts: []string{"192.168.56.203", "localhost"},
Weight: 10,
}
if err := tpDispatcherRPC.Call("ApierV1.GetTPDispatcher",

View File

@@ -47,7 +47,7 @@ type AttrGetTPRatingProfileByLoadId struct {
func (self *ApierV1) GetTPRatingProfilesByLoadId(attrs utils.TPRatingProfile, reply *[]*utils.TPRatingProfile) error {
mndtryFlds := []string{"TPid", "LoadId"}
if len(attrs.Subject) != 0 { // If Subject provided as filter, make all related fields mandatory
mndtryFlds = append(mndtryFlds, "Tenant", "Category", "Direction", "Subject")
mndtryFlds = append(mndtryFlds, "Tenant", "Category", "Subject")
}
if missing := utils.MissingStructFields(&attrs, mndtryFlds); len(missing) != 0 { //Params missing
return utils.NewErrMandatoryIeMissing(missing...)

View File

@@ -132,24 +132,21 @@ func testTPRatingProfilesGetTPRatingProfileBeforeSet(t *testing.T) {
func testTPRatingProfilesSetTPRatingProfile(t *testing.T) {
tpRatingProfile = &utils.TPRatingProfile{
TPid: "TPRProf1",
LoadId: "RPrf",
Direction: "*out",
Tenant: "Tenant1",
Category: "Category",
Subject: "Subject",
TPid: "TPRProf1",
LoadId: "RPrf",
Tenant: "Tenant1",
Category: "Category",
Subject: "Subject",
RatingPlanActivations: []*utils.TPRatingActivation{
&utils.TPRatingActivation{
ActivationTime: "2014-07-29T15:00:00Z",
RatingPlanId: "PlanOne",
FallbackSubjects: "FallBack",
CdrStatQueueIds: "RandomId",
},
&utils.TPRatingActivation{
ActivationTime: "2015-07-29T10:00:00Z",
RatingPlanId: "PlanTwo",
FallbackSubjects: "FallOut",
CdrStatQueueIds: "RandomIdTwo",
},
},
}
@@ -170,8 +167,6 @@ func testTPRatingProfilesGetTPRatingProfileAfterSet(t *testing.T) {
t.Errorf("Expecting : %+v, received: %+v", tpRatingProfile.TPid, respond.TPid)
} else if !reflect.DeepEqual(tpRatingProfile.LoadId, respond.LoadId) {
t.Errorf("Expecting : %+v, received: %+v", tpRatingProfile.LoadId, respond.LoadId)
} else if !reflect.DeepEqual(tpRatingProfile.Direction, respond.Direction) {
t.Errorf("Expecting : %+v, received: %+v", tpRatingProfile.Direction, respond.Direction)
} else if !reflect.DeepEqual(tpRatingProfile.Tenant, respond.Tenant) {
t.Errorf("Expecting : %+v, received: %+v", tpRatingProfile.Tenant, respond.Tenant)
} else if !reflect.DeepEqual(tpRatingProfile.Category, respond.Category) {
@@ -188,7 +183,7 @@ func testTPRatingProfilesGetTPRatingProfileLoadIds(t *testing.T) {
expected := []string{"RPrf"}
if err := tpRatingProfileRPC.Call("ApierV1.GetTPRatingProfileLoadIds",
&utils.AttrTPRatingProfileIds{TPid: tpRatingProfile.TPid, Tenant: tpRatingProfile.Tenant,
Category: tpRatingProfile.Category, Direction: tpRatingProfile.Direction, Subject: tpRatingProfile.Subject}, &result); err != nil {
Category: tpRatingProfile.Category, Subject: tpRatingProfile.Subject}, &result); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(expected, result) {
t.Errorf("Expecting: %+v, received: %+v", expected, result)
@@ -204,8 +199,6 @@ func testTPRatingProfilesGetTPRatingProfilesByLoadId(t *testing.T) {
t.Errorf("Expecting : %+v, received: %+v", tpRatingProfile.TPid, (*respond)[0].TPid)
} else if !reflect.DeepEqual(tpRatingProfile.LoadId, (*respond)[0].LoadId) {
t.Errorf("Expecting : %+v, received: %+v", tpRatingProfile.LoadId, (*respond)[0].LoadId)
} else if !reflect.DeepEqual(tpRatingProfile.Direction, (*respond)[0].Direction) {
t.Errorf("Expecting : %+v, received: %+v", tpRatingProfile.Direction, (*respond)[0].Direction)
} else if !reflect.DeepEqual(tpRatingProfile.Tenant, (*respond)[0].Tenant) {
t.Errorf("Expecting : %+v, received: %+v", tpRatingProfile.Tenant, (*respond)[0].Tenant)
} else if !reflect.DeepEqual(tpRatingProfile.Category, (*respond)[0].Category) {
@@ -224,19 +217,16 @@ func testTPRatingProfilesUpdateTPRatingProfile(t *testing.T) {
ActivationTime: "2014-07-29T15:00:00Z",
RatingPlanId: "PlanOne",
FallbackSubjects: "FallBack",
CdrStatQueueIds: "RandomId",
},
&utils.TPRatingActivation{
ActivationTime: "2015-07-29T10:00:00Z",
RatingPlanId: "PlanTwo",
FallbackSubjects: "FallOut",
CdrStatQueueIds: "RandomIdTwo",
},
&utils.TPRatingActivation{
ActivationTime: "2017-07-29T10:00:00Z",
RatingPlanId: "BackupPlan",
FallbackSubjects: "Retreat",
CdrStatQueueIds: "DefenseID",
},
}
if err := tpRatingProfileRPC.Call("ApierV1.SetTPRatingProfile", tpRatingProfile, &result); err != nil {
@@ -255,8 +245,6 @@ func testTPRatingProfilesGetTPRatingProfileAfterUpdate(t *testing.T) {
t.Errorf("Expecting : %+v, received: %+v", tpRatingProfile.TPid, respond.TPid)
} else if !reflect.DeepEqual(tpRatingProfile.LoadId, respond.LoadId) {
t.Errorf("Expecting : %+v, received: %+v", tpRatingProfile.LoadId, respond.LoadId)
} else if !reflect.DeepEqual(tpRatingProfile.Direction, respond.Direction) {
t.Errorf("Expecting : %+v, received: %+v", tpRatingProfile.Direction, respond.Direction)
} else if !reflect.DeepEqual(tpRatingProfile.Tenant, respond.Tenant) {
t.Errorf("Expecting : %+v, received: %+v", tpRatingProfile.Tenant, respond.Tenant)
} else if !reflect.DeepEqual(tpRatingProfile.Category, respond.Category) {

View File

@@ -37,7 +37,7 @@ var (
tpResCfg *config.CGRConfig
tpResRPC *rpc.Client
tpResDataDir = "/usr/share/cgrates"
tpRes *utils.TPResource
tpRes *utils.TPResourceProfile
tpResDelay int
tpResConfigDIR string //run tests for specific configuration
)
@@ -115,7 +115,7 @@ func testTPResRpcConn(t *testing.T) {
}
func testTPResGetTPResourceBeforeSet(t *testing.T) {
var reply *utils.TPResource
var reply *utils.TPResourceProfile
if err := tpResRPC.Call("ApierV1.GetTPResource",
&utils.TPTntID{TPid: "TPR1", Tenant: "cgrates.org", ID: "ResGroup1"}, &reply); err == nil ||
err.Error() != utils.ErrNotFound.Error() {
@@ -124,7 +124,7 @@ func testTPResGetTPResourceBeforeSet(t *testing.T) {
}
func testTPResSetTPResource(t *testing.T) {
tpRes = &utils.TPResource{
tpRes = &utils.TPResourceProfile{
Tenant: "cgrates.org",
TPid: "TPR1",
ID: "ResGroup1",
@@ -150,7 +150,7 @@ func testTPResSetTPResource(t *testing.T) {
}
func testTPResGetTPResourceAfterSet(t *testing.T) {
var respond *utils.TPResource
var respond *utils.TPResourceProfile
if err := tpResRPC.Call("ApierV1.GetTPResource", &utils.TPTntID{TPid: "TPR1", Tenant: "cgrates.org", ID: "ResGroup1"},
&respond); err != nil {
t.Error(err)
@@ -170,7 +170,7 @@ func testTPResUpdateTPResource(t *testing.T) {
}
func testTPResGetTPResourceAfterUpdate(t *testing.T) {
var expectedTPR *utils.TPResource
var expectedTPR *utils.TPResourceProfile
if err := tpResRPC.Call("ApierV1.GetTPResource", &utils.TPTntID{TPid: "TPR1", Tenant: "cgrates.org", ID: "ResGroup1"},
&expectedTPR); err != nil {
t.Error(err)
@@ -190,7 +190,7 @@ func testTPResRemTPResource(t *testing.T) {
}
func testTPResGetTPResourceAfterRemove(t *testing.T) {
var respond *utils.TPResource
var respond *utils.TPResourceProfile
if err := tpResRPC.Call("ApierV1.GetTPResource", &utils.TPTntID{TPid: "TPR1", Tenant: "cgrates.org", ID: "ResGroup1"},
&respond); err == nil || err.Error() != utils.ErrNotFound.Error() {
t.Error(err)

View File

@@ -37,7 +37,7 @@ var (
tpStatCfg *config.CGRConfig
tpStatRPC *rpc.Client
tpStatDataDir = "/usr/share/cgrates"
tpStat *utils.TPStats
tpStat *utils.TPStatProfile
tpStatDelay int
tpStatConfigDIR string //run tests for specific configuration
)
@@ -115,7 +115,7 @@ func testTPStatsRpcConn(t *testing.T) {
}
func testTPStatsGetTPStatBeforeSet(t *testing.T) {
var reply *utils.TPStats
var reply *utils.TPStatProfile
if err := tpStatRPC.Call("ApierV1.GetTPStat",
&utils.TPTntID{TPid: "TPS1", Tenant: "cgrates.org", ID: "Stat1"},
&reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
@@ -124,7 +124,7 @@ func testTPStatsGetTPStatBeforeSet(t *testing.T) {
}
func testTPStatsSetTPStat(t *testing.T) {
tpStat = &utils.TPStats{
tpStat = &utils.TPStatProfile{
Tenant: "cgrates.org",
TPid: "TPS1",
ID: "Stat1",
@@ -134,10 +134,9 @@ func testTPStatsSetTPStat(t *testing.T) {
ExpiryTime: "",
},
TTL: "1",
Metrics: []*utils.MetricWithParams{
&utils.MetricWithParams{
MetricID: "*sum",
Parameters: "Param1",
Metrics: []*utils.MetricWithFilters{
&utils.MetricWithFilters{
MetricID: "*sum",
},
},
Blocker: false,
@@ -155,7 +154,7 @@ func testTPStatsSetTPStat(t *testing.T) {
}
func testTPStatsGetTPStatAfterSet(t *testing.T) {
var respond *utils.TPStats
var respond *utils.TPStatProfile
if err := tpStatRPC.Call("ApierV1.GetTPStat",
&utils.TPTntID{TPid: "TPS1", Tenant: "cgrates.org", ID: "Stat1"}, &respond); err != nil {
t.Error(err)
@@ -167,14 +166,12 @@ func testTPStatsGetTPStatAfterSet(t *testing.T) {
func testTPStatsUpdateTPStat(t *testing.T) {
var result string
tpStat.Weight = 21
tpStat.Metrics = []*utils.MetricWithParams{
&utils.MetricWithParams{
MetricID: "*sum",
Parameters: "Param1",
tpStat.Metrics = []*utils.MetricWithFilters{
&utils.MetricWithFilters{
MetricID: "*sum",
},
&utils.MetricWithParams{
MetricID: "*averege",
Parameters: "Param1",
&utils.MetricWithFilters{
MetricID: "*averege",
},
}
if err := tpStatRPC.Call("ApierV1.SetTPStat", tpStat, &result); err != nil {
@@ -185,7 +182,7 @@ func testTPStatsUpdateTPStat(t *testing.T) {
}
func testTPStatsGetTPStatAfterUpdate(t *testing.T) {
var expectedTPS *utils.TPStats
var expectedTPS *utils.TPStatProfile
if err := tpStatRPC.Call("ApierV1.GetTPStat",
&utils.TPTntID{TPid: "TPS1", Tenant: "cgrates.org", ID: "Stat1"}, &expectedTPS); err != nil {
t.Error(err)
@@ -205,7 +202,7 @@ func testTPStatsRemTPStat(t *testing.T) {
}
func testTPStatsGetTPStatAfterRemove(t *testing.T) {
var respond *utils.TPStats
var respond *utils.TPStatProfile
if err := tpStatRPC.Call("ApierV1.GetTPStat",
&utils.TPTntID{TPid: "TPS1", Tenant: "cgrates.org", ID: "Stat1"},
&respond); err == nil || err.Error() != utils.ErrNotFound.Error() {

View File

@@ -37,7 +37,7 @@ var (
tpThresholdCfg *config.CGRConfig
tpThresholdRPC *rpc.Client
tpThresholdDataDir = "/usr/share/cgrates"
tpThreshold *utils.TPThreshold
tpThreshold *utils.TPThresholdProfile
tpThresholdDelay int
tpThresholdConfigDIR string //run tests for specific configuration
)
@@ -117,7 +117,7 @@ func testTPThreholdRpcConn(t *testing.T) {
}
func testTPThreholdGetTPThreholdBeforeSet(t *testing.T) {
var reply *utils.TPThreshold
var reply *utils.TPThresholdProfile
if err := tpThresholdRPC.Call("ApierV1.GetTPThreshold",
&utils.TPTntID{TPid: "TH1", Tenant: "cgrates.org", ID: "Threshold"}, &reply); err == nil ||
err.Error() != utils.ErrNotFound.Error() {
@@ -126,7 +126,7 @@ func testTPThreholdGetTPThreholdBeforeSet(t *testing.T) {
}
func testTPThreholdSetTPThrehold(t *testing.T) {
tpThreshold = &utils.TPThreshold{
tpThreshold = &utils.TPThresholdProfile{
TPid: "TH1",
Tenant: "cgrates.org",
ID: "Threshold",
@@ -150,7 +150,7 @@ func testTPThreholdSetTPThrehold(t *testing.T) {
}
func testTPThreholdGetTPThreholdAfterSet(t *testing.T) {
var respond *utils.TPThreshold
var respond *utils.TPThresholdProfile
if err := tpThresholdRPC.Call("ApierV1.GetTPThreshold",
&utils.TPTntID{TPid: "TH1", Tenant: "cgrates.org", ID: "Threshold"}, &respond); err != nil {
t.Error(err)
@@ -181,7 +181,7 @@ func testTPThreholdUpdateTPThrehold(t *testing.T) {
}
func testTPThreholdGetTPThreholdAfterUpdate(t *testing.T) {
var respond *utils.TPThreshold
var respond *utils.TPThresholdProfile
if err := tpThresholdRPC.Call("ApierV1.GetTPThreshold",
&utils.TPTntID{TPid: "TH1", Tenant: "cgrates.org", ID: "Threshold"}, &respond); err != nil {
t.Error(err)
@@ -201,7 +201,7 @@ func testTPThreholdRemTPThrehold(t *testing.T) {
}
func testTPThreholdGetTPThreholdAfterRemove(t *testing.T) {
var reply *utils.TPThreshold
var reply *utils.TPThresholdProfile
if err := tpThresholdRPC.Call("ApierV1.GetTPThreshold",
&utils.TPTntID{TPid: "TH1", Tenant: "cgrates.org", ID: "Threshold"}, &reply); err == nil ||
err.Error() != utils.ErrNotFound.Error() {