mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-22 15:48:44 +05:00
Started removing timing
This commit is contained in:
committed by
Dan Christian Bogos
parent
53474406e3
commit
7671c0cb5e
@@ -83,54 +83,6 @@ func (pgnt Paginator) Clone() Paginator {
|
||||
}
|
||||
}
|
||||
|
||||
type ApierTPTiming struct {
|
||||
TPid string // Tariff plan id
|
||||
ID string // Timing id
|
||||
Years string // semicolon separated list of years this timing is valid on, *any supported
|
||||
Months string // semicolon separated list of months this timing is valid on, *any supported
|
||||
MonthDays string // semicolon separated list of month's days this timing is valid on, *any supported
|
||||
WeekDays string // semicolon separated list of week day names this timing is valid on *any supported
|
||||
Time string // String representing the time this timing starts on
|
||||
}
|
||||
|
||||
type TPTiming struct {
|
||||
ID string
|
||||
Years Years
|
||||
Months Months
|
||||
MonthDays MonthDays
|
||||
WeekDays WeekDays
|
||||
StartTime string
|
||||
EndTime string
|
||||
}
|
||||
|
||||
// TPTimingWithAPIOpts is used in replicatorV1 for dispatcher
|
||||
type TPTimingWithAPIOpts struct {
|
||||
*TPTiming
|
||||
Tenant string
|
||||
APIOpts map[string]interface{}
|
||||
}
|
||||
|
||||
func NewTiming(ID, years, mounths, mounthdays, weekdays, time string) (rt *TPTiming) {
|
||||
rt = &TPTiming{}
|
||||
rt.ID = ID
|
||||
rt.Years.Parse(years, InfieldSep)
|
||||
rt.Months.Parse(mounths, InfieldSep)
|
||||
rt.MonthDays.Parse(mounthdays, InfieldSep)
|
||||
rt.WeekDays.Parse(weekdays, InfieldSep)
|
||||
times := strings.Split(time, InfieldSep)
|
||||
rt.StartTime = times[0]
|
||||
if len(times) > 1 {
|
||||
rt.EndTime = times[1]
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
type AttrSetDestination struct {
|
||||
Id string
|
||||
Prefixes []string
|
||||
Overwrite bool
|
||||
}
|
||||
|
||||
type AttrGetCdrs struct {
|
||||
CgrIds []string // If provided, it will filter based on the cgrids present in list
|
||||
MediationRunIds []string // If provided, it will filter on mediation runid
|
||||
@@ -657,7 +609,7 @@ type TPFilterProfile struct {
|
||||
|
||||
// TPFilter is used in TPFilterProfile
|
||||
type TPFilter struct {
|
||||
Type string // Filter type (*string, *timing, *rsr_filters, *cdr_stats)
|
||||
Type string // Filter type (*string, *rsr_filters, *cdr_stats)
|
||||
Element string // Name of the field providing us the Values to check (used in case of some )
|
||||
Values []string // Filter definition
|
||||
}
|
||||
|
||||
@@ -89,34 +89,6 @@ func TestClonePaginator(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewTiming(t *testing.T) {
|
||||
eOut := &TPTiming{
|
||||
ID: "1",
|
||||
Years: Years{2020},
|
||||
Months: []time.Month{time.April},
|
||||
MonthDays: MonthDays{18},
|
||||
WeekDays: WeekDays{06},
|
||||
StartTime: "00:00:00",
|
||||
EndTime: "11:11:11",
|
||||
}
|
||||
rcv := NewTiming("1", "2020", "04", "18", "06", "00:00:00;11:11:11")
|
||||
if !reflect.DeepEqual(eOut, rcv) {
|
||||
t.Errorf("Expected %+v, received %+v", eOut, rcv)
|
||||
}
|
||||
//without endtime, check if .Split method works (only one timestamp)
|
||||
rcv = NewTiming("1", "2020", "04", "18", "06", "00:00:00")
|
||||
eOut.EndTime = ""
|
||||
if !reflect.DeepEqual(eOut, rcv) {
|
||||
t.Errorf("Expected %+v, received %+v", eOut, rcv)
|
||||
}
|
||||
//check if .Split method works (ignoring the last timestamp)
|
||||
rcv = NewTiming("1", "2020", "04", "18", "06", "00:00:00;11:11:11;22:22:22")
|
||||
eOut.EndTime = "11:11:11"
|
||||
if !reflect.DeepEqual(eOut, rcv) {
|
||||
t.Errorf("Expected %+v, received %+v", eOut, rcv)
|
||||
}
|
||||
}
|
||||
|
||||
//now working here
|
||||
func TestAttrGetCdrsAsCDRsFilter(t *testing.T) {
|
||||
attrGetCdrs := &AttrGetCdrs{
|
||||
@@ -561,7 +533,6 @@ func TestNewAttrReloadCacheWithOpts(t *testing.T) {
|
||||
DispatcherProfileIDs: {MetaAny},
|
||||
DispatcherHostIDs: {MetaAny},
|
||||
RateProfileIDs: {MetaAny},
|
||||
TimingIDs: {MetaAny},
|
||||
AttributeFilterIndexIDs: {MetaAny},
|
||||
ResourceFilterIndexIDs: {MetaAny},
|
||||
StatFilterIndexIDs: {MetaAny},
|
||||
|
||||
@@ -52,7 +52,7 @@ func TestProcessReSearchReplace2(t *testing.T) {
|
||||
|
||||
func TestProcessReSearchReplace3(t *testing.T) { //"MatchedDestId":"CST_31800_DE080"
|
||||
rsr := &ReSearchReplace{SearchRegexp: regexp.MustCompile(`"MatchedDestId":".+_(\w{5})"`), ReplaceTemplate: "$1"}
|
||||
source := `[{"TimeStart":"2014-04-15T22:17:57+02:00","TimeEnd":"2014-04-15T22:18:01+02:00","Cost":0,"RateInterval":{"Timing":{"Years":[],"Months":[],"MonthDays":[],"WeekDays":[],"StartTime":"00:00:00","EndTime":""},"Rating":{"ConnectFee":0,"Rates":[{"GroupIntervalStart":0,"Value":0,"RateIncrement":1000000000,"RateUnit":60000000000}],"RoundingMethod":"*middle","RoundingDecimals":4},"Weight":10},"CallDuration":4000000000,"Increments":null,"MatchedSubject":"*out:sip.test.cgrates.org:call:*any","MatchedPrefix":"+49800","MatchedDestId":"CST_31800_DE080"}]`
|
||||
source := `[{"TimeStart":"2014-04-15T22:17:57+02:00","TimeEnd":"2014-04-15T22:18:01+02:00","Cost":0,"RateInterval":{"Rating":{"ConnectFee":0,"Rates":[{"GroupIntervalStart":0,"Value":0,"RateIncrement":1000000000,"RateUnit":60000000000}],"RoundingMethod":"*middle","RoundingDecimals":4},"Weight":10},"CallDuration":4000000000,"Increments":null,"MatchedSubject":"*out:sip.test.cgrates.org:call:*any","MatchedPrefix":"+49800","MatchedDestId":"CST_31800_DE080"}]`
|
||||
expectOut := "DE080"
|
||||
if outStr := rsr.Process(source); outStr != expectOut {
|
||||
t.Error("Unexpected output from SearchReplace: ", outStr)
|
||||
|
||||
@@ -25,13 +25,12 @@ import (
|
||||
|
||||
func TestMissingStructFieldsCorrect(t *testing.T) {
|
||||
var attr = struct {
|
||||
Tenant string
|
||||
Account string
|
||||
Type string
|
||||
ActionTimingsID string
|
||||
}{"bevoip.eu", "danconns0001", MetaPrepaid, "mama"}
|
||||
Tenant string
|
||||
Account string
|
||||
Type string
|
||||
}{"bevoip.eu", "danconns0001", MetaPrepaid}
|
||||
if missing := MissingStructFields(&attr,
|
||||
[]string{"Tenant", "Account", "Type", "ActionTimingsID"}); len(missing) != 0 {
|
||||
[]string{"Tenant", "Account", "Type"}); len(missing) != 0 {
|
||||
t.Error("Found missing field on correct struct", missing)
|
||||
}
|
||||
}
|
||||
@@ -80,13 +79,12 @@ func TestUpdateStructWithIfaceMap(t *testing.T) {
|
||||
|
||||
func TestMissingStructFieldsAppend(t *testing.T) {
|
||||
var attr = struct {
|
||||
Tenant string
|
||||
Account string
|
||||
Type string
|
||||
ActionTimingsID string
|
||||
}{"", "", MetaPrepaid, ""}
|
||||
Tenant string
|
||||
Account string
|
||||
Type string
|
||||
}{"", "", MetaPrepaid}
|
||||
missing := MissingStructFields(&attr,
|
||||
[]string{"Tenant", "Account", "Type", "ActionTimingsID"})
|
||||
[]string{"Tenant", "Account", "Type"})
|
||||
if len(missing) == 0 {
|
||||
t.Error("Required missing field not found")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user