class TestLicenseHeader(UnitTest): def test_create_replacement_rules(self): self.assert_equals({"year_": str(datetime.now().year)}, LicenseHeader.create_replacement_rules()) def test_instantiate(self): self.instance = LicenseHeader(self.fake_template).instantiate() for token, value in LicenseHeader.create_replacement_rules().items(): self.assert_string_does_not_contain(self.instance, token) self.assert_string_contains(self.instance, value) def test_instantiate_for_cmakelists(self): self.instance = LicenseHeader( self.fake_template).instantiate_for_cmakelists() for line in self.instance.splitlines(): self.assert_true(self.instance.startswith("# ")) self.assert_true(self.instance.endswith("\n\n")) def test_instantiate_for_cpp(self): self.instance = LicenseHeader(self.fake_template).instantiate_for_cpp() self.assert_true(self.instance.startswith("/* ")) self.assert_true(self.instance.endswith(" */\n\n")) def setUp(self): self.fake_template = "year_"
def setUp(self): self.namespace_begin = "namespace Fake {" self.namespace_end = "} /* Fake */" self.class_name = "arbitrary_name" self.interface_name = "interface_name" self.fake_template = self.namespace_begin + " CLASS_NAME_ class_name_ { }; " + self.namespace_end self.fake_interface = ( self.namespace_begin + "\nclass " + self.interface_name + " {\nvirtual void method1() = 0;\nvirtual void method2() = 0;\n};\n" + self.namespace_end) self.fake_raw_header = "};" self.fake_license_header = LicenseHeader("arbitrary license (year_)")
def create_license_header(self): return LicenseHeader(File.read(self.path.to_license_header_template))
def create_license_header(self): return LicenseHeader(File.read(self.path.to_license_header_template) ).instantiate_for_cmakelists()
def setUp(self): self.fake_template = "class_name_" self.fake_license_header = LicenseHeader("arbitrary license (year_)") self.class_name = "arbitrary_name"
def test_instantiate_for_cpp(self): self.instance = LicenseHeader(self.fake_template).instantiate_for_cpp() self.assert_true(self.instance.startswith("/* ")) self.assert_true(self.instance.endswith(" */\n\n"))
def test_instantiate_for_cmakelists(self): self.instance = LicenseHeader( self.fake_template).instantiate_for_cmakelists() for line in self.instance.splitlines(): self.assert_true(self.instance.startswith("# ")) self.assert_true(self.instance.endswith("\n\n"))
def test_instantiate(self): self.instance = LicenseHeader(self.fake_template).instantiate() for token, value in LicenseHeader.create_replacement_rules().items(): self.assert_string_does_not_contain(self.instance, token) self.assert_string_contains(self.instance, value)
def test_create_replacement_rules(self): self.assert_equals({"year_": str(datetime.now().year)}, LicenseHeader.create_replacement_rules())
def setUp(self): self.fake_template = "class_name_\n" self.fake_header = "virtual void method1() = 0;\nvirtual void method2() = 0;\n" self.fake_license_header = LicenseHeader("arbitrary license (year_)") self.class_name = "arbitrary_name"
def setUp(self): self.fake_template = "CLASS_NAME_ class_name_ { };" self.class_name = "arbitrary_name" self.fake_raw_header = "};" self.fake_license_header = LicenseHeader("arbitrary license (year_)")