Example #1
0
 def test_create_no_folder(self):
     with TempDir() as tmp:
         repo_path = tmp / 'no-folder'
         repo = GitHubRepo.create(repo_path, mk_dir=True)
         git_dir = repo_path / '.git'
         ok_(git_dir.exists())
         eq_(str(git_dir), repo.path)
Example #2
0
 def test_register(self, urlopen_mock):
     urlopen_mock.return_value = \
         StringIO(TestProject.GITHUB_JSON_RESPONSE)
     with TempDir() as tmp:
         repo = GitHubRepo.create(tmp)
         git_mock = Mock()
         repo.git = git_mock
         credentials = Credentials('damien', 'xyz')
         repo.register(
             'foo', credentials=credentials,
             description='just a test', is_public=True)
         
         # test project creation 
         url, data = urlopen_mock.call_args[0]
         data_dict = dict(cgi.parse_qsl(data))
         eq_('http://github.com/api/v2/json/repos/create', url)
         eq_('foo', data_dict['name'])
         eq_('just a test', data_dict['description'])
         eq_('1', data_dict['public'])
         eq_('damien', data_dict['login'])
         eq_('xyz', data_dict['token'])
         
         # test remote added
         eq_(('add', 'origin', '[email protected]:damien/foo.git'),
             git_mock.remote.call_args[0])
         eq_(('origin', 'master'), git_mock.push.call_args[0])
Example #3
0
    def test_register(self, urlopen_mock):
        urlopen_mock.return_value = \
            StringIO(TestProject.GITHUB_JSON_RESPONSE)
        with TempDir() as tmp:
            repo = GitHubRepo.create(tmp)
            git_mock = Mock()
            repo.git = git_mock
            credentials = Credentials('damien', 'xyz')
            repo.register('foo',
                          credentials=credentials,
                          description='just a test',
                          is_public=True)

            # test project creation
            url, data = urlopen_mock.call_args[0]
            data_dict = dict(cgi.parse_qsl(data))
            eq_('http://github.com/api/v2/json/repos/create', url)
            eq_('foo', data_dict['name'])
            eq_('just a test', data_dict['description'])
            eq_('1', data_dict['public'])
            eq_('damien', data_dict['login'])
            eq_('xyz', data_dict['token'])

            # test remote added
            eq_(('add', 'origin', '[email protected]:damien/foo.git'),
                git_mock.remote.call_args[0])
            eq_(('origin', 'master'), git_mock.push.call_args[0])
Example #4
0
 def test_create_no_folder(self):
     with TempDir() as tmp:
         repo_path = tmp / 'no-folder'
         repo = GitHubRepo.create(repo_path, mk_dir=True)
         git_dir = repo_path / '.git'
         ok_(git_dir.exists())
         eq_(str(git_dir), repo.path)
Example #5
0
def _get_repo(working_copy):
    """
    Check that a directory is a git working copy.
    
    return a GitHubRepo instance or exit.
    """
    git_dir = os.path.join(working_copy, '.git')
    if os.path.exists(git_dir) and os.path.isdir(git_dir):
        return GitHubRepo(working_copy)
    sys.exit('%s is not a git directory.' % os.getcwd())
Example #6
0
 def test_create(self):
     with TempDir() as tmp:
         repo = GitHubRepo.create(tmp)
         git_dir = tmp / '.git'
         ok_(git_dir.exists())
         eq_(str(git_dir), repo.path)
Example #7
0
 def test_create(self):
     with TempDir() as tmp:
         repo = GitHubRepo.create(tmp)
         git_dir = tmp / '.git'
         ok_(git_dir.exists())
         eq_(str(git_dir), repo.path)