def test_build_a_merged_file_project(self): project = a_project()\ .with_merged_file("foo")\ .build() self.assertEqual( LatexProject(TexFile(LatexProjectBuilder.MERGED_FILE, "foo")), project)
def test_build_project_with_image(self): project = a_project()\ .with_image("img/result.pdf")\ .build() self.assertEqual( LatexProject( TexFile( "img/result.pdf", LatexProjectBuilder.IMAGE_CONTENT.format( key="img_result.pdf"))), project)
def test_difference_with_a_project_with_an_extra_file(self): try: extra_file = TexFile("extra/file.tex", "Extra blabla") self.tex.assert_is_equivalent_to( LatexProject(self.file, extra_file)) self.fail("Exception expected") except AssertionError as error: self.assertEqual( LatexProject.UNEXPECTED_FILE.format(file=extra_file.path), str(error))
def test_difference_with_a_project_whose_file_content_differs(self): try: content = "something different" self.tex.assert_is_equivalent_to( LatexProject(TexFile("main.tex", content))) self.fail("Exception expected") except AssertionError as error: self.assertEqual( LatexProject.CONTENT_MISMATCH.format(file="main.tex", actual=content, expected="blabla"), str(error))
def test_differ_when_file_path_differ(self): self.assertNotEqual( LatexProject(TexFile("a/different/path.tex", "blabla")), self.tex)
def test_differ_when_file_content_differ(self): self.assertNotEqual( LatexProject(TexFile("main.tex", "THIS IS DIFFERENT!")), self.tex)
def test_equals_a_project_with_similar_files(self): self.assertEqual(LatexProject(TexFile("main.tex", "blabla")), self.tex)
def setUp(self): self.file = TexFile("main.tex", "blabla") self.tex = LatexProject(self.file)
def test_does_not_equals_tex_file_with_a_different_content(self): self.assertNotEqual(TexFile(self.path, self.content + "blablabla"), self.tex_file)
def test_setup_a_two_files_project(self): self._do_test_setup( LatexProject(TexFile("main.tex", "blabla"), TexFile("result.tex", "Some results")))
def test_equals_a_similar_file(self): self.assertEqual(TexFile("test/main.tex", "foo"), self.tex_file)
def setUp(self): self.path = "test/main.tex" self.content = "foo" self.tex_file = TexFile(self.path, self.content)
def test_build_single_file_projects(self): project = a_project()\ .with_file("main.tex", "foo")\ .build() self.assertEqual(LatexProject(TexFile("main.tex", "foo")), project)
def _expected(self): tex_files = [] for (path, content) in self._files: tex_files.append(TexFile(path, content)) return LatexProject(*tex_files)
def test_setup_a_project_with_subdirectories(self): self._do_test_setup( LatexProject(TexFile("main.tex", "blabla"), TexFile("sections/introduction.tex", "introduction"), TexFile("sections/conclusions.tex", "conclusions"), TexFile("images/results.pdf", "PDF")))
def test_does_not_equals_tex_file_with_a_different_path(self): self.assertNotEqual(TexFile("dir/" + self.path, self.content), self.tex_file)
def _extract_tex_file(self, entry): return TexFile(self._extract_path(entry), self._extract_content(entry))
def test_setup_a_single_file_project(self): self._do_test_setup(LatexProject(TexFile("main.tex", "blabla")))