示例#1
0
    def test_get_repos_from_org(self):
        def call_api(url):
            if 'org' in url:
                return {
                    'login': '******',
                    'description': 'description!',
                    'repos_url': 'repos'
                }
            elif 'repos' in url:
                return [{
                            'url': 'http://localhost/a_repo'
                        }]
            elif 'a_repo' in url:
                return {
                    'owner': {
                        "login": "******"
                    },
                    'name': 'sample_repo',
                    'description': 'description!',
                    'ssh_url': 'http://localhost/repos',
                    'forks_url': 'http://localhost/repos/forks'
                }
            else:
                raise ValueError()

        self.api.get = mock.MagicMock(side_effect=call_api)
        org = Organization.from_url(self.api, 'the org url!')
        self.assertEqual(len(org.repos), 1)
示例#2
0
    def test_get_repos_from_org(self):
        def call_api(url):
            if 'org' in url:
                return {
                    'login': '******',
                    'description': 'description!',
                    'repos_url': 'repos'
                }
            elif 'repos' in url:
                return [{'url': 'http://localhost/a_repo'}]
            elif 'a_repo' in url:
                return {
                    'owner': {
                        "login": "******"
                    },
                    'name': 'sample_repo',
                    'description': 'description!',
                    'ssh_url': 'http://localhost/repos',
                    'forks_url': 'http://localhost/repos/forks'
                }
            else:
                raise ValueError()

        self.api.get = mock.MagicMock(side_effect=call_api)
        org = Organization.from_url(self.api, 'the org url!')
        self.assertEqual(len(org.repos), 1)
示例#3
0
 def test_create_organization(self):
     self.api.get = mock.MagicMock(return_value={
         'login': '******',
         'description': 'description!',
         'repos_url': 'http://localhost/repos'
     })
     org = Organization.from_url(self.api, 'the org url!')
     print(repr(org))
     self.assertEqual('sample_org', org.name)
     self.assertEqual('description!', org.description)
示例#4
0
 def test_create_organization(self):
     self.api.get = mock.MagicMock(
         return_value={
             'login': '******',
             'description': 'description!',
             'repos_url': 'http://localhost/repos'
         })
     org = Organization.from_url(self.api, 'the org url!')
     print(repr(org))
     self.assertEqual('sample_org', org.name)
     self.assertEqual('description!', org.description)