Beispiel #1
0
    def test_edit_file(self, gitfs_log):
        content = "first part"
        continuation = "second part"
        filename = "{}/some_file".format(self.current_path)

        with gitfs_log("SyncWorker: Set push_successful"):
            with open(filename, "w") as f:
                f.write(content)

        with pull(self.sh):
            with open(filename) as f:
                assert f.read() == content

            self.assert_new_commit()

        with pull(self.sh):
            self.assert_commit_message("Update /some_file")

            with gitfs_log("SyncWorker: Set push_successful"):
                with open(filename, "w") as f:
                    f.write(continuation)

        with pull(self.sh):
            with open(filename) as f:
                assert f.read() == continuation

            self.assert_new_commit()

        with pull(self.sh):
            self.assert_commit_message("Update /some_file")
Beispiel #2
0
    def test_delete_file(self):
        filename = "%s/deletable_file" % self.current_path

        with open(filename, "w") as f:
            f.write("some content")

        time.sleep(5)

        with pull(self.sh):
            self.assert_new_commit()

        time.sleep(1)

        with pull(self.sh):
            self.assert_commit_message("Update /deletable_file")

        os.remove(filename)

        time.sleep(10)

        with pull(self.sh):
            assert not os.path.exists(filename)

        time.sleep(1)

        with pull(self.sh):
            self.assert_commit_message("Deleted /deletable_file")
Beispiel #3
0
    def test_delete_file(self):
        filename = "%s/deletable_file" % self.current_path

        with open(filename, "w") as f:
            f.write("some content")

        time.sleep(5)

        with pull(self.sh):
            self.assert_new_commit()

        time.sleep(1)

        with pull(self.sh):
            self.assert_commit_message("Update /deletable_file")

        os.remove(filename)

        time.sleep(10)

        with pull(self.sh):
            assert not os.path.exists(filename)

        time.sleep(1)

        with pull(self.sh):
            self.assert_commit_message("Deleted /deletable_file")
Beispiel #4
0
    def test_edit_file(self, gitfs_log):
        content = "first part"
        continuation = "second part"
        filename = "{}/some_file".format(self.current_path)

        with gitfs_log("SyncWorker: Set push_successful"):
            with open(filename, "w") as f:
                f.write(content)

        with pull(self.sh):
            with open(filename) as f:
                assert f.read() == content

            self.assert_new_commit()

        with pull(self.sh):
            self.assert_commit_message("Update /some_file")

            with gitfs_log("SyncWorker: Set push_successful"):
                with open(filename, "w") as f:
                    f.write(continuation)

        with pull(self.sh):
            with open(filename) as f:
                assert f.read() == continuation

            self.assert_new_commit()

        with pull(self.sh):
            self.assert_commit_message("Update /some_file")
Beispiel #5
0
    def test_delete_directory_with_space_within_name(self):
        directory = "%s/new directory" % self.current_path

        os.makedirs(directory)

        time.sleep(5)
        with pull(self.sh):
            # check if directory exists or not
            directory_path = "%s/new directory" % self.repo_path
            assert os.path.exists(directory_path)

            # check for .keep file
            keep_path = "%s/new directory/.keep" % self.repo_path
            assert os.path.exists(keep_path)

            self.assert_new_commit()
            self.assert_commit_message("Create the /new directory directory")

        shutil.rmtree("%s/new directory/" % self.current_path)
        time.sleep(5)

        with pull(self.sh):
            self.assert_new_commit()

        assert os.path.exists(directory) is False
Beispiel #6
0
    def test_delete_a_directory(self):
        path = "%s/a_directory/another_dir/" % self.current_path
        os.makedirs(path)

        time.sleep(5)
        with pull(self.sh):
            self.assert_new_commit()

        shutil.rmtree("%s/a_directory/" % self.current_path)
        time.sleep(5)

        with pull(self.sh):
            self.assert_commit_message("Update 2 items")
            self.assert_new_commit()

        assert os.path.exists(path) is False
Beispiel #7
0
    def test_create_embedded_directory_big_depth(self):
        path = ""
        for letter in string.letters:
            path = os.path.join(path, letter)

        os.makedirs(os.path.join(self.current_path, path))

        time.sleep(5)

        with pull(self.sh):
            # check if directory exists or not
            directory_path = os.path.join(self.repo_path, path)
            assert os.path.exists(directory_path)

            # build the paths for the keep files
            keep_files = []
            path = self.repo_path
            for letter in string.letters:
                path = os.path.join(path, letter)
                path_with_keep = os.path.join(path, '.keep')
                keep_files.append(path_with_keep)

            # check the existence of the .keep files
            for keep_file in keep_files:
                assert os.path.exists(keep_file)
Beispiel #8
0
    def test_create_directory_inside_an_already_existing_directory(
            self, gitfs_log):
        directory = "{}/directory/new-embedded-directory".format(
            self.current_path)

        with gitfs_log("SyncWorker: Set push_successful"):
            os.makedirs(directory)

        with pull(self.sh):
            # check if directory exists or not
            directory_path = "{}/directory/new-embedded-directory".format(
                self.repo_path)
            assert os.path.exists(directory_path)

            # check the existence of the .keep files
            keep_files = [
                "{}/directory/.keep".format(self.repo_path),
                "{}/directory/new-embedded-directory/.keep".format(
                    self.repo_path)
            ]
            for keep_file in keep_files:
                assert os.path.exists(keep_file)

            self.assert_new_commit()
            commit_msg = "Create the /directory/new-embedded-directory directory"
            self.assert_commit_message(commit_msg)
Beispiel #9
0
    def test_delete_a_directory(self):
        path = "%s/a_directory/another_dir/" % self.current_path
        os.makedirs(path)

        time.sleep(5)
        with pull(self.sh):
            self.assert_new_commit()

        shutil.rmtree("%s/a_directory/" % self.current_path)
        time.sleep(5)

        with pull(self.sh):
            self.assert_commit_message("Update 2 items")
            self.assert_new_commit()

        assert os.path.exists(path) is False
Beispiel #10
0
    def test_delete_a_directory(self, gitfs_log):
        path = "{}/a_directory/another_dir/".format(self.current_path)
        with gitfs_log("SyncWorker: Set push_successful"):
            os.makedirs(path)

        with pull(self.sh):
            self.assert_new_commit()

        with gitfs_log("SyncWorker: Set push_successful"):
            shutil.rmtree("{}/a_directory/".format(self.current_path))

        with pull(self.sh):
            self.assert_commit_message("Update 2 items. Removed 2 items.")
            self.assert_new_commit()

        assert os.path.exists(path) is False
Beispiel #11
0
    def test_delete_a_directory(self, gitfs_log):
        path = "{}/a_directory/another_dir/".format(self.current_path)
        with gitfs_log("SyncWorker: Set push_successful"):
            os.makedirs(path)

        with pull(self.sh):
            self.assert_new_commit()

        with gitfs_log("SyncWorker: Set push_successful"):
            shutil.rmtree("{}/a_directory/".format(self.current_path))

        with pull(self.sh):
            self.assert_commit_message("Update 2 items. Removed 2 items.")
            self.assert_new_commit()

        assert os.path.exists(path) is False
Beispiel #12
0
    def test_create_embedded_directory_big_depth(self):
        path = ""
        for letter in string.letters:
            path = os.path.join(path, letter)

        os.makedirs(os.path.join(self.current_path, path))

        time.sleep(5)

        with pull(self.sh):
            # check if directory exists or not
            directory_path = os.path.join(self.repo_path, path)
            assert os.path.exists(directory_path)

            # build the paths for the keep files
            keep_files = []
            path = self.repo_path
            for letter in string.letters:
                path = os.path.join(path, letter)
                path_with_keep = os.path.join(path, '.keep')
                keep_files.append(path_with_keep)

            # check the existence of the .keep files
            for keep_file in keep_files:
                assert os.path.exists(keep_file)
Beispiel #13
0
    def test_rename_directory(self, gitfs_log):
        old_dir = "{}/a_directory/".format(self.current_path)
        new_dir = "{}/some_directory/".format(self.current_path)
        with gitfs_log("SyncWorker: Set push_successful"):
            os.makedirs(old_dir)

        with pull(self.sh):
            self.assert_new_commit()

        with gitfs_log("SyncWorker: Set push_successful"):
            os.rename(old_dir, new_dir)

        with pull(self.sh):
            self.assert_new_commit()

        assert os.path.isdir(new_dir) is not False
        assert os.path.exists(old_dir) is False
Beispiel #14
0
    def test_delete_file(self, gitfs_log):
        filename = "{}/deletable_file".format(self.current_path)

        with gitfs_log("SyncWorker: Set push_successful"):
            with open(filename, "w") as f:
                f.write("some content")

        with pull(self.sh):
            self.assert_new_commit()
            self.assert_commit_message("Update /deletable_file")

        with gitfs_log("SyncWorker: Set push_successful"):
            os.remove(filename)

        with pull(self.sh):
            assert not os.path.exists(filename)
            self.assert_commit_message("Deleted /deletable_file")
Beispiel #15
0
    def test_create(self, gitfs_log):
        filename = "{}/new_empty_file".format(self.current_path)
        with gitfs_log("SyncWorker: Set push_successful"):
            open(filename, "a").close()

        with pull(self.sh):
            self.assert_new_commit()
            self.assert_commit_message("Created /new_empty_file")
Beispiel #16
0
    def test_delete_file(self, gitfs_log):
        filename = "{}/deletable_file".format(self.current_path)

        with gitfs_log("SyncWorker: Set push_successful"):
            with open(filename, "w") as f:
                f.write("some content")

        with pull(self.sh):
            self.assert_new_commit()
            self.assert_commit_message("Update /deletable_file")

        with gitfs_log("SyncWorker: Set push_successful"):
            os.remove(filename)

        with pull(self.sh):
            assert not os.path.exists(filename)
            self.assert_commit_message("Deleted /deletable_file")
Beispiel #17
0
    def test_create(self, gitfs_log):
        filename = "{}/new_empty_file".format(self.current_path)
        with gitfs_log("SyncWorker: Set push_successful"):
            open(filename, "a").close()

        with pull(self.sh):
            self.assert_new_commit()
            self.assert_commit_message("Created /new_empty_file")
Beispiel #18
0
    def test_rename_directory(self, gitfs_log):
        old_dir = "{}/a_directory/".format(self.current_path)
        new_dir = "{}/some_directory/".format(self.current_path)
        with gitfs_log("SyncWorker: Set push_successful"):
            os.makedirs(old_dir)

        with pull(self.sh):
            self.assert_new_commit()

        with gitfs_log("SyncWorker: Set push_successful"):
            os.rename(old_dir, new_dir)

        with pull(self.sh):
            self.assert_new_commit()

        assert os.path.isdir(new_dir) is not False
        assert os.path.exists(old_dir) is False
Beispiel #19
0
    def test_rename_directory(self):
        old_dir = "%s/a_directory/" % self.current_path
        new_dir = "%s/some_directory/" % self.current_path
        os.makedirs(old_dir)

        time.sleep(5)
        with pull(self.sh):
            self.assert_new_commit()

        os.rename(old_dir, new_dir)

        time.sleep(5)
        with pull(self.sh):
            self.assert_new_commit()

        assert os.path.isdir(new_dir) is not False
        assert os.path.exists(old_dir) is False
Beispiel #20
0
    def test_rename_directory(self):
        old_dir = "%s/a_directory/" % self.current_path
        new_dir = "%s/some_directory/" % self.current_path
        os.makedirs(old_dir)

        time.sleep(5)
        with pull(self.sh):
            self.assert_new_commit()

        os.rename(old_dir, new_dir)

        time.sleep(5)
        with pull(self.sh):
            self.assert_new_commit()

        assert os.path.isdir(new_dir) is not False
        assert os.path.exists(old_dir) is False
Beispiel #21
0
    def test_create(self):
        filename = "%s/new_empty_file" % self.current_path
        open(filename, "a").close()

        time.sleep(5)

        with pull(self.sh):
            self.assert_new_commit()
            self.assert_commit_message("Created /new_empty_file")
Beispiel #22
0
    def test_create(self):
        filename = "%s/new_empty_file" % self.current_path
        open(filename, "a").close()

        time.sleep(5)

        with pull(self.sh):
            self.assert_new_commit()
            self.assert_commit_message("Created /new_empty_file")
Beispiel #23
0
    def test_create_multiple_files(self, gitfs_log):
        content = "Just a small file"
        no_of_files = 10
        filename = "{}/new_file".format(self.current_path)

        with gitfs_log("SyncWorker: Set push_successful"):
            for i in range(no_of_files):
                with open(filename + str(i), "w") as f:
                    f.write(content)

        with pull(self.sh):
            for i in range(no_of_files):
                with open(filename + str(i)) as f:
                    assert f.read() == content

            self.assert_new_commit()

        with pull(self.sh):
            self.assert_commit_message("Update {} items. Added {} items.".format(no_of_files, no_of_files))
Beispiel #24
0
    def test_create_multiple_files(self, gitfs_log):
        content = "Just a small file"
        no_of_files = 10
        filename = "{}/new_file".format(self.current_path)

        with gitfs_log("SyncWorker: Set push_successful"):
            for i in range(no_of_files):
                with open(filename + str(i), "w") as f:
                    f.write(content)

        with pull(self.sh):
            for i in range(no_of_files):
                with open(filename + str(i)) as f:
                    assert f.read() == content

            self.assert_new_commit()

        with pull(self.sh):
            self.assert_commit_message("Update {} items".format(no_of_files))
Beispiel #25
0
    def test_fsync(self, gitfs_log):
        filename = "{}/me".format(self.current_path)
        content = "test fsync"

        with gitfs_log("SyncWorker: Set push_successful"):
            with open(filename, "w") as f:
                f.write(content)
                os.fsync(f.fileno())

        with pull(self.sh):
            self.assert_new_commit()
            self.assert_commit_message("Update 1 items. Added 2 items.")
Beispiel #26
0
    def test_write_a_file(self):
        content = "Just a small file"
        filename = "%s/new_file" % self.current_path

        with open(filename, "w") as f:
            f.write(content)

        time.sleep(5)

        # check if the write was done correctly
        with open(filename) as f:
            assert f.read() == content

        # check if a commit was made
        with pull(self.sh):
            self.assert_new_commit()

        time.sleep(1)

        with pull(self.sh):
            self.assert_commit_message("Update /new_file")
Beispiel #27
0
    def test_chmod_valid_mode(self, gitfs_log):
        filename = "{}/testing".format(self.current_path)
        with gitfs_log("SyncWorker: Set push_successful"):
            os.chmod(filename, 0o755)

        with pull(self.sh):
            # check if the right mode was set
            stats = os.stat(filename)
            assert stats.st_mode == 0o100755

            self.assert_new_commit()
            self.assert_commit_message("Chmod to 0755 on /testing")
Beispiel #28
0
    def test_chmod_valid_mode(self, gitfs_log):
        filename = "%s/testing" % self.current_path
        with gitfs_log("SyncWorker: Set push_successful"):
            os.chmod(filename, 0755)

        with pull(self.sh):
            # check if the right mode was set
            stats = os.stat(filename)
            assert stats.st_mode == 0100755

            self.assert_new_commit()
            self.assert_commit_message("Chmod to 0755 on /testing")
Beispiel #29
0
    def test_write_a_file(self):
        content = "Just a small file"
        filename = "%s/new_file" % self.current_path

        with open(filename, "w") as f:
            f.write(content)

        time.sleep(5)

        # check if the write was done correctly
        with open(filename) as f:
            assert f.read() == content

        # check if a commit was made
        with pull(self.sh):
            self.assert_new_commit()

        time.sleep(1)

        with pull(self.sh):
            self.assert_commit_message("Update /new_file")
Beispiel #30
0
    def test_fsync(self, gitfs_log):
        filename = "{}/me".format(self.current_path)
        content = "test fsync"

        with gitfs_log("SyncWorker: Set push_successful"):
            with open(filename, "w") as f:
                f.write(content)
                os.fsync(f.fileno())

        with pull(self.sh):
            self.assert_new_commit()
            self.assert_commit_message("Update 1 items. Added 2 items.")
Beispiel #31
0
    def test_create_multiple_files(self):
        content = "Just a small file"
        no_of_files = 10
        filename = "%s/new_file" % self.current_path

        for i in range(no_of_files):
            with open(filename + str(i), "w") as f:
                f.write(content)

        time.sleep(5)

        with pull(self.sh):
            for i in range(no_of_files):
                with open(filename + str(i)) as f:
                    assert f.read() == content

            self.assert_new_commit()

        time.sleep(1)

        with pull(self.sh):
            self.assert_commit_message("Update %d items" % no_of_files)
Beispiel #32
0
    def test_fsync(self):
        filename = "%s/me" % self.current_path
        content = "test fsync"

        with open(filename, "w") as f:
            f.write(content)
            os.fsync(f.fileno())

        time.sleep(5)

        with pull(self.sh):
            self.assert_new_commit()
            self.assert_commit_message("Update 1 items")
Beispiel #33
0
    def test_fsync(self):
        filename = "%s/me" % self.current_path
        content = "test fsync"

        with open(filename, "w") as f:
            f.write(content)
            os.fsync(f.fileno())

        time.sleep(5)

        with pull(self.sh):
            self.assert_new_commit()
            self.assert_commit_message("Update 1 items")
Beispiel #34
0
    def test_chmod_valid_mode(self):
        filename = "%s/testing" % self.current_path
        os.chmod(filename, 0755)

        time.sleep(5)

        with pull(self.sh):
            # check if the right mode was set
            stats = os.stat(filename)
            assert stats.st_mode == 0100755

            self.assert_new_commit()
            self.assert_commit_message("Chmod to 0755 on /testing")
Beispiel #35
0
    def test_rename(self, gitfs_log):
        old_filename = "{}/testing".format(self.current_path)
        new_filename = "{}/new_testing".format(self.current_path)

        with gitfs_log("SyncWorker: Set push_successful"):
            os.rename(old_filename, new_filename)

        with pull(self.sh):
            # check for new file
            assert os.path.exists(new_filename)

            self.assert_new_commit()
            self.assert_commit_message("Rename /testing to /new_testing")
Beispiel #36
0
    def test_create_multiple_files(self):
        content = "Just a small file"
        no_of_files = 10
        filename = "%s/new_file" % self.current_path

        for i in range(no_of_files):
            with open(filename + str(i), "w") as f:
                f.write(content)

        time.sleep(5)

        with pull(self.sh):
            for i in range(no_of_files):
                with open(filename + str(i)) as f:
                    assert f.read() == content

            self.assert_new_commit()

        time.sleep(1)

        with pull(self.sh):
            self.assert_commit_message("Update %d items" % no_of_files)
Beispiel #37
0
    def test_rename(self, gitfs_log):
        old_filename = "{}/testing".format(self.current_path)
        new_filename = "{}/new_testing".format(self.current_path)

        with gitfs_log("SyncWorker: Set push_successful"):
            os.rename(old_filename, new_filename)

        with pull(self.sh):
            # check for new file
            assert os.path.exists(new_filename)

            self.assert_new_commit()
            self.assert_commit_message("Rename /testing to /new_testing")
Beispiel #38
0
    def test_chmod_valid_mode(self):
        filename = "%s/testing" % self.current_path
        os.chmod(filename, 0755)

        time.sleep(5)

        with pull(self.sh):
            # check if the right mode was set
            stats = os.stat(filename)
            assert stats.st_mode == 0100755

            self.assert_new_commit()
            self.assert_commit_message("Chmod to 0755 on /testing")
Beispiel #39
0
    def test_symbolic_link(self, gitfs_log):
        target = "me"
        name = "{}/links".format(self.current_path)
        with gitfs_log("SyncWorker: Set push_successful"):
            os.symlink(target, name)

        with pull(self.sh):
            # check if link exists
            assert os.path.exists(name)

            self.assert_new_commit()
            self.assert_commit_message("Create symlink to {} for "
                                       "/links".format(target))
Beispiel #40
0
    def test_symbolic_link(self, gitfs_log):
        target = "me"
        name = "{}/links".format(self.current_path)
        with gitfs_log("SyncWorker: Set push_successful"):
            os.symlink(target, name)

        with pull(self.sh):
            # check if link exists
            assert os.path.exists(name)

            self.assert_new_commit()
            self.assert_commit_message("Create symlink to {} for "
                                       "/links".format(target))
Beispiel #41
0
    def test_rename(self):
        old_filename = "%s/testing" % self.current_path
        new_filename = "%s/new_testing" % self.current_path

        os.rename(old_filename, new_filename)

        time.sleep(5)

        with pull(self.sh):
            # check for new file
            assert os.path.exists(new_filename)

            self.assert_new_commit()
            self.assert_commit_message("Rename /testing to /new_testing")
Beispiel #42
0
    def test_rename(self):
        old_filename = "%s/testing" % self.current_path
        new_filename = "%s/new_testing" % self.current_path

        os.rename(old_filename, new_filename)

        time.sleep(5)

        with pull(self.sh):
            # check for new file
            assert os.path.exists(new_filename)

            self.assert_new_commit()
            self.assert_commit_message("Rename /testing to /new_testing")
Beispiel #43
0
    def test_symbolic_link(self):
        target = "me"
        name = "%s/links" % self.current_path
        os.symlink(target, name)

        time.sleep(5)

        with pull(self.sh):
            # check if link exists
            assert os.path.exists(name)

            self.assert_new_commit()
            self.assert_commit_message("Create symlink to %s for "
                                       "/links" % (target))
Beispiel #44
0
    def test_symbolic_link(self):
        target = "me"
        name = "%s/links" % self.current_path
        os.symlink(target, name)

        time.sleep(5)

        with pull(self.sh):
            # check if link exists
            assert os.path.exists(name)

            self.assert_new_commit()
            self.assert_commit_message("Create symlink to %s for "
                                       "/links" % (target))
Beispiel #45
0
    def test_link_a_file(self, gitfs_log):
        filename = "{}/link_file".format(self.current_path)
        link_name = "{}/new_link".format(self.current_path)

        with open(filename, "w") as f:
            f.write("some content")

        with gitfs_log("SyncWorker: Set push_successful"):
            os.link(filename, link_name)

        with pull(self.sh):
            self.assert_commit_message("Update 2 items. Added 2 items.")

        is_link = os.path.isfile(link_name)
        assert is_link is not False
Beispiel #46
0
    def test_edit_file(self):
        content = "first part"
        continuation = "second part"
        filename = "%s/some_file" % self.current_path

        with open(filename, "w") as f:
            f.write(content)

        time.sleep(5)

        with pull(self.sh):
            with open(filename) as f:
                assert f.read() == content

            self.assert_new_commit()

        time.sleep(1)

        with pull(self.sh):
            self.assert_commit_message("Update /some_file")

            with open(filename, "w") as f:
                f.write(continuation)

        time.sleep(5)

        with pull(self.sh):
            with open(filename) as f:
                assert f.read() == continuation

            self.assert_new_commit()

        time.sleep(1)

        with pull(self.sh):
            self.assert_commit_message("Update /some_file")
Beispiel #47
0
    def test_delete_directory_with_space_within_name(self, gitfs_log):
        directory = "{}/new directory".format(self.current_path)

        with gitfs_log("SyncWorker: Set push_successful"):
            os.makedirs(directory)
        with pull(self.sh):
            # check if directory exists or not
            directory_path = "{}/new directory".format(self.repo_path)
            assert os.path.exists(directory_path)

            # check for .keep file
            keep_path = "{}/new directory/.keep".format(self.repo_path)
            assert os.path.exists(keep_path)

            self.assert_new_commit()
            self.assert_commit_message("Create the /new directory directory")

        with gitfs_log("SyncWorker: Set push_successful"):
            shutil.rmtree("{}/new directory/".format(self.current_path))

        with pull(self.sh):
            self.assert_new_commit()

        assert os.path.exists(directory) is False
Beispiel #48
0
    def test_link_a_file(self, gitfs_log):
        filename = "{}/link_file".format(self.current_path)
        link_name = "{}/new_link".format(self.current_path)

        with open(filename, "w") as f:
            f.write("some content")

        with gitfs_log("SyncWorker: Set push_successful"):
            os.link(filename, link_name)

        with pull(self.sh):
            self.assert_commit_message("Update 2 items. Added 2 items.")

        is_link = os.path.isfile(link_name)
        assert is_link is not False
Beispiel #49
0
    def test_delete_directory_with_space_within_name(self, gitfs_log):
        directory = "{}/new directory".format(self.current_path)

        with gitfs_log("SyncWorker: Set push_successful"):
            os.makedirs(directory)
        with pull(self.sh):
            # check if directory exists or not
            directory_path = "{}/new directory".format(self.repo_path)
            assert os.path.exists(directory_path)

            # check for .keep file
            keep_path = "{}/new directory/.keep".format(self.repo_path)
            assert os.path.exists(keep_path)

            self.assert_new_commit()
            self.assert_commit_message("Create the /new directory directory")

        with gitfs_log("SyncWorker: Set push_successful"):
            shutil.rmtree("{}/new directory/".format(self.current_path))

        with pull(self.sh):
            self.assert_new_commit()

        assert os.path.exists(directory) is False
Beispiel #50
0
    def test_link_a_file(self):
        filename = "%s/link_file" % self.current_path
        link_name = "%s/new_link" % self.current_path

        with open(filename, "w") as f:
            f.write("some content")

        os.link(filename, link_name)

        time.sleep(5)
        with pull(self.sh):
            self.assert_commit_message("Update 2 items")

        is_link = os.path.isfile(link_name)
        assert is_link is not False
Beispiel #51
0
    def test_edit_file(self):
        content = "first part"
        continuation = "second part"
        filename = "%s/some_file" % self.current_path

        with open(filename, "w") as f:
            f.write(content)

        time.sleep(5)

        with pull(self.sh):
            with open(filename) as f:
                assert f.read() == content

            self.assert_new_commit()

        time.sleep(1)

        with pull(self.sh):
            self.assert_commit_message("Update /some_file")

            with open(filename, "w") as f:
                f.write(continuation)

        time.sleep(5)

        with pull(self.sh):
            with open(filename) as f:
                assert f.read() == continuation

            self.assert_new_commit()

        time.sleep(1)

        with pull(self.sh):
            self.assert_commit_message("Update /some_file")
Beispiel #52
0
    def test_link_a_file(self):
        filename = "%s/link_file" % self.current_path
        link_name = "%s/new_link" % self.current_path

        with open(filename, "w") as f:
            f.write("some content")

        os.link(filename, link_name)

        time.sleep(5)
        with pull(self.sh):
            self.assert_commit_message("Update 2 items")

        is_link = os.path.isfile(link_name)
        assert is_link is not False
Beispiel #53
0
    def test_write_a_file(self, gitfs_log):
        content = "Just a small file"
        filename = "{}/new_file".format(self.current_path)

        with gitfs_log("SyncWorker: Set push_successful"):
            with open(filename, "w") as f:
                f.write(content)

        # check if the write was done correctly
        with open(filename) as f:
            assert f.read() == content

        # check if a commit was made
        with pull(self.sh):
            self.assert_new_commit()
            self.assert_commit_message("Update /new_file")
Beispiel #54
0
    def test_create_a_directory(self, gitfs_log):
        directory = "{}/new_directory".format(self.current_path)
        with gitfs_log("SyncWorker: Set push_successful"):
            os.makedirs(directory)

        with pull(self.sh):
            # check if directory exists or not
            directory_path = "{}/new_directory".format(self.repo_path)
            assert os.path.exists(directory_path)

            # check for .keep file
            keep_path = "{}/new_directory/.keep".format(self.repo_path)
            assert os.path.exists(keep_path)

            self.assert_new_commit()
            self.assert_commit_message("Create the /new_directory directory")
Beispiel #55
0
    def test_create_a_directory(self, gitfs_log):
        directory = "{}/new_directory".format(self.current_path)
        with gitfs_log("SyncWorker: Set push_successful"):
            os.makedirs(directory)

        with pull(self.sh):
            # check if directory exists or not
            directory_path = "{}/new_directory".format(self.repo_path)
            assert os.path.exists(directory_path)

            # check for .keep file
            keep_path = "{}/new_directory/.keep".format(self.repo_path)
            assert os.path.exists(keep_path)

            self.assert_new_commit()
            self.assert_commit_message("Create the /new_directory directory")
Beispiel #56
0
    def test_write_a_file(self, gitfs_log):
        content = "Just a small file"
        filename = "{}/new_file".format(self.current_path)

        with gitfs_log("SyncWorker: Set push_successful"):
            with open(filename, "w") as f:
                f.write(content)

        # check if the write was done correctly
        with open(filename) as f:
            assert f.read() == content

        # check if a commit was made
        with pull(self.sh):
            self.assert_new_commit()
            self.assert_commit_message("Update /new_file")
Beispiel #57
0
    def test_create_a_directory(self):
        directory = "%s/new_directory" % self.current_path

        os.makedirs(directory)

        time.sleep(5)

        with pull(self.sh):
            # check if directory exists or not
            directory_path = "%s/new_directory" % self.repo_path
            assert os.path.exists(directory_path)

            # check for .keep file
            keep_path = "%s/new_directory/.keep" % self.repo_path
            assert os.path.exists(keep_path)

            self.assert_new_commit()
            self.assert_commit_message("Create the /new_directory directory")
Beispiel #58
0
    def test_create_a_directory(self):
        directory = "%s/new_directory" % self.current_path

        os.makedirs(directory)

        time.sleep(5)

        with pull(self.sh):
            # check if directory exists or not
            directory_path = "%s/new_directory" % self.repo_path
            assert os.path.exists(directory_path)

            # check for .keep file
            keep_path = "%s/new_directory/.keep" % self.repo_path
            assert os.path.exists(keep_path)

            self.assert_new_commit()
            self.assert_commit_message("Create the /new_directory directory")
Beispiel #59
0
    def test_create_embedded_directory(self, gitfs_log):
        directory = "{}/directory/embedded-directory".format(self.current_path)
        with gitfs_log("SyncWorker: Set push_successful"):
            os.makedirs(directory)

        with pull(self.sh):
            # check if directory exists or not
            directory_path = "{}/directory/embedded-directory".format(self.repo_path)
            assert os.path.exists(directory_path)

            # check the existence of the .keep files
            keep_files = [
                "{}/directory/.keep".format(self.repo_path),
                "{}/directory/embedded-directory/.keep".format(self.repo_path)
            ]
            for keep_file in keep_files:
                assert os.path.exists(keep_file)

            self.assert_new_commit()
            commit_msg = "Update 2 items. Added 2 items."
            self.assert_commit_message(commit_msg)