Пример #1
0
    def test_can_add_repository_hook(self):
        repo = str(uuid.uuid4())
        create_bare_repository(repo)

        created = self.gandalf.hook_add('post-receive', repo, repo)
        expect(created).to_be_true()
        archive = open(os.path.join(REPOS_DIR, repo + '.git', 'hooks', 'post-receive'), 'r')
        content = archive.read()
        archive.close()
        expect(content).to_equal(repo)

        created = self.gandalf.hook_add('pre-receive', repo, repo)
        expect(created).to_be_true()
        archive = open(os.path.join(REPOS_DIR, repo + '.git', 'hooks', 'pre-receive'), 'r')
        content = archive.read()
        archive.close()
        expect(content).to_equal(repo)

        created = self.gandalf.hook_add('update', repo, repo)
        expect(created).to_be_true()
        archive = open(os.path.join(REPOS_DIR, repo + '.git', 'hooks', 'update'), 'r')
        content = archive.read()
        archive.close()
        expect(content).to_equal(repo)

        created = self.gandalf.hook_add('update', repo + ' another', [repo])
        expect(created).to_be_true()
        archive = open(os.path.join(REPOS_DIR, repo + '.git', 'hooks', 'update'), 'r')
        content = archive.read()
        archive.close()
        expect(content).to_equal(repo + ' another')

        not_created = self.gandalf.hook_add('invalid', repo, repo)
        expect(not_created).to_be_false()
Пример #2
0
    def test_can_commit_into_repo(self):
        repo = str(uuid.uuid4())
        create_bare_repository(repo)

        json = self.gandalf.repository_commit(
            repo,
            'Repository scaffold',
            'Author Name',
            '*****@*****.**',
            'Committer Name',
            '*****@*****.**',
            'master',
            open('./tests/fixtures/scaffold.zip', 'rb')
        )

        expect(json).to_include('committer')
        expect(json).to_include('author')
        expect(json).to_include('name')
        expect(json).to_include('ref')
        expect(json).to_include('createdAt')
        expect(json).to_include('subject')
        expect(json).to_include('_links')

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

        expect(json['author']).to_include('date')
        expect(json['author']).to_include('name')
        expect(json['author']).to_include('email')

        expect(json['name']).to_equal(u'master')
        expect(json['subject']).to_equal(u'Repository scaffold')

        expect(json['_links']).to_include('zipArchive')
        expect(json['_links']).to_include('tarArchive')