예제 #1
0
class GitLabContentTest(IGittTestCase):
    def setUp(self):
        self.token = GitLabOAuthToken(os.environ.get('GITLAB_TEST_TOKEN', ''))
        self.repo = GitLabRepository(self.token, 'gitmate-test-user/test')

    def test_get_content(self):
        file = GitLabContent(self.token,
                             'gitmate-test-user/test',
                             path='README.md')
        self.assertIsNone(file.get_content())

    def test_delete_content(self):
        self.repo.create_file(path='deleteme',
                              message='hello',
                              content='hello',
                              branch='master')
        file = GitLabContent(self.token,
                             'gitmate-test-user/test',
                             path='deleteme')
        self.assertIsNone(file.delete(message='Delete file'))

    def test_update_content(self):
        file = GitLabContent(self.token,
                             'gitmate-test-user/test',
                             path='README.md')
        self.assertIsNone(
            file.update(message='Update README',
                        content='I am a test repo! Updated content!'))
예제 #2
0
    def test_create_mr(self):
        try:
            fork = self.fork_repo.create_fork(namespace='gitmate-test-user-2')
        except RuntimeError:
            fork = GitLabRepository(self.fork_token, 'gitmate-test-user-2/test')
            fork.delete()
            fork = self.fork_repo.create_fork(namespace='gitmate-test-user-2')

        fork.create_file(path='.coafile', message='hello', content='hello', branch='master')
        mr = fork.create_merge_request(title='coafile', head='master', base='master',
                                       target_project_id=self.repo.data['id'],
                                       target_project=self.repo.data['path_with_namespace'])

        self.assertIsInstance(mr, GitLabMergeRequest)
예제 #3
0
    def test_create_file(self):
        try:
            fork = self.fork_repo.create_fork(namespace='gitmate-test-user-2')
        except RuntimeError:
            fork = GitLabRepository(self.fork_token, 'gitmate-test-user-2/test')
            fork.delete()
            fork = self.fork_repo.create_fork(namespace='gitmate-test-user-2')
        author = {
            'name': 'gitmate-test-user-2',
            'email': '*****@*****.**'
        }

        self.assertIsInstance(fork.create_file(path='.coafile', message='hello',
                                               content='hello', branch='master', author=author),
                              GitLabContent)