In general_tests use testit Tarrifplans instead of oldtutorial for accounts_it_test.go

This commit is contained in:
TeoV
2018-11-28 08:37:06 -05:00
committed by Dan Christian Bogos
parent 628ae21a5b
commit 0283412767
4 changed files with 28 additions and 4 deletions

View File

@@ -1,2 +1,3 @@
#Tenant,Account,ActionPlanId,ActionTriggersId,AllowNegative,Disabled
cgrates.org,1001,PACKAGE_1001,,,
cgrates.org,1002,PACKAGE_1002,,,
1 #Tenant Account ActionPlanId ActionTriggersId AllowNegative Disabled
2 cgrates.org 1001 PACKAGE_1001
3 cgrates.org 1002 PACKAGE_1002

View File

@@ -1,2 +1,3 @@
#Id,ActionsId,TimingId,Weight
PACKAGE_1001,TOPUP_RST_MONETARY_10,*asap,10
PACKAGE_1002,TOPUP_RST_DATA_100,*asap,10
1 #Id ActionsId TimingId Weight
2 PACKAGE_1001 TOPUP_RST_MONETARY_10 *asap 10
3 PACKAGE_1002 TOPUP_RST_DATA_100 *asap 10

View File

@@ -1,3 +1,4 @@
#ActionsId[0],Action[1],ExtraParameters[2],Filter[3],BalanceId[4],BalanceType[5],Directions[6],Categories[7],DestinationIds[8],RatingSubject[9],SharedGroup[10],ExpiryTime[11],TimingIds[12],Units[13],BalanceWeight[14],BalanceBlocker[15],BalanceDisabled[16],Weight[17]
TOPUP_RST_MONETARY_10,*topup_reset,,,,*monetary,*out,,*any,,,*unlimited,,10,10,false,false,10
TOPUP_MONETARY_10,*topup,,,,*monetary,*out,,*any,,,*unlimited,,10,10,false,false,10
TOPUP_RST_DATA_100,*topup_reset,,,,*data,*out,,*any,,,*monthly,,4096,10,false,false,10
1 #ActionsId[0] Action[1] ExtraParameters[2] Filter[3] BalanceId[4] BalanceType[5] Directions[6] Categories[7] DestinationIds[8] RatingSubject[9] SharedGroup[10] ExpiryTime[11] TimingIds[12] Units[13] BalanceWeight[14] BalanceBlocker[15] BalanceDisabled[16] Weight[17]
2 TOPUP_RST_MONETARY_10 *topup_reset *monetary *out *any *unlimited 10 10 false false 10
3 TOPUP_MONETARY_10 *topup *monetary *out *any *unlimited 10 10 false false 10
4 TOPUP_RST_DATA_100 *topup_reset *data *out *any *monthly 4096 10 false false 10

View File

@@ -23,11 +23,9 @@ import (
"net/rpc"
"net/rpc/jsonrpc"
"path"
//"reflect"
"testing"
"time"
//"github.com/cgrates/cgrates/apier/v2"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
@@ -58,6 +56,7 @@ var sTestsAcc = []func(t *testing.T){
testV1AccRemAccountSet,
testV1AccGetAccountSetAfterDelete,
//testV1AccRemAccountAfterDelete,
testV1AccMonthly,
testV1AccStopEngine,
}
@@ -118,14 +117,16 @@ func testV1AccRpcConn(t *testing.T) {
func testV1AccGetAccountBeforeSet(t *testing.T) {
var reply *engine.Account
if err := accRpc.Call("ApierV2.GetAccount", &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001"}, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
if err := accRpc.Call("ApierV2.GetAccount",
&utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001"}, &reply); err == nil ||
err.Error() != utils.ErrNotFound.Error() {
t.Error(err)
}
}
func testV1AccLoadTarrifPlans(t *testing.T) {
var reply string
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "oldtutorial")}
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "testit")}
if err := accRpc.Call("ApierV1.LoadTariffPlanFromFolder", attrs, &reply); err != nil {
t.Error(err)
} else if reply != utils.OK {
@@ -213,6 +214,26 @@ func testV1AccRemAccountAfterDelete(t *testing.T) {
}
*/
func testV1AccMonthly(t *testing.T) {
// add 10 seconds delay before and after
timeAfter := time.Now().Add(10*time.Second).AddDate(0, 1, 0)
timeBefore := time.Now().Add(-10*time.Second).AddDate(0, 1, 0)
var reply *engine.Account
if err := accRpc.Call("ApierV2.GetAccount",
&utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1002"},
&reply); err != nil {
t.Error(err)
} else if _, has := reply.BalanceMap[utils.DATA]; !has {
t.Error("Unexpected balance returned: ", utils.ToJSON(reply.BalanceMap[utils.DATA]))
} else if len(reply.BalanceMap[utils.DATA]) != 1 {
t.Error("Unexpected number of balances returned: ", len(reply.BalanceMap[utils.DATA]))
} else if reply.BalanceMap[utils.DATA][0].ExpirationDate.After(timeAfter) &&
reply.BalanceMap[utils.DATA][0].ExpirationDate.Before(timeBefore) {
t.Error("Unexpected expiration date returned: ", reply.BalanceMap[utils.DATA][0].ExpirationDate)
}
}
func testV1AccStopEngine(t *testing.T) {
if err := engine.KillEngine(accDelay); err != nil {
t.Error(err)