Esempio n. 1
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")
Esempio n. 2
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"))
Esempio n. 3
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")
Esempio n. 4
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
Esempio n. 5
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()) == str(path)
         or str(any_file.path()).startswith(str(path) + ".")
     ]
Esempio n. 6
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
Esempio n. 7
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
Esempio n. 8
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
Esempio n. 9
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")
Esempio n. 10
0
 def setUp(self):
     self.fileSystem = InMemoryFileSystem()
     self.current_directory = Path.fromText("/temp")
Esempio n. 11
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])
Esempio n. 12
0
 def test_remove_trailing_spaces(self):
     path = Path.fromText("/text/ blabla /test.txt")
     self.assertEqual(path, Path.fromText("/text/blabla/test.txt"))
Esempio n. 13
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)
Esempio n. 14
0
    def test_without_extension(self):
        path = Path.fromText("/home/test/foo.txt")

        self.assertEquals(path.without_extension(), Path.fromText("/home/test/foo"))
Esempio n. 15
0
 def setUp(self):
     self.fileSystem = InMemoryFileSystem()
     self.current_directory = Path.fromText("/temp")
Esempio n. 16
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"))
Esempio n. 17
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!")
Esempio n. 18
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"))
Esempio n. 19
0
    def test_as_absolute_with_root(self):
        path = ROOT

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

        self.assertEqual(absolute_path, ROOT)
Esempio n. 20
0
 def test_is_absolute_with_relative(self):
     path = Path.fromText("franck/test.tex")
     self.assertFalse(path.is_absolute())
Esempio n. 21
0
 def test_is_absolute_on_windows_paths(self):
     path = Path.fromText("C:\\Users\\franckc\\file.txt")
     self.assertTrue(path.is_absolute())
Esempio n. 22
0
 def test_is_absolute_on_unix_paths(self):
     path = Path.fromText("/home/franck/test.tex")
     self.assertTrue(path.is_absolute())
Esempio n. 23
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")
Esempio n. 24
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"])
Esempio n. 25
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() ])
Esempio n. 26
0
 def testPathWithNewlines(self):
     path = Path.fromText("/Root/Foo\nBar\nBaz/home")
     self.verify_parts(path, ["", "Root", "FooBarBaz", "home"])
Esempio n. 27
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"))
Esempio n. 28
0
 def test_remove_trailing_spaces(self):
     path = Path.fromText("/text/ blabla /test.txt")
     self.assertEqual(path, Path.fromText("/text/blabla/test.txt"))
Esempio n. 29
0
 def testThatMissingFileDoNotExist(self):
     path = Path.fromText("file\\that\\do\\not\\exist.txt")
     file = self.fileSystem.open(path)
     self.assertFalse(file.exists())
Esempio n. 30
0
 def test_is_absolute_on_unix_paths(self):
     path = Path.fromText("/home/franck/test.tex")
     self.assertTrue(path.is_absolute())
Esempio n. 31
0
 def _extract_project(self):
     root = self._file_system.open(Path.fromText(self._directory))
     return LatexProject.extract_from_directory(root)
Esempio n. 32
0
 def test_is_absolute_on_windows_paths(self):
     path = Path.fromText("C:\\Users\\franckc\\file.txt")
     self.assertTrue(path.is_absolute())
Esempio n. 33
0
 def testPathBuilding(self):
     path = Path.fromText("\\Users\\franckc\\file.txt")
     
     self.assertEqual(path, ROOT / "Users" / "franckc" / "file.txt")
Esempio n. 34
0
 def test_is_absolute_with_relative(self):
     path = Path.fromText("franck/test.tex")
     self.assertFalse(path.is_absolute())
Esempio n. 35
0
 def test_empty_container(self):
     path = Path.fromText("foo.tex")
     self.assertEquals(CURRENT_DIRECTORY, path.container())
Esempio n. 36
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"))
Esempio n. 37
0
 def testThatMissingFileDoNotExist(self):
     path = Path.fromText("file\\that\\do\\not\\exist.txt")
     file = self.fileSystem.open(path)
     self.assertFalse(file.exists())
Esempio n. 38
0
    def test_as_absolute_with_root(self):
        path = ROOT

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

        self.assertEqual(absolute_path, ROOT)
Esempio n. 39
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")
Esempio n. 40
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"))
Esempio n. 41
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)
Esempio n. 42
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")
Esempio n. 43
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)
Esempio n. 44
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)
Esempio n. 45
0
 def __init__(self):
     super().__init__()
     self.current_directory = Path.fromText(os.getcwd())
Esempio n. 46
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"])
Esempio n. 47
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)
Esempio n. 48
0
 def output_directory(self):
     return Path.fromText(self._output)
Esempio n. 49
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])
Esempio n. 50
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!")
Esempio n. 51
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")
Esempio n. 52
0
 def testPathWithNewlines(self):
     path = Path.fromText("/Root/Foo\nBar\nBaz/home")
     self.verify_parts(path, ["", "Root", "FooBarBaz", "home"])
Esempio n. 53
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")
Esempio n. 54
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)
Esempio n. 55
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)
Esempio n. 56
0
 def _do_test_setup(self, project):
     project.setup(self._file_system, Path.fromText(self._directory))
     self._verify(project)
Esempio n. 57
0
 def root_tex_file(self):
     return Path.fromText(self._root_tex_file)
Esempio n. 58
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())
Esempio n. 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)
Esempio n. 60
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)