mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
added holiday rating plan test
This commit is contained in:
@@ -218,6 +218,38 @@ func TestSplitSpansRoundToIncrements(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCalldescHolliday(t *testing.T) {
|
||||
cd := &CallDescriptor{
|
||||
TimeStart: time.Date(2015, time.May, 1, 13, 30, 0, 0, time.UTC),
|
||||
TimeEnd: time.Date(2015, time.May, 1, 13, 35, 26, 0, time.UTC),
|
||||
RatingInfos: RatingInfos{
|
||||
&RatingInfo{
|
||||
RateIntervals: RateIntervalList{
|
||||
&RateInterval{
|
||||
Timing: &RITiming{WeekDays: utils.WeekDays{1, 2, 3, 4, 5}, StartTime: "00:00:00"},
|
||||
Weight: 10,
|
||||
},
|
||||
&RateInterval{
|
||||
Timing: &RITiming{WeekDays: utils.WeekDays{6, 7}, StartTime: "00:00:00"},
|
||||
Weight: 10,
|
||||
},
|
||||
&RateInterval{
|
||||
Timing: &RITiming{Months: utils.Months{time.May}, MonthDays: utils.MonthDays{1}, StartTime: "00:00:00"},
|
||||
Weight: 5,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
timespans := cd.splitInTimeSpans()
|
||||
if len(timespans) != 1 {
|
||||
t.Error("Error assiging holidy rate interval: ", timespans)
|
||||
}
|
||||
if timespans[0].RateInterval.Timing.MonthDays == nil {
|
||||
t.Errorf("Error setting holiday rate interval: %+v", timespans[0].RateInterval.Timing)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetCost(t *testing.T) {
|
||||
t1 := time.Date(2012, time.February, 2, 17, 30, 0, 0, time.UTC)
|
||||
t2 := time.Date(2012, time.February, 2, 18, 30, 0, 0, time.UTC)
|
||||
|
||||
@@ -327,6 +327,9 @@ func (i *RateInterval) GetCost(duration, startSecond time.Duration) float64 {
|
||||
|
||||
// Gets the price for a the provided start second
|
||||
func (i *RateInterval) GetRateParameters(startSecond time.Duration) (rate float64, rateIncrement, rateUnit time.Duration) {
|
||||
if i.Rating == nil {
|
||||
return -1, -1, -1
|
||||
}
|
||||
i.Rating.Rates.Sort()
|
||||
for index, price := range i.Rating.Rates {
|
||||
if price.GroupIntervalStart <= startSecond && (index == len(i.Rating.Rates)-1 ||
|
||||
|
||||
@@ -546,8 +546,8 @@ func (ts *TimeSpan) hasBetterRateIntervalThan(interval *RateInterval) bool {
|
||||
return false
|
||||
}
|
||||
//log.Print("StartTime: ", ts.TimeStart)
|
||||
//log.Printf("OWN: %+v", ts.RateInterval.Timing)
|
||||
//log.Printf("OTHER: %+v", interval.Timing)
|
||||
//log.Printf("OWN: %+v", ts.RateInterval)
|
||||
//log.Printf("OTHER: %+v", interval)
|
||||
// the lower the weight the better
|
||||
if ts.RateInterval != nil &&
|
||||
ts.RateInterval.Weight < interval.Weight {
|
||||
|
||||
Reference in New Issue
Block a user