mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
moved test data from tut and renamed prepaid1cent
This commit is contained in:
@@ -52,7 +52,7 @@ README:
|
||||
* Flush tables in storDb to start clean.
|
||||
* Start engine with default configuration and give it some time to listen (here caching can slow down, hence the command argument parameter).
|
||||
* Connect rpc client depending on encoding defined in configuration.
|
||||
* Execute remote Apis and test their replies(follow prepaid1cent scenario so we can test load in dataDb also).
|
||||
* Execute remote Apis and test their replies(follow testtp scenario so we can test load in dataDb also).
|
||||
*/
|
||||
|
||||
var cfgPath string
|
||||
@@ -1226,7 +1226,7 @@ func TestApierLoadTariffPlanFromFolder(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
// Simple test that command is executed without errors
|
||||
attrs = &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "prepaid1centpsec")}
|
||||
attrs = &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "testtp")}
|
||||
if err := rater.Call("ApierV1.LoadTariffPlanFromFolder", attrs, &reply); err != nil {
|
||||
t.Error("Got error on ApierV1.LoadTariffPlanFromFolder: ", err.Error())
|
||||
} else if reply != "OK" {
|
||||
|
||||
@@ -5,71 +5,6 @@ import (
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
type AttrAddActionTrigger struct {
|
||||
ActionTriggersId string
|
||||
ActionTriggersUniqueId string
|
||||
Tenant string
|
||||
Account string
|
||||
ThresholdType string
|
||||
ThresholdValue float64
|
||||
BalanceId string
|
||||
BalanceType string
|
||||
BalanceDirection string
|
||||
BalanceDestinationIds string
|
||||
BalanceRatingSubject string //ToDo
|
||||
BalanceWeight float64
|
||||
BalanceExpiryTime string
|
||||
BalanceSharedGroup string //ToDo
|
||||
Weight float64
|
||||
ActionsId string
|
||||
}
|
||||
|
||||
func (self *ApierV1) AddTriggeredAction(attr AttrAddActionTrigger, reply *string) error {
|
||||
if attr.BalanceDirection == "" {
|
||||
attr.BalanceDirection = utils.OUT
|
||||
}
|
||||
balExpiryTime, err := utils.ParseTimeDetectLayout(attr.BalanceExpiryTime, self.Config.DefaultTimezone)
|
||||
if err != nil {
|
||||
return utils.NewErrServerError(err)
|
||||
}
|
||||
at := &engine.ActionTrigger{
|
||||
ID: attr.ActionTriggersId,
|
||||
UniqueID: attr.ActionTriggersUniqueId,
|
||||
ThresholdType: attr.ThresholdType,
|
||||
ThresholdValue: attr.ThresholdValue,
|
||||
BalanceId: attr.BalanceId,
|
||||
BalanceType: attr.BalanceType,
|
||||
BalanceDirections: utils.ParseStringMap(attr.BalanceDirection),
|
||||
BalanceDestinationIds: utils.ParseStringMap(attr.BalanceDestinationIds),
|
||||
BalanceWeight: attr.BalanceWeight,
|
||||
BalanceExpirationDate: balExpiryTime,
|
||||
Weight: attr.Weight,
|
||||
ActionsId: attr.ActionsId,
|
||||
Executed: false,
|
||||
}
|
||||
|
||||
tag := utils.AccountKey(attr.Tenant, attr.Account)
|
||||
_, err = engine.Guardian.Guard(func() (interface{}, error) {
|
||||
userBalance, err := self.AccountDb.GetAccount(tag)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
userBalance.ActionTriggers = append(userBalance.ActionTriggers, at)
|
||||
|
||||
if err = self.AccountDb.SetAccount(userBalance); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return 0, nil
|
||||
}, 0, tag)
|
||||
if err != nil {
|
||||
*reply = err.Error()
|
||||
return err
|
||||
}
|
||||
*reply = OK
|
||||
return nil
|
||||
}
|
||||
|
||||
type AttrSetAccountActionTriggers struct {
|
||||
Tenant string
|
||||
Account string
|
||||
|
||||
@@ -4,3 +4,4 @@ cgrates.org,1002,PREPAID_10,STANDARD_TRIGGERS,,
|
||||
cgrates.org,1003,PREPAID_10,STANDARD_TRIGGERS,,
|
||||
cgrates.org,1004,PREPAID_10,STANDARD_TRIGGERS,,
|
||||
cgrates.org,1005,PREPAID_10,STANDARD_TRIGGERS,,
|
||||
cgrates.org,1009,TEST_EXE,,,
|
||||
|
@@ -1,3 +1,4 @@
|
||||
#Tag,ActionsTag,TimingTag,Weight
|
||||
PREPAID_10,PREPAID_10,ASAP,10
|
||||
PREPAID_10,BONUS_1,ASAP,10
|
||||
TEST_EXE,TOPUP_EXE,ALWAYS,10
|
||||
|
@@ -4,3 +4,4 @@ BONUS_1,*topup,,,,*monetary,*out,,*any,,,*unlimited,,1,10,false,false,10
|
||||
LOG_BALANCE,*log,,,,,,,,,,,,,,false,false,10
|
||||
CDRST_WARN_HTTP,*call_url,http://localhost:8080,,,,,,,,,,,,,false,false,10
|
||||
CDRST_LOG,*log,,,,,,,,,,,,,,false,false,10
|
||||
TOPUP_EXE,*topup,,,,*monetary,*out,,*any,,,*unlimited,,5,10,false,false,10
|
||||
|
@@ -1,3 +1,3 @@
|
||||
#Tag,Years,Months,MonthDays,WeekDays,Time
|
||||
ALWAYS,*any,*any,*any,*any,00:00:00
|
||||
ASAP,*any,*any,*any,*any,*asap
|
||||
ASAP,*any,*any,*any,*any,*asap
|
||||
|
@@ -4,4 +4,3 @@ cgrates.org,1002,PACKAGE_10,STANDARD_TRIGGERS,,
|
||||
cgrates.org,1003,PACKAGE_10,STANDARD_TRIGGERS,,
|
||||
cgrates.org,1004,PACKAGE_10,STANDARD_TRIGGERS,,
|
||||
cgrates.org,1007,USE_SHARED_A,STANDARD_TRIGGERS,,
|
||||
cgrates.org,1009,TEST_EXE,,,
|
||||
|
||||
|
@@ -6,4 +6,3 @@ USE_SHARED_A,SHARED_A_0,*asap,10
|
||||
PACKAGE_1001,TOPUP_RST_5,*asap,10
|
||||
PACKAGE_1001,TOPUP_RST_SHARED_5,*asap,10
|
||||
PACKAGE_1001,TOPUP_120_DST1003,*asap,10
|
||||
TEST_EXE,TOPUP_EXE,DAILY,10
|
||||
|
@@ -4,7 +4,6 @@ TOPUP_RST_5,*topup_reset,,,,*monetary,*out,,*any,,,*unlimited,,5,20,false,false,
|
||||
TOPUP_RST_5,*topup_reset,,,,*voice,*out,,DST_1002,SPECIAL_1002,,*unlimited,,90,20,false,false,10
|
||||
TOPUP_120_DST1003,*topup_reset,,,,*voice,*out,,DST_1003,,,*unlimited,,120,20,false,false,10
|
||||
TOPUP_RST_SHARED_5,*topup,,,,*monetary,*out,,*any,,SHARED_A,*unlimited,,5,10,false,false,10
|
||||
TOPUP_EXE,*topup,,,,*monetary,*out,,*any,,,*unlimited,,5,10,false,false,10
|
||||
SHARED_A_0,*topup_reset,,,,*monetary,*out,,*any,,SHARED_A,*unlimited,,0,10,false,false,10
|
||||
LOG_WARNING,*log,,,,,,,,,,,,,,false,false,10
|
||||
DISABLE_AND_LOG,*log,,,,,,,,,,,,,,false,false,10
|
||||
|
||||
|
@@ -4,5 +4,4 @@ ASAP,*any,*any,*any,*any,*asap
|
||||
PEAK,*any,*any,*any,1;2;3;4;5,08:00:00
|
||||
OFFPEAK_MORNING,*any,*any,*any,1;2;3;4;5,00:00:00
|
||||
OFFPEAK_EVENING,*any,*any,*any,1;2;3;4;5,19:00:00
|
||||
OFFPEAK_WEEKEND,*any,*any,*any,6;7,00:00:00
|
||||
DAILY,*any,*any,*any,*any,00:00:00
|
||||
OFFPEAK_WEEKEND,*any,*any,*any,6;7,00:00:00
|
||||
|
@@ -47,7 +47,7 @@ var accountDbCsv, accountDbStor, accountDbApier AccountingStorage // Each rating
|
||||
var storDb LoadStorage
|
||||
var lCfg *config.CGRConfig
|
||||
|
||||
var tpCsvScenario = flag.String("tp_scenario", "prepaid1centpsec", "Use this scenario folder to import tp csv data from")
|
||||
var tpCsvScenario = flag.String("tp_scenario", "testtp", "Use this scenario folder to import tp csv data from")
|
||||
|
||||
// Create connection to ratingDb
|
||||
// Will use 3 different datadbs in order to be able to see differences in data loaded
|
||||
|
||||
@@ -135,7 +135,7 @@ func TestMCDRCApierLoadTariffPlanFromFolder(t *testing.T) {
|
||||
}
|
||||
reply := ""
|
||||
// Simple test that command is executed without errors
|
||||
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "prepaid1centpsec")}
|
||||
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "testtp")}
|
||||
if err := rater.Call("ApierV1.LoadTariffPlanFromFolder", attrs, &reply); err != nil {
|
||||
t.Error("Got error on ApierV1.LoadTariffPlanFromFolder: ", err.Error())
|
||||
} else if reply != "OK" {
|
||||
|
||||
Reference in New Issue
Block a user