Default rating subject for *mms

This commit is contained in:
DanB
2020-03-24 19:16:31 +01:00
parent 4e9e794de9
commit 9b8243f285
6 changed files with 24 additions and 27 deletions

View File

@@ -242,16 +242,13 @@ const CGRATES_CFG_JSON = `
"*any": "189h",
"*voice": "72h",
"*data": "107374182400",
"*sms": "10000"
"*sms": "10000",
"*mms": "10000"
},
"max_increments": 1000000,
"balance_rating_subject":{ // default rating subject in case that balance rating subject is empty
"*any": "*zero1ns",
"*voice": "*zero1s",
"*data": "*zero1ns",
"*sms": "*zero1ns",
"*monetary":"*zero1ns",
"*generic":"*zero1ns",
"*voice": "*zero1s"
},
},

View File

@@ -495,15 +495,13 @@ func TestDfRalsJsonCfg(t *testing.T) {
utils.ANY: "189h",
utils.VOICE: "72h",
utils.DATA: "107374182400",
utils.SMS: "10000"},
utils.SMS: "10000",
utils.MMS: "10000",
},
Max_increments: utils.IntPointer(1000000),
Balance_rating_subject: &map[string]string{
utils.ANY: "*zero1ns",
utils.VOICE: "*zero1s",
utils.DATA: "*zero1ns",
utils.SMS: "*zero1ns",
utils.MONETARY: "*zero1ns",
utils.GENERIC: "*zero1ns",
utils.ANY: "*zero1ns",
utils.VOICE: "*zero1s",
},
}
if cfg, err := dfCgrJsonCfg.RalsJsonCfg(); err != nil {

View File

@@ -389,6 +389,7 @@ func TestCgrCfgJSONDefaultsRALs(t *testing.T) {
utils.VOICE: time.Duration(72 * time.Hour),
utils.DATA: time.Duration(107374182400),
utils.SMS: time.Duration(10000),
utils.MMS: time.Duration(10000),
}
if !reflect.DeepEqual(eMaxCU, cgrCfg.RalsCfg().MaxComputedUsage) {
t.Errorf("Expecting: %+v , received: %+v", eMaxCU, cgrCfg.RalsCfg().MaxComputedUsage)
@@ -397,12 +398,8 @@ func TestCgrCfgJSONDefaultsRALs(t *testing.T) {
t.Errorf("Expecting: 1000000 , received: %+v", cgrCfg.RalsCfg().MaxIncrements)
}
eBalRatingSbj := map[string]string{
utils.ANY: "*zero1ns",
utils.VOICE: "*zero1s",
utils.DATA: "*zero1ns",
utils.SMS: "*zero1ns",
utils.MONETARY: "*zero1ns",
utils.GENERIC: "*zero1ns",
utils.ANY: "*zero1ns",
utils.VOICE: "*zero1s",
}
if !reflect.DeepEqual(eBalRatingSbj, cgrCfg.RalsCfg().BalanceRatingSubject) {
t.Errorf("Expecting: %+v , received: %+v", eBalRatingSbj, cgrCfg.RalsCfg().BalanceRatingSubject)

View File

@@ -338,7 +338,7 @@ Instead of arguments, the options for enabling various functionaity will come in
**\*update**
Update a sesssion (or initialize + update) out of event.
**\*terminate
**\*terminate**
Terminate a session (or initialize + terminate) out of event.
\*suppliers

View File

@@ -337,7 +337,10 @@ func MinDuration(d1, d2 time.Duration) time.Duration {
func ParseZeroRatingSubject(tor, rateSubj string, defaultRateSubj map[string]string) (time.Duration, error) {
rateSubj = strings.TrimSpace(rateSubj)
if rateSubj == "" || rateSubj == ANY {
rateSubj = defaultRateSubj[tor]
var hasToR bool
if rateSubj, hasToR = defaultRateSubj[tor]; !hasToR {
rateSubj = defaultRateSubj[META_ANY]
}
}
if !strings.HasPrefix(rateSubj, ZERO_RATING_SUBJECT_PREFIX) {
return 0, errors.New("malformed rating subject: " + rateSubj)

View File

@@ -578,12 +578,8 @@ func TestParseZeroRatingSubject(t *testing.T) {
dur := []time.Duration{time.Second, time.Duration(1024),
time.Second, 5 * time.Minute, 10 * time.Hour}
dfltRatingSubject := map[string]string{
ANY: "*zero1ns",
VOICE: "*zero1s",
DATA: "*zero1ns",
SMS: "*zero1ns",
MONETARY: "*zero1ns",
GENERIC: "*zero1ns",
ANY: "*zero1ns",
VOICE: "*zero1s",
}
for i, s := range subj {
if d, err := ParseZeroRatingSubject(VOICE, s, dfltRatingSubject); err != nil || d != dur[i] {
@@ -593,6 +589,12 @@ func TestParseZeroRatingSubject(t *testing.T) {
if d, err := ParseZeroRatingSubject(DATA, EmptyString, dfltRatingSubject); err != nil || d != time.Nanosecond {
t.Error("Error parsing rating subject: ", EmptyString, d, err)
}
if d, err := ParseZeroRatingSubject(SMS, EmptyString, dfltRatingSubject); err != nil || d != time.Nanosecond {
t.Error("Error parsing rating subject: ", EmptyString, d, err)
}
if d, err := ParseZeroRatingSubject(MMS, EmptyString, dfltRatingSubject); err != nil || d != time.Nanosecond {
t.Error("Error parsing rating subject: ", EmptyString, d, err)
}
if d, err := ParseZeroRatingSubject(MONETARY, EmptyString, dfltRatingSubject); err != nil || d != time.Nanosecond {
t.Error("Error parsing rating subject: ", EmptyString, d, err)
}