Skip to content

Commit

Permalink
Default rating subject for *mms
Browse files Browse the repository at this point in the history
  • Loading branch information
danbogos committed Mar 24, 2020
1 parent e4355ba commit 1f05f6e
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 27 deletions.
9 changes: 3 additions & 6 deletions config/config_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,16 +241,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"
},
},
Expand Down
12 changes: 5 additions & 7 deletions config/config_json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 3 additions & 6 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,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)
Expand All @@ -396,12 +397,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)
Expand Down
2 changes: 1 addition & 1 deletion docs/sessions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion utils/coreutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 8 additions & 6 deletions utils/coreutils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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] {
Expand All @@ -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)
}
Expand Down

0 comments on commit 1f05f6e

Please sign in to comment.