Пример #1
0
 def testDirectoryContainsOnlyItsDirectContent(self):
     self.fileSystem.create_file(Path.fromText("dir/test.txt"), "x")
     self.fileSystem.create_file(Path.fromText("dir/test2.txt"), "y")
     self.fileSystem.create_file(Path.fromText("dir/more/test.txt"), "x")
     directory = self.fileSystem.open(Path.fromText("dir"))
     self.assertEqual(len(directory.files()), 3, [
                      str(file.path()) for file in directory.files()])
Пример #2
0
    def test_as_absolute_with_implicit_current(self):
        path = Path.fromText("test/foo.txt")

        absolute_path = path.absolute_from(Path.fromText("/home/franck"))

        self.assertEqual(absolute_path,
                         Path.fromText("/home/franck/test/foo.txt"))
Пример #3
0
 def test_file_creation(self):
     path = Path.fromText("dir/test/source.tex")
     self.fileSystem.create_file(path, "blah")
     
     file = self.fileSystem.open(Path.fromText("dir/test/source.tex"))
     
     self.assertTrue(file.exists())
     self.assertTrue(file.contains("blah"))
Пример #4
0
    def test_finding_files_in_the_current_directory(self):
        path = Path.fromText("/root/foo/bar/test.txt")
        self.fileSystem.create_file(path, "blahblah blah")

        self.fileSystem.move_to_directory(Path.fromText("/root/foo"))
        file = self.fileSystem.open(Path.fromText("bar/test.txt"))

        self.assertEqual(file.content(), "blahblah blah")
Пример #5
0
    def test_file_creation(self):
        path = Path.fromText("dir/test/source.tex")
        self.fileSystem.create_file(path, "blah")

        file = self.fileSystem.open(Path.fromText("dir/test/source.tex"))

        self.assertTrue(file.exists())
        self.assertTrue(file.contains("blah"))
Пример #6
0
    def test_finding_files_in_the_current_directory(self):
        path = Path.fromText("/root/foo/bar/test.txt")
        self.fileSystem.create_file(path, "blahblah blah")

        self.fileSystem.move_to_directory(Path.fromText("/root/foo"))
        file = self.fileSystem.open(Path.fromText("bar/test.txt"))

        self.assertEqual(file.content(), "blahblah blah")
Пример #7
0
    def testCopyingFile(self):
        source = Path.fromText("dir/test.txt")
        self.fileSystem.create_file(source, "whatever")
        file = self.fileSystem.open(source)
        destination = Path.fromText("dir2/clone")

        self.fileSystem.copy(file, destination)

        copy = self.fileSystem.open(destination / "test.txt")
        self.assertTrue(copy.exists())
        self.assertEqual(copy.content(), "whatever")
Пример #8
0
    def testCopyingFile(self):
        source = Path.fromText("dir/test.txt")
        self.fileSystem.create_file(source, "whatever")
        file = self.fileSystem.open(source)
        destination = Path.fromText("dir2/clone")

        self.fileSystem.copy(file, destination)

        copy = self.fileSystem.open(destination / "test.txt")
        self.assertTrue(copy.exists())
        self.assertEqual(copy.content(), "whatever")
Пример #9
0
 def files_that_matches(self, pattern):
     path = Path.fromText(str(self._path) + "/" + str(pattern))
     directory = self.fileSystem.open(path.container())
     return [
         any_file for any_file in directory.files()
         if str(any_file.path()).startswith(str(path))
     ]
Пример #10
0
 def _find(path, directories, extensions, error):
     for any_directory in directories:
         candidates = any_directory.files_that_matches(Path.fromText(path))
         for any_possible_extension in extensions:
             for any_resource in candidates:
                 if any_resource.has_extension(any_possible_extension):
                     return any_resource
     raise error
Пример #11
0
 def _find(path, directories, extensions, error):
     for any_directory in directories:
         candidates = any_directory.files_that_matches(Path.fromText(path))
         for any_possible_extension in extensions:
             for any_resource in candidates:
                 if any_resource.has_extension(any_possible_extension):
                     return any_resource
     raise error
Пример #12
0
def load_tests(loader, tests, pattern):
    file_system = OSFileSystem()
    repository = FileBasedTestRepository(file_system, Path.fromText("tests/acceptance/scenarios"), YamlCodec())
    runner = EndToEndRunner(file_system)
    generate = Generator(repository, runner)
    suite = TestSuite()
    tests = loader.loadTestsFromTestCase(generate.test_class())
    suite.addTests(tests)
    return suite
Пример #13
0
def load_tests(loader, tests, pattern):
    file_system = OSFileSystem()
    repository = FileBasedTestRepository(file_system, Path.fromText("tests/acceptance/scenarios"), YamlCodec())
    runner = EndToEndRunner(file_system)
    generate = Generator(repository, runner)
    suite = TestSuite()
    tests = loader.loadTestsFromTestCase(generate.test_class())
    suite.addTests(tests)
    return suite
Пример #14
0
 def __init__(self):
     super().__init__()
     self.current_directory = Path.fromText(os.getcwd())
Пример #15
0
 def testFilteringFilesInDirectory(self):
     self.fileSystem.create_file(Path.fromText("dir/test.txt"), "x")
     self.fileSystem.create_file(Path.fromText("dir/test2.txt"), "y")
     self.fileSystem.create_file(Path.fromText("dir/blah"), "z")
     file = self.fileSystem.open(Path.fromText("dir"))
     self.assertEqual(len(file.files_that_matches("test")), 2)
Пример #16
0
 def testDirectoryContainsFiles(self):
     self.fileSystem.create_file(Path.fromText("dir/test.txt"), "x")
     self.fileSystem.create_file(Path.fromText("dir/test2.txt"), "y")
     file = self.fileSystem.open(Path.fromText("dir"))
     self.assertEqual(len(file.files()), 2)
Пример #17
0
    def test_as_absolute_with_absolute_path(self):
        path = Path.fromText("/home/test/foo.txt")

        absolute_path = path.absolute_from(Path.fromText("/home/franck"))

        self.assertEqual(absolute_path, Path.fromText("/home/test/foo.txt"))
Пример #18
0
    def test_relative_to_file(self):
        path = Path.fromText("/home/test/foo.txt")

        relative = path.relative_to(Path.fromText("/home/test"))

        self.assertEquals(relative, Path.fromText("foo.txt"))
Пример #19
0
 def testDirectoryContainsFiles(self):
     self.fileSystem.create_file(Path.fromText("dir/test.txt"), "x")
     self.fileSystem.create_file(Path.fromText("dir/test2.txt"), "y")
     file = self.fileSystem.open(Path.fromText("dir"))
     self.assertEqual(len(file.files()), 2)
Пример #20
0
 def testThatMissingFileDoNotExist(self):
     path = Path.fromText("file\\that\\do\\not\\exist.txt")
     file = self.fileSystem.open(path)
     self.assertFalse(file.exists())
Пример #21
0
    def test_as_absolute_with_root(self):
        path = ROOT

        absolute_path = path.absolute_from(Path.fromText("/home/franck"))

        self.assertEqual(absolute_path, ROOT)
Пример #22
0
 def test_is_absolute_on_windows_paths(self):
     path = Path.fromText("C:\\Users\\franckc\\file.txt")
     self.assertTrue(path.is_absolute())
Пример #23
0
 def test_is_absolute_with_relative(self):
     path = Path.fromText("franck/test.tex")
     self.assertFalse(path.is_absolute())
Пример #24
0
 def test_is_absolute_on_windows_paths(self):
     path = Path.fromText("C:\\Users\\franckc\\file.txt")
     self.assertTrue(path.is_absolute())
Пример #25
0
 def test_is_absolute_on_unix_paths(self):
     path = Path.fromText("/home/franck/test.tex")
     self.assertTrue(path.is_absolute())
Пример #26
0
    def test_relative_to_directory(self):
        path = Path.fromText("/home/test/foo.txt")

        relative = path.relative_to(Path.fromText("/home"))

        self.assertEquals(relative, Path.fromText("test/foo.txt"))
Пример #27
0
    def test_as_absolute_with_root(self):
        path = ROOT

        absolute_path = path.absolute_from(Path.fromText("/home/franck"))

        self.assertEqual(absolute_path, ROOT)
Пример #28
0
    def test_parsing_directory(self):
        path = Path.fromText("project/img/")

        parts = [each.fullname() for each in path.parts()]
        self.assertEqual(parts, ["project", "img"], "Wrong parts!")
Пример #29
0
 def testPathBuilding(self):
     path = Path.fromText("\\Users\\franckc\\file.txt")
     
     self.assertEqual(path, ROOT / "Users" / "franckc" / "file.txt")
Пример #30
0
    def test_relative_to_directory(self):
        path = Path.fromText("/home/test/foo.txt")

        relative = path.relative_to(Path.fromText("/home"))

        self.assertEqual(relative, Path.fromText("test/foo.txt"))
Пример #31
0
 def testFullNameIsAvailable(self):
     path = Path.fromText("/my/dir/test.txt")
     self.fileSystem.create_file(path, "data")
     file = self.fileSystem.open(path)
     self.assertEqual(file.fullname(), "test.txt")
Пример #32
0
 def _verify_generated_files(self, test_case):
     location = self._file_system.open(Path.fromText("output"))
     actual = LatexProject.extract_from_directory(location)
     actual.assert_is_equivalent_to(test_case._expected)
Пример #33
0
 def testFilteringFilesInDirectory(self):
     self.fileSystem.create_file(Path.fromText("dir/test.txt"), "x")
     self.fileSystem.create_file(Path.fromText("dir/test2.txt"), "y")
     self.fileSystem.create_file(Path.fromText("dir/blah"), "z")
     file = self.fileSystem.open(Path.fromText("dir"))
     self.assertEqual(len(file.files_that_matches("test")), 1)
Пример #34
0
 def test_is_absolute_on_unix_paths(self):
     path = Path.fromText("/home/franck/test.tex")
     self.assertTrue(path.is_absolute())
Пример #35
0
 def output_directory(self):
     return Path.fromText(self._output)
Пример #36
0
 def _do_test_setup(self, project):
     project.setup(self._file_system, Path.fromText(self._directory))
     self._verify(project)
Пример #37
0
 def testBasenameIsAvailable(self):
     path = Path.fromText("my/dir/test.txt")
     self.fileSystem.create_file(path, "whatever")
     file = self.fileSystem.open(path)
     self.assertEqual(file.basename(), "test")
Пример #38
0
 def _verify(self, project):
     for (path, file) in project.files.items():
         file_on_disk = self._file_system.open(
             Path.fromText(self._directory) / path)
         self.assertEqual(file.content, file_on_disk.content())
Пример #39
0
 def testDirectoryContainsOnlyItsDirectContent(self):
     self.fileSystem.create_file(Path.fromText("dir/test.txt"), "x")
     self.fileSystem.create_file(Path.fromText("dir/test2.txt"), "y")
     self.fileSystem.create_file(Path.fromText("dir/more/test.txt"), "x")
     directory = self.fileSystem.open(Path.fromText("dir"))
     self.assertEqual(len(directory.files()), 3, [ str(file.path()) for file in directory.files() ])
Пример #40
0
 def _create_files(self, *files):
     self._files = files
     for (path, content) in files:
         complete_path = Path.fromText(self._directory + path)
         self._file_system.create_file(complete_path, content)
Пример #41
0
    def testParts(self):
        path = Path.fromText("C:\\Users\\franckc\\pub\\JOCC\\main.tex")

        self.verify_parts(path, ["C:", "Users", "franckc", "pub", "JOCC", "main.tex"])
Пример #42
0
 def _extract_project(self):
     root = self._file_system.open(Path.fromText(self._directory))
     return LatexProject.extract_from_directory(root)
Пример #43
0
 def test_files_that_match_with_multiple_matches(self):
     self.fileSystem.create_file(Path.fromText("dir/foo/test.txt"), "x")
     self.fileSystem.create_file(Path.fromText("dir/foo/subtest.txt"), "x")
     directory = self.fileSystem.open(Path.fromText("dir/foo"))
     results = directory.files_that_matches("test")
     self.assertEqual(len(results), 1)
Пример #44
0
 def test_files_that_match_with_multiple_matches(self):
     self.fileSystem.create_file(Path.fromText("dir/foo/test.txt"), "x")
     self.fileSystem.create_file(Path.fromText("dir/foo/subtest.txt"), "x")
     directory = self.fileSystem.open(Path.fromText("dir/foo"))
     results = directory.files_that_matches("test")
     self.assertEqual(len(results), 1)
Пример #45
0
 def setUp(self):
     self.fileSystem = InMemoryFileSystem()
     self.current_directory = Path.fromText("/temp")
Пример #46
0
 def test_remove_trailing_spaces(self):
     path = Path.fromText("/text/ blabla /test.txt")
     self.assertEqual(path, Path.fromText("/text/blabla/test.txt"))
Пример #47
0
 def test_create_file_rejects_content_that_is_not_text(self):
     path = Path.fromText("dir/test.txt")
     with self.assertRaises(ValueError):
         self.fileSystem.create_file(path, [1, 2, 3, 4])
Пример #48
0
 def setUp(self):
     self.fileSystem = InMemoryFileSystem()
     self.current_directory = Path.fromText("/temp")
Пример #49
0
 def testContainingDirectoryIsAvailable(self):
     path = Path.fromText("my\\dir\\test.txt")
     self.fileSystem.create_file(path, "data")
     file = self.fileSystem.open(path)
     self.assertEqual(file.container().path(), ROOT / "my" / "dir")
Пример #50
0
 def testPathWithNewlines(self):
     path = Path.fromText("/Root/Foo\nBar\nBaz/home")
     self.verify_parts(path, ["", "Root", "FooBarBaz", "home"])
Пример #51
0
 def testBasenameIsAvailable(self):
     path = Path.fromText("my/dir/test.txt")
     self.fileSystem.create_file(path, "whatever")
     file = self.fileSystem.open(path)
     self.assertEqual(file.basename(), "test")
Пример #52
0
 def test_create_file_rejects_content_that_is_not_text(self):
     path = Path.fromText("dir/test.txt")
     with self.assertRaises(ValueError):
         self.fileSystem.create_file(path, [1, 2, 3, 4])
Пример #53
0
 def test_empty_container(self):
     path = Path.fromText("foo.tex")
     self.assertEquals(CURRENT_DIRECTORY, path.container())
Пример #54
0
 def testThatMissingFileDoNotExist(self):
     path = Path.fromText("file\\that\\do\\not\\exist.txt")
     file = self.fileSystem.open(path)
     self.assertFalse(file.exists())
Пример #55
0
    def test_without_extension(self):
        path = Path.fromText("/home/test/foo.txt")

        self.assertEquals(path.without_extension(), Path.fromText("/home/test/foo"))
Пример #56
0
 def testContainingDirectoryIsAvailable(self):
     path = Path.fromText("my\\dir\\test.txt")
     self.fileSystem.create_file(path, "data")
     file = self.fileSystem.open(path)
     self.assertEqual(file.container().path(), ROOT / "my" / "dir")
Пример #57
0
 def root_tex_file(self):
     return Path.fromText(self._root_tex_file)
Пример #58
0
 def testFullNameIsAvailable(self):
     path = Path.fromText("/my/dir/test.txt")
     self.fileSystem.create_file(path, "data")
     file = self.fileSystem.open(path)
     self.assertEqual(file.fullname(), "test.txt")
Пример #59
0
 def _verify_generated_files(self, test_case):
     location = self._file_system.open(Path.fromText("output"))
     actual = LatexProject.extract_from_directory(location)
     test_case._expected.assert_is_equivalent_to(actual)
Пример #60
0
 def test_is_absolute_with_relative(self):
     path = Path.fromText("franck/test.tex")
     self.assertFalse(path.is_absolute())