<commit_before>import os
import stat

from tests.integrations.base import BaseTest


class TestWriteCurrentView(BaseTest):
    def setup(self):
        super(TestWriteCurrentView, self).setup()
        self.current = "%s/current/" % self.mount_path

    def test_write_a_file(self):
        content = "Just a small file"
        filename = "%s/new_file" % self.current

        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
        date = self.repo.get_commit_dates()
        commits = self.repo.get_commits_by_date(date[0])
        assert len(commits) == 2

        # check if the commit contains the right blob
        last_commit = commits[0]
        commit = self.repo.revparse_single(last_commit.split('-')[1])
        assert self.repo.get_blob_data(commit.tree, "new_file") == content

    def test_create_a_directory(self):
        directory = "%s/new_directory" % self.current

        os.makedirs(directory)

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

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

        # check if a commit was made
        date = self.repo.get_commit_dates()
        commits = self.repo.get_commits_by_date(date[0])
        assert len(commits) == 3

    def test_chmod(self):
        filename = "%s/testing" % self.current
        os.chmod(filename, 0766)

        # check if the right mode was set
        stats = os.stat(filename)
        assert stats.st_mode == 0100766

        # check if a commit was made
        date = self.repo.get_commit_dates()
        commits = self.repo.get_commits_by_date(date[0])
        assert len(commits) == 4<commit_msg>Test rename<commit_after>import os

from tests.integrations.base import BaseTest


class TestWriteCurrentView(BaseTest):
    def setup(self):
        super(TestWriteCurrentView, self).setup()
        self.current = "%s/current/" % self.mount_path

    def test_write_a_file(self):
        content = "Just a small file"
        filename = "%s/new_file" % self.current

        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
        date = self.repo.get_commit_dates()
        commits = self.repo.get_commits_by_date(date[0])
        assert len(commits) == 2

        # check if the commit contains the right blob
        last_commit = commits[0]
        commit = self.repo.revparse_single(last_commit.split('-')[1])
        assert self.repo.get_blob_data(commit.tree, "new_file") == content

    def test_create_a_directory(self):
        directory = "%s/new_directory" % self.current

        os.makedirs(directory)

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

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

        # check if a commit was made
        date = self.repo.get_commit_dates()
        commits = self.repo.get_commits_by_date(date[0])
        assert len(commits) == 3

    def test_chmod(self):
        filename = "%s/testing" % self.current
        os.chmod(filename, 0766)

        # check if the right mode was set
        stats = os.stat(filename)
        assert stats.st_mode == 0100766

        # check if a commit was made
        date = self.repo.get_commit_dates()
        commits = self.repo.get_commits_by_date(date[0])
        assert len(commits) == 4

    def test_rename(self):
        old_filename = "%s/testing" % self.current
        new_filename = "%s/new_testing" % self.current

        os.rename(old_filename, new_filename)

        # check for new file
        assert os.path.exists(new_filename)

        # check if a commit was made
        date = self.repo.get_commit_dates()
        commits = self.repo.get_commits_by_date(date[0])
        assert len(commits) == 5
{'fraction_non_alphanumeric': 0.10075394105551748, 'fraction_numerical': 0.009138679460817912, 'mean_word_length': 2.412314886983632, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1775409', 'n_tokens_mistral': 1369, 'n_tokens_neox': 1312, 'n_words': 321}