Example #1
0
    def test_3_load_multiple_files(self):
        file_list = [pair_text_BP[0]["in"], pair_text_RG[0]["in"]]
        result = load(file_list)
        with open(pair_text_BP[0]["out"], "rb") as f:
            BPs_etalon = pickle.load(f)
        with open(pair_text_RG[0]["out"], "rb") as f:
            # pickle.dump(result, f)
            RGs_etalon = pickle.load(f)
        result.config["services charging billing-plan"]
        for etal, res in zip(BPs_etalon.config["services charging billing-plan"],
                       result.config["services charging billing-plan"]):
            self.assertEqual(etal.name, res.name)
            for etal_field, res_field in zip(etal["rating-group"], res["rating-group"]):
                # try:
                # print(f"field= {etal_field} = ", etal_field["fraud-charging"], res_field.name)
                self.assertEqual(etal_field.name, res_field.name, "check name of RG")
                self.assertEqual(etal_field["fraud-charging"], res_field["fraud-charging"],
                                 "check fraud-charging subfield")
                # except AttributeError:
                #     pass

        for etal, res in zip(RGs_etalon.config["services charging rating-group"],
                             result.config["services charging rating-group"]):
            self.assertEqual(etal.name, res.name)
            for etal_field, res_field in zip(etal.items(), res.items()):
                self.assertEqual(etal_field, res_field, "tuple(key, value)")
                # print(f"field= {etal_field} = ", etal_field, res_field)
            for sr_etal, sr_res in zip(etal["service-rule"], res["service-rule"]):
                self.assertEqual(sr_etal, sr_res, "values of service-rule")
Example #2
0
 def test_1_printOneObj(self):
     gen_object = load(pair_text_SR[1]["in"])
     result = str(dump(gen_object.config["service-construct service-rule"][0]))
     self.assertEqual(pair_text_SR[1]["in"], result.replace(linesep, "\n"), "stdout not eq")
     dump(gen_object.config["service-construct service-rule"][0], "temp.dump")
     with open("temp.dump", "r", newline=linesep) as f:
         result = f.read()
     self.assertEqual(pair_text_SR[1]["in"], result.replace(linesep, "\n"), "data in file not eq")
Example #3
0
    def test_3_printBP(self):
        for i, pair in enumerate(pair_text_BP):
            gen_object = load(pair["in"])
            result = str(dump(gen_object.config["services charging billing-plan"]))
            with open(pair["in"], "r", newline=linesep) as etal:
                etalon = etal.read()
            self.assertEqual(etalon, result, "stdout not eq")

            dump(gen_object.config["services charging billing-plan"], "temp.dump")
            with open("temp.dump", "r", newline=linesep) as dumpF:
                result = dumpF.read()
            self.assertEqual(etalon, result, "data in file not eq")
Example #4
0
    def test_2_printMult(self):
        for i, pair in enumerate(pair_text_SR_multiple):
            gen_object = load(pair["in"])
            result = str(dump(gen_object.config["service-construct service-rule"]))
            with open(pair["in"], "r", newline=linesep) as etal:
                etalon = etal.read()
            self.assertEqual(etalon, result, "stdout not eq")

            dump(gen_object.config["service-construct service-rule"], "temp.dump")
            with open("temp.dump", "r", newline=linesep) as dumpF:
                result = dumpF.read()
            self.assertEqual(etalon, result, "data in file not eq")

        for i, pair in enumerate(pair_text_RG):
            gen_object = load(pair["in"])
            result = str(dump(gen_object.config["services charging rating-group"]))
            with open(pair["in"], "r", newline=linesep) as etal:
                etalon = etal.read()
            self.assertEqual(etalon, result, "stdout not eq")

            dump(gen_object.config["services charging rating-group"], "temp.dump")
            with open("temp.dump", "r", newline=linesep) as dumpF:
                result = dumpF.read()
            self.assertEqual(etalon, result, "data in file not eq")
Example #5
0
 def test_1_RG(self):
     for i, pair in enumerate(pair_text_RG):
         result = load(pair["in"])
         with open(pair["out"], "rb") as f:
             # pickle.dump(result, f, 0)
             result_etalon = pickle.load(f)
         for res in result_etalon.config["services charging rating-group"]:
             rg = result.config["services charging rating-group"]
             rg_dic = {i.name: i for i in rg}
             self.assertEqual(res.name, rg_dic[res.name].name)
             for field in res:
                 try:
                     self.assertEqual(res[field], rg_dic[res.name][field])
                 except AttributeError:
                     pass
Example #6
0
 def test_2_BP(self):
     for i, pair in enumerate(pair_text_BP):
         result = load(pair["in"])
         with open(pair["out"], "rb") as f:
             # pickle.dump(result, f, 0)
             result_etalon = pickle.load(f)
         for res in result_etalon.config["services charging billing-plan"]:
             bp = result.config["services charging billing-plan"]
             bp_dic = {i.name: i for i in bp}
             # print("name=", result_etalon.bp[res].name, bp_dic[res].name)
             self.assertEqual(res.name, bp_dic[res.name].name)
             for field in res:
                 try:
                     # print(f"field= {field} = ", result_etalon.bp[res][field], [rg.name for rg in bp_dic[res][field]])
                     self.assertEqual([rg.name for rg in res[field]], [rg.name for rg in bp_dic[res.name][field]])
                 except AttributeError:
                     pass