def test_all(self):
        info = GenerationInfoByTarget()

        info.name = "module_1"
        info.child_modules.append("submodule_1")
        info.child_modules.append("submodule_2")

        constant_info = self._create_constant_info()
        info.data.append(constant_info)

        dep_1 = Dependency()
        dep_1.mod_name = "module_1"
        dep_1.add_type("Class1")
        dep_1.add_type("Class2")
        info.dependencies.append(dep_1)

        dep_2 = Dependency()
        dep_2.mod_name = "module_2"
        dep_2.add_type("ClassZ")
        info.dependencies.append(dep_2)

        info.external_modules.append("os")

        self.assertEqual(info.name, "module_1")
        self.assertEquals(info.child_modules, ["submodule_1", "submodule_2"])
        self.assertEquals(info.data, [constant_info])
        self.assertEquals(info.dependencies, [dep_1, dep_2])
        self.assertEquals(info.external_modules, ["sys", "typing", "os"])
    def test_dump_json(self):
        info = GenerationInfoByTarget()

        info.name = "module_1"
        info.data.append(self._create_constant_info())
        info.data.append(self._create_function_info())
        info.data.append(self._create_base_class_1_info())
        info.data.append(self._create_base_class_2_info())
        info.data.append(self._create_class_info())
        info.child_modules.append("submodule_1")

        dep = Dependency()
        dep.mod_name = "module_2"
        dep.add_type("Class1")
        dep.add_type("Class2")
        info.dependencies.append(dep)

        dep = Dependency()
        dep.mod_name = ".submodule_2"
        dep.add_type("ClassZ")
        info.dependencies.append(dep)

        info.external_modules.append("os")

        generator = BaseGenerator()
        generator.dump_json(self.output_file_path, info)

        expect_file_path = "{}/{}".format(self.data_dir, "base_generator_test_dump_json.json")
        with open(expect_file_path, "r") as f:
            expect_data = { "data": json.load(f) }
        actual_file_path = self.output_file_path
        with open(actual_file_path, "r") as f:
            actual_data = { "data": json.load(f) }
        self.assertDictEqual(expect_data, actual_data)
    def test_pre_process(self):
        info = GenerationInfoByTarget()

        info.name = "module_1"
        info.data.append(self._create_constant_info())
        info.data.append(self._create_function_info())
        info.data.append(self._create_base_class_1_info())
        info.data.append(self._create_base_class_2_info())
        info.data.append(self._create_class_info())
        info.child_modules.append("submodule_1")

        dep = Dependency()
        dep.mod_name = "module_2"
        dep.add_type("Class1")
        dep.add_type("Class2")
        info.dependencies.append(dep)

        dep = Dependency()
        dep.mod_name = ".submodule_2"
        dep.add_type("ClassZ")
        info.dependencies.append(dep)

        info.external_modules.append("os")

        generator = BaseGenerator()
        processed_info = generator.pre_process("module_1", info)

        self.assertEqual(info.name, processed_info.name)
        self.assertEquals(info.child_modules, processed_info.child_modules)
        self.assertEquals(info.dependencies, processed_info.dependencies)
        self.assertEquals(info.external_modules, processed_info.external_modules)
        self.assertEquals(info.data, processed_info.data)
    def test_generate(self):
        info = GenerationInfoByTarget()

        info.name = "module_1"
        info.data.append(self._create_constant_info())
        info.data.append(self._create_function_info())
        info.data.append(self._create_base_class_1_info())
        info.data.append(self._create_base_class_2_info())
        info.data.append(self._create_class_info())
        info.child_modules.append("submodule_1")

        dep = Dependency()
        dep.mod_name = "module_2"
        dep.add_type("Class1")
        dep.add_type("Class2")
        info.dependencies.append(dep)

        dep = Dependency()
        dep.mod_name = ".submodule_2"
        dep.add_type("ClassZ")
        info.dependencies.append(dep)

        info.external_modules.append("os")

        generator = BaseGenerator()
        generator.generate(self.output_file_path, info, "pep8")

        expect_file_path = "{}/{}".format(self.data_dir, "base_generator_test_generate.py")
        actual_file_path = self.output_file_path
        with open(actual_file_path, "r") as f:
            self.log(f.read())
        self.assertTrue(filecmp.cmp(expect_file_path, actual_file_path))
    def test_all(self):
        dep = Dependency()

        dep.mod_name = "module_1"
        dep.add_type("ClassA")
        dep.add_type("ClassB")

        self.assertEqual(dep.mod_name, "module_1")
        self.assertEqual(len(dep.type_lists), 2)
        self.assertEquals(dep.type_lists, ["ClassA", "ClassB"])