Example #1
0
    def test_size_includes_files_that_would_be_copied(self, subject):
        with open("legit.txt", "w") as f:
            f.write("12345")

        source = subject()

        assert source.size == 5
Example #2
0
    def test_size_excludes_files_that_would_not_be_copied(self, subject):
        with open("illegit.db", "w") as f:
            f.write("12345")

        source = subject()

        assert source.size == 0
Example #3
0
    def test_size_excludes_bad_files_when_in_subdirectories(self, subject):
        os.mkdir("legit_dir")
        with open("legit_dir/illegit.db", "w") as f:
            f.write("12345")

        source = subject()

        assert source.size == 0
Example #4
0
    def test_size_excludes_directories_that_would_not_be_copied(self, subject):
        os.mkdir("snapshots")
        with open("snapshots/legit.txt", "w") as f:
            f.write("12345")

        source = subject()

        assert source.size == 0
Example #5
0
    def test_lists_files_valid_for_copying(self, subject):
        legit_file = "./some/subdir/John Doe's file.txt"
        os.makedirs(os.path.dirname(legit_file))
        with open(legit_file, "w") as f:
            f.write("12345")

        source = subject()

        assert legit_file in source.files
Example #6
0
    def test_copy_to_copies_nonascii_filenames2(self, subject):
        legit_file = "".join(["å", " ", "f", "i", "l", "e"])
        with open(legit_file, "w") as f:
            f.write("12345")
        destination = tempfile.mkdtemp()
        source = subject()

        source.selective_copy_to(destination)

        assert os.path.isfile(os.path.join(destination, legit_file))
Example #7
0
    def test_normalizes_unicode_for_merging_git_inclusions(self, subject, git):
        legit_file = "".join(
            [".", "/", "a", "̊", " ", "f", "i", "l", "e", ".", "t", "x", "t"])
        with open(legit_file, "w") as f:
            f.write("12345")
        git.init()

        source = subject()

        assert source.files == {legit_file}
Example #8
0
    def test_apply_to_resolves_nonascii_filenames_with_git2(self, subject):
        legit_file = "".join(["å", " ", "f", "i", "l", "e"])
        with open(legit_file, "w") as f:
            f.write("12345")
        destination = tempfile.mkdtemp()
        source = subject()

        source.apply_to(destination)

        assert (Path(destination) / legit_file).is_file()
Example #9
0
    def test_recipe_for_copy_accepts_explicit_root(self, subject):
        legit_file = "./some/subdir/legit.txt"
        os.makedirs(os.path.dirname(legit_file))
        with open(legit_file, "w") as f:
            f.write("12345")
        destination = tempfile.mkdtemp()
        source = subject(os.getcwd())

        source.apply_to(destination)

        assert (Path(destination) / legit_file).is_file()
Example #10
0
    def test_copy_to_copies_with_explicit_root(self, subject):
        legit_file = "./some/subdir/legit.txt"
        os.makedirs(os.path.dirname(legit_file))
        with open(legit_file, "w") as f:
            f.write("12345")
        destination = tempfile.mkdtemp()
        source = subject(os.getcwd())

        source.selective_copy_to(destination)

        assert os.path.isfile(os.path.join(destination, "some/subdir/legit.txt"))
Example #11
0
    def test_copy_to_copies_to_same_subdirectories(self, subject):
        legit_file = "./some/subdir/John Doe's file.txt"
        os.makedirs(os.path.dirname(legit_file))
        with open(legit_file, "w") as f:
            f.write("12345")
        destination = tempfile.mkdtemp()
        source = subject()

        source.selective_copy_to(destination)

        assert os.path.isfile(
            os.path.join(destination, "some/subdir/John Doe's file.txt"))
Example #12
0
    def test_recipe_for_copy_defaults_to_cwd(self, subject):
        legit_file = "./some/subdir/John Doe's file.txt"
        os.makedirs(os.path.dirname(legit_file))
        with open(legit_file, "w") as f:
            f.write("12345")
        destination = tempfile.mkdtemp()
        source = subject()

        source.apply_to(destination)

        assert (Path(destination) /
                "some/subdir/John Doe's file.txt").is_file()
Example #13
0
    def test_excludes_otherwise_valid_files_if_in_gitignore_complex(self, subject, git):
        legit_file = "./some/subdir/legit.txt"
        os.makedirs(os.path.dirname(legit_file))
        with open(legit_file, "w") as f:
            f.write("12345")
        with open(".gitignore", "w") as f:
            f.write("**/subdir/*")
        git.init()

        source = subject()

        assert source.files == {"./.gitignore"}