コード例 #1
0
    def test_can_get_tree(self):
        create_repository('test1')
        add_file_to_repo('test1', 'some/path/doge.txt', 'VERY COMMIT')
        add_file_to_repo('test1', 'some/path/to/add.txt', 'MUCH WOW')

        tree = yield self.gandalf.repository_tree('test1')

        expect(tree[0]).to_be_like({
            u'rawPath': u'README',
            u'path': u'README',
            u'filetype': u'blob',
            u'hash': u'e69de29bb2d1d6434b8b29ae775ad8c2e48c5391',
            u'permission': u'100644'
        })

        expect(tree[1]).to_be_like({
            u'rawPath': u'some/path/doge.txt',
            u'path': u'some/path/doge.txt',
            u'filetype': u'blob',
            u'hash': u'cb508ee85be1e116233ae7c18e2d9bcc9553d209',
            u'permission': u'100644'
        })

        expect(tree[2]).to_be_like({
            u'rawPath': u'some/path/to/add.txt',
            u'path': u'some/path/to/add.txt',
            u'filetype': u'blob',
            u'hash': u'c5545f629c01a7597c9d4f9d5b68626062551622',
            u'permission': u'100644'
        })
コード例 #2
0
    def test_can_get_repository_log_with_path_with_special_characters(self):
        repo = str(uuid.uuid4())
        create_repository(repo)
        add_file_to_repo(repo, 'some/path/doéã.txt', 'FOO BAR')
        add_file_to_repo(repo, 'some/path/doéã.txt', 'wow')

        result = self.gandalf.repository_log(repo, 'HEAD', 1, u'some/path/doéã.txt')

        expect(result).to_include('commits')
        expect(result).to_include('next')

        commits = result['commits']

        expect(commits[0]).to_include('subject')
        expect(commits[0]['subject']).to_equal(u'some/path/doéã.txt')

        expect(commits[0]).to_include('parent')
        expect(commits[0]).to_include('ref')
        expect(commits[0]).to_include('createdAt')

        expect(commits[0]).to_include('committer')
        expect(commits[0]['committer']).to_include('date')
        expect(commits[0]['committer']).to_include('name')
        expect(commits[0]['committer']).to_include('email')

        expect(commits[0]).to_include('author')
        expect(commits[0]['author']).to_include('date')
        expect(commits[0]['author']).to_include('name')
        expect(commits[0]['author']).to_include('email')
コード例 #3
0
    def test_can_get_repository_log_with_path(self):
        repo = str(uuid.uuid4())
        create_repository(repo)

        result = self.gandalf.repository_log(repo, "HEAD", 1, "README")

        expect(result).to_include('commits')
        expect(result).to_include('next')

        commits = result['commits']

        expect(commits[0]).to_include('subject')
        expect(commits[0]['subject']).to_equal('Initial commit')

        expect(commits[0]).to_include('parent')
        expect(commits[0]).to_include('ref')
        expect(commits[0]).to_include('createdAt')

        expect(commits[0]).to_include('committer')
        expect(commits[0]['committer']).to_include('date')
        expect(commits[0]['committer']).to_include('name')
        expect(commits[0]['committer']).to_include('email')

        expect(commits[0]).to_include('author')
        expect(commits[0]['author']).to_include('date')
        expect(commits[0]['author']).to_include('name')
        expect(commits[0]['author']).to_include('email')
コード例 #4
0
 def test_can_get_repository_contents_of_a_image(self):
     repo = str(uuid.uuid4())
     create_repository(repo)
     img_path = os.path.abspath('tests/fixtures/thumbnail.jpg')
     add_img_to_repo(repo, 'some/path/thumbnail.jpg', img_path)
     content = self.gandalf.repository_contents(repo, 'some/path/thumbnail.jpg')
     with open(img_path, 'rb') as img_file:
         expect(content).to_equal(img_file.read())
コード例 #5
0
    def test_can_get_repository_tags(self):
        repo = str(uuid.uuid4())
        create_repository(repo)
        tag_repo(repo, 'my-tag')

        result = self.gandalf.repository_tags(repo)
        expect(result[0]).to_include('name')
        expect(result[0]['name']).to_equal('my-tag')
コード例 #6
0
    def test_can_get_repository_tags_annotated_no_message(self):
        repo = str(uuid.uuid4())
        create_repository(repo)
        tag_repo(repo, 'my-annotated-tag', '')

        result = self.gandalf.repository_tags(repo)
        expect(result[0]).to_include('name')
        expect(result[0]['name']).to_equal('my-annotated-tag')
        expect(result[0]).to_include('subject')
        expect(result[0]['subject']).to_equal('')
コード例 #7
0
    def test_can_get_repository_branches(self):
        repo = str(uuid.uuid4())
        create_repository(repo)
        branch_repo(repo, 'branch-test')

        result = self.gandalf.repository_branches(repo)
        expect(result[0]).to_include('name')
        expect(result[0]['name']).to_equal('branch-test')
        expect(result[1]).to_include('name')
        expect(result[1]['name']).to_equal('master')
コード例 #8
0
    def test_can_get_repository_tags_with_git_committer(self):
        repo = str(uuid.uuid4())
        create_repository(repo)
        tag_repo(repo, 'my-tag')

        result = self.gandalf.repository_tags(repo)
        expect(result[0]).to_include('name')
        expect(result[0]['name']).to_equal('my-tag')
        expect(result[0]).to_include('committer')
        expect(result[0]['committer']['name']).to_equal('committer')
        expect(result[0]['committer']['email']).to_equal('<*****@*****.**>')
コード例 #9
0
    def test_can_get_repository_contents(self):
        repo = str(uuid.uuid4())
        create_repository(repo)
        add_file_to_repo(repo, 'some/path/doge.txt', 'FOO BAR')
        tag_repo(repo, '0.1.0')
        add_file_to_repo(repo, 'some/path/doge.txt', 'OTHER TEST')

        content = self.gandalf.repository_contents(repo, 'some/path/doge.txt', '0.1.0')
        expect(content).to_equal('FOO BAR\n')

        content = self.gandalf.repository_contents(repo, 'some/path/doge.txt')
        expect(content).to_equal('OTHER TEST\n')
コード例 #10
0
    def test_can_get_repository_branches(self):
        repo = str(uuid.uuid4())
        create_repository(repo)
        branch_repo(repo, 'branch-test')

        results = self.gandalf.repository_branches(repo)
        # there`s 2 branches: 'master' and 'branch-test'
        branches = ['branch-test', 'master']
        for i in range(len(results)):
            expect(results[i]).to_include('name')
            expect(branches).to_include(results[i]['name'])
            branches.remove(results[i]['name'])
        expect(branches).to_length(0)
コード例 #11
0
    def test_can_get_tree_with_path_for_ref(self):
        create_repository('test3')
        add_file_to_repo('test3', 'some/path/doge.txt', 'VERY COMMIT')
        tag_repo('test3', '0.1.0')
        add_file_to_repo('test3', 'some/path/to/add.txt', 'MUCH WOW')

        tree = yield self.gandalf.repository_tree('test3', '/some/path/', '0.1.0')

        expect(tree).to_length(1)
        expect(tree[0]).to_be_like({
            u'rawPath': u'some/path/doge.txt',
            u'path': u'some/path/doge.txt',
            u'filetype': u'blob',
            u'hash': u'cb508ee85be1e116233ae7c18e2d9bcc9553d209',
            u'permission': u'100644'
        })
コード例 #12
0
    def test_can_diff_commits(self):
        repo = str(uuid.uuid4())
        create_repository(repo)
        add_file_to_repo(repo, 'some/path/doge.txt', 'FOO BAR')
        tag_repo(repo, '0.1.0')
        add_file_to_repo(repo, 'some/path/doge.txt', 'OTHER TEST')

        diff = self.gandalf.repository_diff_commits(repo, '0.1.0', 'master')
        expected = """diff --git a/some/path/doge.txt b/some/path/doge.txt
index 404727f..bd82f1d 100644
--- a/some/path/doge.txt
+++ b/some/path/doge.txt
@@ -1 +1 @@
-FOO BAR
+OTHER TEST
"""
        expect(expected).to_equal(diff)
コード例 #13
0
    def test_can_get_repository_tags_annotated_with_git_tagger(self):
        repo = str(uuid.uuid4())
        create_repository(repo)
        tag_repo(repo, 'my-annotated-tag', 'annotated tag')

        result = self.gandalf.repository_tags(repo)
        expect(result[0]).to_include('name')
        expect(result[0]['name']).to_equal('my-annotated-tag')
        expect(result[0]).to_include('subject')
        expect(result[0]['subject']).to_equal('annotated tag')
        expect(result[0]).to_include('tagger')
        expect(result[0]['tagger']['name']).to_equal('tagger')
        expect(result[0]['tagger']['email']).to_equal('<*****@*****.**>')
        expect(result[0]).to_include('author')
        expect(result[0]['author']['name']).to_be_empty()
        expect(result[0]['author']['email']).to_be_empty()
        expect(result[0]).to_include('committer')
        expect(result[0]['committer']['name']).to_be_empty()
        expect(result[0]['committer']['email']).to_be_empty()
コード例 #14
0
    def test_can_get_repository_archive(self):
        repo = str(uuid.uuid4())
        create_repository(repo)
        add_file_to_repo(repo, 'some/path/doge.txt', 'FOO BAR')
        tag_repo(repo, '0.1.0')
        add_file_to_repo(repo, 'some/path/doge.txt', 'OTHER TEST')

        tar = self.gandalf.repository_archive(repo, 'master', 'tar')
        tar.extract('{0}-master/some/path/doge.txt'.format(repo), TMP_DIR)
        archive = open(os.path.join(TMP_DIR, '{0}-master/some/path/doge.txt'.format(repo)), 'r')
        content = archive.read()
        archive.close()
        expect(content).to_equal('OTHER TEST\n')

        zip_ = self.gandalf.repository_archive(repo, '0.1.0')
        zip_.extract('{0}-0.1.0/some/path/doge.txt'.format(repo), TMP_DIR)
        archive = open(os.path.join(TMP_DIR, '{0}-0.1.0/some/path/doge.txt'.format(repo)), 'r')
        content = archive.read()
        archive.close()
        expect(content).to_equal('FOO BAR\n')
コード例 #15
0
    def test_can_get_tree_with_path(self):
        create_repository('test2')
        add_file_to_repo('test2', 'some/path/doge.txt', 'VERY COMMIT')
        add_file_to_repo('test2', 'some/path/to/add.txt', 'MUCH WOW')

        tree = self.gandalf.repository_tree('test2', '/some/path/')

        expect(tree[0]).to_be_like({
            u'rawPath': u'some/path/doge.txt',
            u'path': u'some/path/doge.txt',
            u'filetype': u'blob',
            u'hash': u'cb508ee85be1e116233ae7c18e2d9bcc9553d209',
            u'permission': u'100644'
        })

        expect(tree[1]).to_be_like({
            u'rawPath': u'some/path/to/add.txt',
            u'path': u'some/path/to/add.txt',
            u'filetype': u'blob',
            u'hash': u'c5545f629c01a7597c9d4f9d5b68626062551622',
            u'permission': u'100644'
        })