Add integration test for RALsV1.GetRatinPlanCost in dispatcher

This commit is contained in:
TeoV
2019-07-30 11:19:08 +03:00
committed by Dan Christian Bogos
parent 5d7db1db47
commit d394f92181
2 changed files with 82 additions and 0 deletions

View File

@@ -19,3 +19,4 @@ cgrates.org,ATTR_API_DSP_AUTH,*auth,*string:~APIKey:dsp12345,,,APIMethods,*const
cgrates.org,ATTR_API_PSE_AUTH,*auth,*string:~APIKey:pse12345,,,APIMethods,*constant,SessionSv1.Ping&SessionSv1.AuthorizeEvent&SessionSv1.AuthorizeEventWithDigest&SessionSv1.InitiateSession&SessionSv1.InitiateSessionWithDigest&SessionSv1.UpdateSession&SessionSv1.SyncSessions&SessionSv1.TerminateSession&SessionSv1.ProcessCDR&SessionSv1.ProcessMessage&SessionSv1.GetActiveSessions&SessionSv1.GetActiveSessionsCount&SessionSv1.ForceDisconnect&SessionSv1.GetPassiveSessions&SessionSv1.GetPassiveSessionsCount&SessionSv1.ReplicateSessions&SessionSv1.SetPassiveSession&AttributeSv1.ProcessEvent&Responder.Debit&ResourceSv1.AllocateResources&ChargerSv1.ProcessEvent&Responder.MaxDebit,false,20
cgrates.org,ATTR_API_CFG_AUTH,*auth,*string:~APIKey:cfg12345,,,APIMethods,*constant,ConfigSv1.GetJSONSection,false,20
cgrates.org,ATTR_API_APIER_AUTH,*auth,*string:~APIKey:apier12345,,,APIMethods,*constant,ApierV1.GetAttributeProfile&ApierV1.SetAttributeProfile,false,20
cgrates.org,ATTR_API_RALS_AUTH,*auth,*string:~APIKey:rals12345,,,APIMethods,*constant,RALsV1.Ping&RALsV1.GetRatingPlansCost,false,20
1 #Tenant ID Contexts FilterIDs ActivationInterval AttributeFilterIDs FieldName Type Value Blocker Weight
19 cgrates.org ATTR_API_PSE_AUTH *auth *string:~APIKey:pse12345 APIMethods *constant SessionSv1.Ping&SessionSv1.AuthorizeEvent&SessionSv1.AuthorizeEventWithDigest&SessionSv1.InitiateSession&SessionSv1.InitiateSessionWithDigest&SessionSv1.UpdateSession&SessionSv1.SyncSessions&SessionSv1.TerminateSession&SessionSv1.ProcessCDR&SessionSv1.ProcessMessage&SessionSv1.GetActiveSessions&SessionSv1.GetActiveSessionsCount&SessionSv1.ForceDisconnect&SessionSv1.GetPassiveSessions&SessionSv1.GetPassiveSessionsCount&SessionSv1.ReplicateSessions&SessionSv1.SetPassiveSession&AttributeSv1.ProcessEvent&Responder.Debit&ResourceSv1.AllocateResources&ChargerSv1.ProcessEvent&Responder.MaxDebit false 20
20 cgrates.org ATTR_API_CFG_AUTH *auth *string:~APIKey:cfg12345 APIMethods *constant ConfigSv1.GetJSONSection false 20
21 cgrates.org ATTR_API_APIER_AUTH *auth *string:~APIKey:apier12345 APIMethods *constant ApierV1.GetAttributeProfile&ApierV1.SetAttributeProfile false 20
22 cgrates.org ATTR_API_RALS_AUTH *auth *string:~APIKey:rals12345 APIMethods *constant RALsV1.Ping&RALsV1.GetRatingPlansCost false 20

View File

@@ -0,0 +1,81 @@
// +build integration
/*
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
Copyright (C) ITsysCOM GmbH
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package dispatchers
import (
"testing"
"time"
"github.com/cgrates/cgrates/utils"
)
var sTestsDspRALs = []func(t *testing.T){
testDspRALsPing,
testDspRALsGetRatingPlanCost,
}
//Test start here
func TestDspRALsITMySQL(t *testing.T) {
testDsp(t, sTestsDspRALs, "TestDspRALsITMySQL", "all", "all2", "dispatchers", "tutorial", "oldtutorial", "dispatchers")
}
func testDspRALsPing(t *testing.T) {
var reply string
if err := allEngine.RCP.Call(utils.RALsV1Ping, new(utils.CGREvent), &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
if err := dispEngine.RCP.Call(utils.RALsV1Ping, &utils.CGREventWithArgDispatcher{
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
},
ArgDispatcher: &utils.ArgDispatcher{
APIKey: utils.StringPointer("rals12345"),
},
}, &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
}
func testDspRALsGetRatingPlanCost(t *testing.T) {
arg := &utils.RatingPlanCostArg{
Destination: "1002",
RatingPlanIDs: []string{"RP_1001", "RP_1002"},
SetupTime: utils.META_NOW,
Usage: "1h",
ArgDispatcher: &utils.ArgDispatcher{
APIKey: utils.StringPointer("rals12345"),
},
}
var reply RatingPlanCost
if err := dispEngine.RCP.Call(utils.RALsV1GetRatingPlansCost, arg, &reply); err != nil {
t.Error(err)
} else if reply.RatingPlanID != "RP_1001" {
t.Error("Unexpected RatingPlanID: ", reply.RatingPlanID)
} else if *reply.EventCost.Cost != 6.5118 {
t.Error("Unexpected Cost: ", *reply.EventCost.Cost)
} else if *reply.EventCost.Usage != time.Duration(time.Hour) {
t.Error("Unexpected Usage: ", *reply.EventCost.Usage)
}
}