def test_org(self, url, my_mock): """ Test GithubOrgClient.org """ my_mock.return_value = True g = client.GithubOrgClient(url) self.assertEqual(g.org, True) my_mock.assert_called_once()
def test_org(self, url, payload, mockJson): """ test org property """ mockJson.return_value = payload data = client.GithubOrgClient(url) response = data.org self.assertEqual(response, payload) mockJson.assert_called_once()
def test_org(self, org_name, mock_get_json): ''' Test GithubOrgClient.org() ''' goc = client.GithubOrgClient(org_name) goc.org() mock_get_json.assert_called_once_with( 'https://api.github.com/orgs/{}'.format(org_name))
def test_public_repos_url(self, name, expect): """ Test _public_repos_url """ with patch('client.GithubOrgClient.org', PropertyMock(return_value=expect)): response = client.GithubOrgClient(name)._public_repos_url self.assertEqual(response, expect.get('repos_url'))
def test_public_repos(self): """ method test_public_repos """ g = client.GithubOrgClient('test') self.assertEqual(g.org, self.org_payload) self.assertEqual(g.repos_payload, self.repos_payload) self.assertEqual(g.public_repos(), self.expected_repos) self.assertEqual(g.public_repos('test'), []) self.mock.assert_called()
def test_public_repos_url(self, org): """ method test_public_repos_url """ url = 'https://api.github.com/orgs/{}/repos'.format(org) payload = {'repos_url': url} with patch('client.GithubOrgClient.org', PropertyMock(return_value=payload)): g = client.GithubOrgClient(org) self.assertEqual(g._public_repos_url, url)
def test_public_repos(self, mock): """ method test_public_repos """ return_value = [{'name': 'google'}, {'name': 'abc'}] mock.return_value = return_value with patch('client.GithubOrgClient._public_repos_url', PropertyMock(return_value=return_value)) as public: g = client.GithubOrgClient('test') self.assertEqual(g.public_repos(), ['google', 'abc']) mock.assert_called_once() public.assert_called_once()
def test_public_repos_with_license(self): """ Test public_repos with license 'apache-2.0' """ g = client.GithubOrgClient('test') self.assertEqual(g.org, self.org_payload) self.assertEqual(g.repos_payload, self.repos_payload) self.assertEqual(g.public_repos(), self.expected_repos) self.assertEqual(g.public_repos('test'), []) self.assertEqual(g.public_repos('apache-2.0'), self.apache2_repos) self.mock.assert_called()
def test_gorg(self, gorg, m): ''' Test Github Org class doc string ''' client.GithubOrgClient(gorg).org() m.assert_called_once_with(f'https://api.github.com/orgs/{gorg}')
def test_has_license(self, repo, license_key, has_license): """ Test has_license """ g = client.GithubOrgClient('test') self.assertEqual(g.has_license(repo, license_key), has_license)