Exemplo n.º 1
0
    def setUp(self):
        # TODO: we need prf_map, prf_imgs and prf_eth_map
        self.rtfparser = RTF_Parser()
        shutil.copyfile("newganmanager/.user/default_cfg.json",
                        "newganmanager/testing/.user/cfg.json")
        self.pm = Profile_Manager("No Profile", "newganmanager/testing")
        self.mapper = Mapper("newganmanager/test/", self.pm)
        self.pm.prf_cfg["img_dir"] = "newganmanager/test/"
        # data: UID, first_nat, sec_nat, eth-code
        self.data_simple = self.rtfparser.parse_rtf(
            "newganmanager/test/test_simple.rtf")
        self.data_all_cases = self.rtfparser.parse_rtf(
            "newganmanager/test/test_allcases.rtf")
        self.data_subset1 = self.rtfparser.parse_rtf(
            "newganmanager/test/allcases_subset1.rtf")
        self.data_subset2 = self.rtfparser.parse_rtf(
            "newganmanager/test/allcases_subset2.rtf")
        self.data_exclusive = self.rtfparser.parse_rtf(
            "newganmanager/test/test_exclusive.rtf")

        for eth in [
                "African", "Asian", "EECA", "Italmed", "SAMed",
                "South American", "SpanMed", "YugoGreek", "MENA", "MESA",
                "Caucasian", "Central European", "Scandinavian", "Seasian"
        ]:
            map = [eth + str(i) for i in range(20)]
            self.mapper.eth_map[eth] = set(map)
Exemplo n.º 2
0
 def _replace_faces(self, widget):
     self.logger.info("Start Replace Faces")
     # get values from UI elements
     rtf = self.profile_manager.prf_cfg['rtf']
     img_dir = self.profile_manager.prf_cfg['img_dir']
     profile = self.profile_manager.cur_prf
     mode = self.genmde_lst.value
     if not os.path.isfile(rtf):
         self._throw_error("The RTF file doesn't exist!")
         self.gen_prg.stop()
         self.profile_manager.prf_cfg['rtf'] = ''
         return
     if not os.path.isdir(img_dir):
         self._throw_error("The image directory doesn't exist!")
         self.gen_prg.stop()
         self.profile_manager.prf_cfg['img_dir'] = ''
         return
     self.logger.info("rtf: {}".format(rtf))
     self.logger.info("img_dir: {}".format(img_dir))
     self.logger.info("profile: {}".format(profile))
     self.logger.info("mode: {}".format(mode))
     self.gen_prg.start()
     self.gen_prg.update_label("Parsing RTF")
     yield 0.1
     rtf_data = RTF_Parser().parse_rtf(rtf)
     self.gen_prg.update_progress(20)
     self.gen_prg.update_label("Map player to ethnicity")
     yield 0.1
     mapping_data = Mapper(img_dir, self.profile_manager).generate_mapping(
         rtf_data, mode)
     self.gen_prg.update_progress(60)
     self.gen_prg.update_label("Generate config.xml")
     yield 0.1
     self.profile_manager.write_xml(mapping_data)
     # save profile metadata (used pics and config.xml)
     self.gen_prg.update_label("Save metadata for profile")
     self.gen_prg.update_progress(10)
     yield 0.1
     Config_Manager().save_config(
         str(self.paths.app) + "/.user/" + profile + ".json",
         self.profile_manager.prf_cfg)
     self.gen_prg.update_progress(10)
     yield 0.1
     self.gen_prg.update_label("Finished! :)")
     yield 0.1
     self._show_info("Finished! :)")
     self.gen_prg.stop()
Exemplo n.º 3
0
class Test_Mapper_Overwrite_Mapping(unittest.TestCase):
    def setUp(self):
        # TODO: we need prf_map, prf_imgs and prf_eth_map
        self.rtfparser = RTF_Parser()
        shutil.copyfile("newganmanager/.user/default_cfg.json",
                        "newganmanager/testing/.user/cfg.json")
        self.pm = Profile_Manager("No Profile", "newganmanager/testing")
        self.mapper = Mapper("newganmanager/test/", self.pm)
        self.pm.prf_cfg["img_dir"] = "newganmanager/test/"
        # data: UID, first_nat, sec_nat, eth-code
        self.data_simple = self.rtfparser.parse_rtf(
            "newganmanager/test/test_simple.rtf")
        self.data_all_cases = self.rtfparser.parse_rtf(
            "newganmanager/test/test_allcases.rtf")
        self.data_subset1 = self.rtfparser.parse_rtf(
            "newganmanager/test/allcases_subset1.rtf")
        self.data_subset2 = self.rtfparser.parse_rtf(
            "newganmanager/test/allcases_subset2.rtf")
        self.data_exclusive = self.rtfparser.parse_rtf(
            "newganmanager/test/test_exclusive.rtf")

        for eth in [
                "African", "Asian", "EECA", "Italmed", "SAMed",
                "South American", "SpanMed", "YugoGreek", "MENA", "MESA",
                "Caucasian", "Central European", "Scandinavian", "Seasian"
        ]:
            map = [eth + str(i) for i in range(20)]
            self.mapper.eth_map[eth] = set(map)

    def tearDown(self):
        shutil.rmtree("newganmanager/testing/.config/")
        shutil.copytree("newganmanager/.config/",
                        "newganmanager/testing/.config/")
        shutil.rmtree("newganmanager/testing/.user/")
        shutil.copytree("newganmanager/.user/", "newganmanager/testing/.user/")
        with open("newganmanager/test/config.xml", "w") as cfg:
            cfg.write('OUTSIDE')

    def test_overwrite_mapping_simple(self):
        mapping = self.mapper.generate_mapping(self.data_simple, "Overwrite")
        self.assertEqual("SpanMed", mapping[0][1])
        self.assertEqual("1915714540", mapping[0][0])
        self.assertEqual("MESA", mapping[1][1])
        self.assertEqual("1915576430", mapping[1][0])

    def test_overwrite_mapping_all_cases(self):
        mapping = self.mapper.generate_mapping(self.data_all_cases,
                                               "Overwrite")
        self.assertEqual("SpanMed", mapping[0][1])
        self.assertEqual("1915714540", mapping[0][0])
        self.assertEqual("MESA", mapping[1][1])
        self.assertEqual("1915576430", mapping[1][0])
        self.assertEqual("Italmed", mapping[2][1])
        self.assertEqual("1915576432", mapping[2][0])
        self.assertEqual("EECA", mapping[3][1])
        self.assertEqual("1915576433", mapping[3][0])
        self.assertEqual("SAMed", mapping[4][1])
        self.assertEqual("1915576434", mapping[4][0])
        self.assertEqual("South American", mapping[5][1])
        self.assertEqual("1915576435", mapping[5][0])
        self.assertEqual("YugoGreek", mapping[6][1])
        self.assertEqual("1915576436", mapping[6][0])
        self.assertEqual("African", mapping[7][1])
        self.assertEqual("1915576437", mapping[7][0])
        self.assertEqual("African", mapping[8][1])
        self.assertEqual("1915576438", mapping[8][0])
        self.assertEqual("African", mapping[9][1])
        self.assertEqual("1915576439", mapping[9][0])
        self.assertEqual("African", mapping[10][1])
        self.assertEqual("1915576440", mapping[10][0])
        self.assertEqual("African", mapping[11][1])
        self.assertEqual("1915576441", mapping[11][0])
        self.assertEqual("Asian", mapping[12][1])
        self.assertEqual("1915576442", mapping[12][0])
        self.assertEqual("MENA", mapping[13][1])
        self.assertEqual("1915576444", mapping[13][0])
        self.assertEqual("Seasian", mapping[14][1])
        self.assertEqual("1915576445", mapping[14][0])
        self.assertEqual("Scandinavian", mapping[15][1])
        self.assertEqual("1915576446", mapping[15][0])
        self.assertEqual("Caucasian", mapping[16][1])
        self.assertEqual("1915576447", mapping[16][0])
        self.assertEqual("Central European", mapping[17][1])
        self.assertEqual("1915576448", mapping[17][0])
        self.assertEqual("MESA", mapping[18][1])
        self.assertEqual("1915576450", mapping[18][0])

    def test_overwrite_mapping_double(self):
        simple_mapping = self.mapper.generate_mapping(self.data_simple,
                                                      "Overwrite")
        self.pm.write_xml(simple_mapping)
        next_mapping = self.mapper.generate_mapping(self.data_simple,
                                                    "Overwrite")
        self.pm.write_xml(next_mapping)
        self.assertNotEqual(simple_mapping, next_mapping)

    def test_overwrite_mapping_double_exclusive(self):
        simple_mapping = self.mapper.generate_mapping(self.data_simple,
                                                      "Overwrite")
        self.pm.write_xml(simple_mapping)
        next_mapping = self.mapper.generate_mapping(self.data_exclusive,
                                                    "Overwrite")
        self.pm.write_xml(next_mapping)
        self.assertEqual(simple_mapping, next_mapping[2:])
        self.assertEqual(len(next_mapping), 4)

    def test_overwrite_mapping_complete_subset(self):
        simple_mapping = self.mapper.generate_mapping(self.data_simple,
                                                      "Overwrite")
        self.pm.write_xml(simple_mapping)
        next_mapping = self.mapper.generate_mapping(self.data_all_cases,
                                                    "Overwrite")
        self.pm.write_xml(next_mapping)
        self.assertNotEqual(simple_mapping, next_mapping[:2])

    def test_overwrite_mapping_complete_subset_reverse(self):
        next_mapping = self.mapper.generate_mapping(self.data_all_cases,
                                                    "Overwrite")
        self.pm.write_xml(next_mapping)
        simple_mapping = self.mapper.generate_mapping(self.data_simple,
                                                      "Overwrite")
        self.pm.write_xml(simple_mapping)
        self.assertNotEqual(simple_mapping, next_mapping[:2])
        self.assertEqual(next_mapping[2:], simple_mapping[2:])

    def test_overwrite_mapping_partial_subset(self):
        sub2_mapping = self.mapper.generate_mapping(self.data_subset2,
                                                    "Overwrite")
        self.pm.write_xml(sub2_mapping)
        sub1_mapping = self.mapper.generate_mapping(self.data_subset1,
                                                    "Overwrite")
        self.pm.write_xml(sub1_mapping)
        self.assertNotEqual(sub1_mapping[:5], sub2_mapping[:5])
        self.assertIn(sub2_mapping[5], sub1_mapping)
        self.assertIn(sub2_mapping[6], sub1_mapping)
        self.assertIn(sub2_mapping[7], sub1_mapping)
        self.assertIn(sub2_mapping[8], sub1_mapping)
        self.assertIn(sub2_mapping[9], sub1_mapping)
        self.assertEqual(len(sub1_mapping), 12)

    def test_overwrite_mapping_partial_subset_reverse(self):
        sub1_mapping = self.mapper.generate_mapping(self.data_subset1,
                                                    "Overwrite")
        self.pm.write_xml(sub1_mapping)
        sub2_mapping = self.mapper.generate_mapping(self.data_subset2,
                                                    "Overwrite")
        self.pm.write_xml(sub2_mapping)
        self.assertNotEqual(sub1_mapping[:5], sub2_mapping[:5])
        self.assertEqual(len(sub2_mapping), 12)
Exemplo n.º 4
0
class Test_Mapper_Generate_Mapping(unittest.TestCase):
    def setUp(self):
        shutil.copyfile("newganmanager/.user/default_cfg.json",
                        "newganmanager/testing/.user/cfg.json")
        self.rtfparser = RTF_Parser()
        self.pm = Profile_Manager("No Profile", "newganmanager/testing")
        self.pm.prf_cfg["img_dir"] = "newganmanager/test/"
        self.mapper = Mapper("newganmanager/test/", self.pm)
        # data: UID, first_nat, sec_nat, eth-code
        self.data_simple = self.rtfparser.parse_rtf(
            "newganmanager/test/test_simple.rtf")
        self.data_all_cases = self.rtfparser.parse_rtf(
            "newganmanager/test/test_allcases.rtf")
        self.data_buggy_ethnicity = self.rtfparser.parse_rtf(
            "newganmanager/test/ethnicity.rtf")
        for eth in [
                "African", "Asian", "EECA", "Italmed", "SAMed",
                "South American", "SpanMed", "YugoGreek", "MENA", "MESA",
                "Caucasian", "Central European", "Scandinavian", "Seasian"
        ]:
            map = [eth + str(i) for i in range(20)]
            self.mapper.eth_map[eth] = set(map)

    def tearDown(self):
        shutil.rmtree("newganmanager/testing/.config/")
        shutil.copytree("newganmanager/.config/",
                        "newganmanager/testing/.config/")
        shutil.rmtree("newganmanager/testing/.user/")
        shutil.copytree("newganmanager/.user/", "newganmanager/testing/.user/")
        with open("newganmanager/test/config.xml", "w") as cfg:
            cfg.write('OUTSIDE')

    def test_generate_mapping_simple(self):
        mapping = self.mapper.generate_mapping(self.data_simple, "Generate")
        self.assertEqual("SpanMed", mapping[0][1])
        self.assertEqual("1915714540", mapping[0][0])
        self.assertEqual("MESA", mapping[1][1])
        self.assertEqual("1915576430", mapping[1][0])

    def test_generate_mapping_all_cases(self):
        mapping = self.mapper.generate_mapping(self.data_all_cases, "Generate")
        self.assertEqual("SpanMed", mapping[0][1])
        self.assertEqual("1915714540", mapping[0][0])
        self.assertEqual("MESA", mapping[1][1])
        self.assertEqual("1915576430", mapping[1][0])
        self.assertEqual("Italmed", mapping[2][1])
        self.assertEqual("1915576432", mapping[2][0])
        self.assertEqual("EECA", mapping[3][1])
        self.assertEqual("1915576433", mapping[3][0])
        self.assertEqual("SAMed", mapping[4][1])
        self.assertEqual("1915576434", mapping[4][0])
        self.assertEqual("South American", mapping[5][1])
        self.assertEqual("1915576435", mapping[5][0])
        self.assertEqual("YugoGreek", mapping[6][1])
        self.assertEqual("1915576436", mapping[6][0])
        self.assertEqual("African", mapping[7][1])
        self.assertEqual("1915576437", mapping[7][0])
        self.assertEqual("African", mapping[8][1])
        self.assertEqual("1915576438", mapping[8][0])
        self.assertEqual("African", mapping[9][1])
        self.assertEqual("1915576439", mapping[9][0])
        self.assertEqual("African", mapping[10][1])
        self.assertEqual("1915576440", mapping[10][0])
        self.assertEqual("African", mapping[11][1])
        self.assertEqual("1915576441", mapping[11][0])
        self.assertEqual("Asian", mapping[12][1])
        self.assertEqual("1915576442", mapping[12][0])
        self.assertEqual("MENA", mapping[13][1])
        self.assertEqual("1915576444", mapping[13][0])
        self.assertEqual("Seasian", mapping[14][1])
        self.assertEqual("1915576445", mapping[14][0])
        self.assertEqual("Scandinavian", mapping[15][1])
        self.assertEqual("1915576446", mapping[15][0])
        self.assertEqual("Caucasian", mapping[16][1])
        self.assertEqual("1915576447", mapping[16][0])
        self.assertEqual("Central European", mapping[17][1])
        self.assertEqual("1915576448", mapping[17][0])
        self.assertEqual("MESA", mapping[18][1])
        self.assertEqual("1915576450", mapping[18][0])

    def test_generate_mapping_double(self):
        simple_mapping = self.mapper.generate_mapping(self.data_simple,
                                                      "Generate")
        next_mapping = self.mapper.generate_mapping(self.data_simple,
                                                    "Generate")
        self.assertNotEqual(simple_mapping, next_mapping)

    def test_generate_mapping_permutations(self):
        self.eth_val = [str(i) for i in range(11)]
        self.ethnics = [
            "VIR", "PRK", "UZB", "ITA", "URU", "PUR", "POR", "SVN", "MAR",
            "YEM", "USA", "LIE", "SWE", "THA"
        ]
        product_inp = [["Name"], self.ethnics, self.ethnics, self.eth_val]
        map_list = list(itertools.product(*product_inp))
        for eth in [
                "African", "Asian", "EECA", "Italmed", "SAMed",
                "South American", "SpanMed", "YugoGreek", "MENA", "MESA",
                "Caucasian", "Central European", "Scandinavian", "Seasian"
        ]:
            map = [eth + str(i) for i in range(len(map_list))]
            self.mapper.eth_map[eth] = map
        self.mapper.generate_mapping(map_list, "Generate")

    def test_generate_user_rtf(self):
        rtf_files = [
            f.name for f in os.scandir("newganmanager/user_rtf")
            if f.is_file()
        ]
        for rtf in rtf_files:
            rtf_data = self.rtfparser.parse_rtf("newganmanager/user_rtf/" +
                                                rtf)
            map_data = self.mapper.generate_mapping(rtf_data, "Generate")

    def test_generate_mapping_duplicate(self):
        self.eth_val = [str(i) for i in range(11)]
        self.ethnics = [
            "VIR", "PRK", "UZB", "ITA", "URU", "PUR", "POR", "SVN", "MAR",
            "YEM", "USA", "LIE", "SWE", "THA"
        ]
        product_inp = [["Name"], self.ethnics, self.ethnics, self.eth_val]
        map_list = list(itertools.product(*product_inp))
        for eth in [
                "African", "Asian", "EECA", "Italmed", "SAMed",
                "South American", "SpanMed", "YugoGreek", "MENA", "MESA",
                "Caucasian", "Central European", "Scandinavian", "Seasian"
        ]:
            map = [eth + str(i) for i in range(3)]
            self.mapper.eth_map[eth] = map
        test_res = self.mapper.generate_mapping(map_list, "Generate", True)
        imgs = [i[2] for i in test_res]
        unique_img = set(imgs)
        self.assertGreaterEqual(len(imgs), len(unique_img))

    def test_buggy_ethnicity(self):
        map_data = self.mapper.generate_mapping(self.data_buggy_ethnicity,
                                                "Generate")
        self.assertEqual(len(map_data), 3)
Exemplo n.º 5
0
 def _replace_faces(self, widget):
     self.logger.info("Start Replace Faces")
     # get values from UI elements
     rtf = self.profile_manager.prf_cfg['rtf']
     img_dir = self.profile_manager.prf_cfg['img_dir']
     profile = self.profile_manager.cur_prf
     mode = self.genmde_lst.value
     if not os.path.isfile(rtf):
         self._throw_error("The RTF file doesn't exist!")
         self.gen_prg.stop()
         self.profile_manager.prf_cfg['rtf'] = ''
         return
     if not os.path.isdir(img_dir):
         self._throw_error("The image directory doesn't exist!")
         self.gen_prg.stop()
         self.profile_manager.prf_cfg['img_dir'] = ''
         return
     # Check if valid image_directory contains all the needed subfolders
     img_dirs = set()
     for entry in os.scandir(img_dir):
         if entry.is_dir():
             img_dirs.add(entry.name)
     for fp_dir in self.facepack_dirs:
         if fp_dir not in img_dirs:
             self._throw_error(
                 "Folder {} is missing in the image directory".format(
                     fp_dir))
             self.gen_prg.stop()
             return
     self.logger.info("rtf: {}".format(rtf))
     self.logger.info("img_dir: {}".format(img_dir))
     self.logger.info("profile: {}".format(profile))
     self.logger.info("mode: {}".format(mode))
     self.set_btns(False)
     self.gen_prg.start()
     self.gen_prg.update_label("Parsing RTF")
     # yield 0.1
     rtf_parser = RTF_Parser()
     if not rtf_parser.is_rtf_valid(rtf):
         self._throw_error("The RTF file is invalid!")
         self.gen_prg.stop()
         return
     rtf_data = rtf_parser.parse_rtf(rtf)
     self.gen_prg.update_progress(20)
     self.gen_prg.update_label("Map player to ethnicity")
     # yield 0.1
     mapping_data = Mapper(img_dir, self.profile_manager).generate_mapping(
         rtf_data, mode, self.gendup.is_on)
     self.gen_prg.update_progress(60)
     self.gen_prg.update_label("Generate config.xml")
     # yield 0.1
     self.profile_manager.write_xml(mapping_data)
     # save profile metadata (used pics and config.xml)
     self.gen_prg.update_label("Save metadata for profile")
     self.gen_prg.update_progress(10)
     # yield 0.1
     Config_Manager().save_config(
         str(self.paths.app) + "/.user/" + profile + ".json",
         self.profile_manager.prf_cfg)
     self.gen_prg.update_progress(10)
     # yield 0.1
     self.gen_prg.update_label("Finished! :)")
     # yield 0.1
     self._show_info("Finished! :)")
     self.gen_prg.stop()
     self.set_btns(True)
Exemplo n.º 6
0
 def test_parse_rtf_with_short_UIDs(self):
     test_simple_UID = RTF_Parser.parse_rtf(None, "newganmanager/test/test_simple_UID.rtf")
     self.assertSequenceEqual(test_simple_UID[0], ["1915576430", "KSA", "ARG", "2"])
     self.assertEqual(len(test_simple_UID), 1)
Exemplo n.º 7
0
 def test_parse_rtf(self):
     test_simple = RTF_Parser.parse_rtf(None, "newganmanager/test/test_simple.rtf")
     self.assertSequenceEqual(test_simple[0], ["1915714540", "ESP", "BAS", "1"])
     self.assertSequenceEqual(test_simple[1], ["1915576430", "KSA", "ARG", "2"])
     self.assertEqual(len(test_simple), 2)
Exemplo n.º 8
0
class Test_Mapper_Generate_Mapping(unittest.TestCase):
    def setUp(self):
        # TODO: we need prf_map, prf_imgs and prf_eth_map
        self.rtfparser = RTF_Parser()
        self.pm = Profile_Manager("No Profile", "newganmanager/testing/")
        self.pm.prf_cfg["img_dir"] = "newganmanager/test/"
        self.mapper = Mapper("newganmanager/test/", self.pm)
        # data: UID, first_nat, sec_nat, eth-code
        self.data_simple = self.rtfparser.parse_rtf(
            "newganmanager/test/test_simple.rtf")
        self.data_all_cases = self.rtfparser.parse_rtf(
            "newganmanager/test/test_allcases.rtf")
        for eth in [
                "African", "Asian", "EECA", "Italmed", "SAMed",
                "South American", "SpanMed", "YugoGreek", "MENA", "MESA",
                "Caucasian", "Central European", "Scandinavian", "Seasian"
        ]:
            map = [eth + str(i) for i in range(20)]
            self.mapper.eth_map[eth] = map

    def tearDown(self):
        shutil.rmtree("newganmanager/testing/.config/")
        shutil.copytree("newganmanager/.config/",
                        "newganmanager/testing/.config/")
        shutil.rmtree("newganmanager/testing/.user/")
        shutil.copytree("newganmanager/.user/", "newganmanager/testing/.user/")
        with open("newganmanager/test/config.xml", "w") as cfg:
            cfg.write('OUTSIDE')

    def test_generate_mapping_simple(self):
        mapping = self.mapper.generate_mapping(self.data_simple, "Generate")
        self.assertEqual("SpanMed", mapping[0][1])
        self.assertEqual("1915714540", mapping[0][0])
        self.assertEqual("MESA", mapping[1][1])
        self.assertEqual("1915576430", mapping[1][0])

    def test_generate_mapping_all_cases(self):
        mapping = self.mapper.generate_mapping(self.data_all_cases, "Generate")
        self.assertEqual("SpanMed", mapping[0][1])
        self.assertEqual("1915714540", mapping[0][0])
        self.assertEqual("MESA", mapping[1][1])
        self.assertEqual("1915576430", mapping[1][0])
        self.assertEqual("Italmed", mapping[2][1])
        self.assertEqual("1915576432", mapping[2][0])
        self.assertEqual("EECA", mapping[3][1])
        self.assertEqual("1915576433", mapping[3][0])
        self.assertEqual("SAMed", mapping[4][1])
        self.assertEqual("1915576434", mapping[4][0])
        self.assertEqual("South American", mapping[5][1])
        self.assertEqual("1915576435", mapping[5][0])
        self.assertEqual("YugoGreek", mapping[6][1])
        self.assertEqual("1915576436", mapping[6][0])
        self.assertEqual("African", mapping[7][1])
        self.assertEqual("1915576437", mapping[7][0])
        self.assertEqual("African", mapping[8][1])
        self.assertEqual("1915576438", mapping[8][0])
        self.assertEqual("African", mapping[9][1])
        self.assertEqual("1915576439", mapping[9][0])
        self.assertEqual("African", mapping[10][1])
        self.assertEqual("1915576440", mapping[10][0])
        self.assertEqual("African", mapping[11][1])
        self.assertEqual("1915576441", mapping[11][0])
        self.assertEqual("Asian", mapping[12][1])
        self.assertEqual("1915576442", mapping[12][0])
        self.assertEqual("MENA", mapping[13][1])
        self.assertEqual("1915576444", mapping[13][0])
        self.assertEqual("Seasian", mapping[14][1])
        self.assertEqual("1915576445", mapping[14][0])
        self.assertEqual("Scandinavian", mapping[15][1])
        self.assertEqual("1915576446", mapping[15][0])
        self.assertEqual("Caucasian", mapping[16][1])
        self.assertEqual("1915576447", mapping[16][0])
        self.assertEqual("Central European", mapping[17][1])
        self.assertEqual("1915576448", mapping[17][0])
        self.assertEqual("MESA", mapping[18][1])
        self.assertEqual("1915576450", mapping[18][0])

    def test_generate_mapping_double(self):
        simple_mapping = self.mapper.generate_mapping(self.data_simple,
                                                      "Generate")
        next_mapping = self.mapper.generate_mapping(self.data_simple,
                                                    "Generate")
        self.assertNotEqual(simple_mapping, next_mapping)
Exemplo n.º 9
0
 def test_valid_rtf(self):
     self.assertTrue(RTF_Parser.is_rtf_valid(None, "newganmanager/test/test_simple_UID.rtf"))
     self.assertFalse(RTF_Parser.is_rtf_valid(None, "newganmanager/test/false.rtf"))
Exemplo n.º 10
0
 def test_parse_rtf_fake_players(self):
     test_simple_UID_fake = RTF_Parser.parse_rtf(None, "newganmanager/test/test_simple_UID_fake.rtf")
     self.assertSequenceEqual(test_simple_UID_fake[0], ["1915576430", "KSA", "ARG", "2"])
     self.assertSequenceEqual(test_simple_UID_fake[1], ["1915576", "KSA", "GER", "2"])
     self.assertEqual(len(test_simple_UID_fake), 2)