apier vet

This commit is contained in:
Radu Ioan Fericean
2015-02-05 23:07:17 +02:00
parent 4ff96becee
commit 48bf322b16
5 changed files with 23 additions and 8 deletions

View File

@@ -435,7 +435,7 @@ func (self *ApierV1) SetActions(attrs AttrSetActions, reply *string) error {
// Retrieves actions attached to specific ActionsId within cache
func (self *ApierV1) GetActions(actsId string, reply *[]*utils.TPAction) error {
if len(actsId) == 0 {
return fmt.Errorf("%s:ActionsId", utils.ERR_MANDATORY_IE_MISSING, actsId)
return fmt.Errorf("%s ActionsId: %s", utils.ERR_MANDATORY_IE_MISSING, actsId)
}
acts := make([]*utils.TPAction, 0)
engActs, err := self.AccountDb.GetActions(actsId, false)

View File

@@ -217,7 +217,7 @@ func TestApierTPTiming(t *testing.T) {
// Test getIds
var rplyTmIds []string
expectedTmIds := []string{"ALWAYS", "ASAP"}
if err := rater.Call("ApierV1.GetTPTimingIds", AttrGetTPTimingIds{tmAlways.TPid, utils.Paginator{0, 0, ""}}, &rplyTmIds); err != nil {
if err := rater.Call("ApierV1.GetTPTimingIds", AttrGetTPTimingIds{tmAlways.TPid, utils.Paginator{Page: 0, ItemsPerPage: 0, SearchTerm: ""}}, &rplyTmIds); err != nil {
t.Error("Calling ApierV1.GetTPTimingIds, got error: ", err.Error())
} else if !reflect.DeepEqual(expectedTmIds, rplyTmIds) {
t.Errorf("Calling ApierV1.GetTPTimingIds expected: %v, received: %v", expectedTmIds, rplyTmIds)
@@ -325,7 +325,7 @@ func TestApierTPRate(t *testing.T) {
// Test getIds
var rplyRtIds []string
expectedRtIds := []string{"RT_FS_USERS"}
if err := rater.Call("ApierV1.GetTPRateIds", AttrGetTPRateIds{rt.TPid, utils.Paginator{0, 0, ""}}, &rplyRtIds); err != nil {
if err := rater.Call("ApierV1.GetTPRateIds", AttrGetTPRateIds{rt.TPid, utils.Paginator{Page: 0, ItemsPerPage: 0, SearchTerm: ""}}, &rplyRtIds); err != nil {
t.Error("Calling ApierV1.GetTPRateIds, got error: ", err.Error())
} else if !reflect.DeepEqual(expectedRtIds, rplyRtIds) {
t.Errorf("Calling ApierV1.GetTPDestinationIds expected: %v, received: %v", expectedRtIds, rplyRtIds)
@@ -382,7 +382,7 @@ func TestApierTPDestinationRate(t *testing.T) {
// Test getIds
var rplyDrIds []string
expectedDrIds := []string{"DR_FREESWITCH_USERS"}
if err := rater.Call("ApierV1.GetTPDestinationRateIds", AttrTPDestinationRateIds{dr.TPid, utils.Paginator{0, 0, ""}}, &rplyDrIds); err != nil {
if err := rater.Call("ApierV1.GetTPDestinationRateIds", AttrTPDestinationRateIds{dr.TPid, utils.Paginator{Page: 0, ItemsPerPage: 0, SearchTerm: ""}}, &rplyDrIds); err != nil {
t.Error("Calling ApierV1.GetTPDestinationRateIds, got error: ", err.Error())
} else if !reflect.DeepEqual(expectedDrIds, rplyDrIds) {
t.Errorf("Calling ApierV1.GetTPDestinationRateIds expected: %v, received: %v", expectedDrIds, rplyDrIds)
@@ -436,7 +436,7 @@ func TestApierTPRatingPlan(t *testing.T) {
// Test getIds
var rplyRpIds []string
expectedRpIds := []string{"RETAIL1"}
if err := rater.Call("ApierV1.GetTPRatingPlanIds", AttrGetTPRatingPlanIds{rp.TPid, utils.Paginator{0, 0, ""}}, &rplyRpIds); err != nil {
if err := rater.Call("ApierV1.GetTPRatingPlanIds", AttrGetTPRatingPlanIds{rp.TPid, utils.Paginator{Page: 0, ItemsPerPage: 0, SearchTerm: ""}}, &rplyRpIds); err != nil {
t.Error("Calling ApierV1.GetTPRatingPlanIds, got error: ", err.Error())
} else if !reflect.DeepEqual(expectedRpIds, rplyRpIds) {
t.Errorf("Calling ApierV1.GetTPRatingPlanIds expected: %v, received: %v", expectedRpIds, rplyRpIds)

View File

@@ -77,7 +77,14 @@ func (self *ApierV1) ImportTPZipFile(attrs AttrImportTPZipFile, reply *string) e
*reply = "ERROR: missing TPid!"
return err
}
csvImporter := engine.TPCSVImporter{attrs.TPid, self.StorDb, path, ',', false, ""}
csvImporter := engine.TPCSVImporter{
TPid: attrs.TPid,
StorDb: self.StorDb,
DirPath: path,
Sep: ',',
Verbose: false,
ImportId: "",
}
if errImport := csvImporter.Run(); errImport != nil {
return errImport
}

View File

@@ -58,7 +58,11 @@ func (self *ApierV1) GetTPActionPlan(attrs AttrGetTPActionPlan, reply *utils.TPA
} else if len(ats) == 0 {
return errors.New(utils.ERR_NOT_FOUND)
} else { // Got the data we need, convert it
atRply := &utils.TPActionPlan{attrs.TPid, attrs.Id, ats[attrs.Id]}
atRply := &utils.TPActionPlan{
TPid: attrs.TPid,
Id: attrs.Id,
ActionPlan: ats[attrs.Id],
}
*reply = *atRply
}
return nil

View File

@@ -56,7 +56,11 @@ func (self *ApierV1) GetTPActionTriggers(attrs AttrGetTPActionTriggers, reply *u
} else if len(atsMap) == 0 {
return errors.New(utils.ERR_NOT_FOUND)
} else {
atRply := &utils.TPActionTriggers{attrs.TPid, attrs.ActionTriggersId, atsMap[attrs.ActionTriggersId]}
atRply := &utils.TPActionTriggers{
TPid: attrs.TPid,
ActionTriggersId: attrs.ActionTriggersId,
ActionTriggers: atsMap[attrs.ActionTriggersId],
}
*reply = *atRply
}
return nil