def test_json_format(self):
     pr = ProfileResponse(
         1,
         2,
         3,
         ["Java", "Python", "Ruby"],
         ["Java is coffee", "Ruby is shiny", "Python is slippery"],
     )
     expected = {
         "languages": [{
             "java": 1
         }, {
             "python": 1
         }, {
             "ruby": 1
         }],
         "repo_topics": [
             {
                 "java is coffee": 1
             },
             {
                 "ruby is shiny": 1
             },
             {
                 "python is slippery": 1
             },
         ],
         "total_repos": {
             "forked": 3,
             "original": 1
         },
         "total_watchers":
         2,
     }
     assert expected == pr.json_format()
 def test_count_languages(self):
     pr = ProfileResponse(
         1,
         2,
         3,
         ["Java", "java", "Python", "Ruby"],
         ["Java is coffee", "Ruby is shiny", "Python is slippery"],
     )
     expected = [{"java": 2}, {"python": 1}, {"ruby": 1}]
     assert expected == pr.get_counts(pr.languages)
 def test_json_format_empty(self):
     pr = ProfileResponse(0, 0, 0, [], [])
     expected = {
         "languages": [],
         "repo_topics": [],
         "total_repos": {
             "forked": 0,
             "original": 0
         },
         "total_watchers": 0,
     }
     assert expected == pr.json_format()
示例#4
0
 def get_profile(self, org):
     return ProfileResponse(**self.parse_response(
         make_call(
             "https://api.github.com/orgs/{}/repos".format(org),
             HEADERS,
             "Github",
         ).content))
 def get_profile(self, team):
     return ProfileResponse(**self.parse_repos(
         make_call(
             "https://bitbucket.org/api/2.0/repositories/{}".format(team),
             HEADERS,
             "bitbucket",
             username=self.username,
             password=self.password,
         ).content))
示例#6
0
 def test_get_profile(self):
     github_mock = mock.MagicMock()
     github_mock.get_profile = mock.MagicMock()
     github_mock.get_profile.return_value = ProfileResponse(
         1, 1, 1, ["l1"], ["topic1"])
     bitbucket_mock = mock.MagicMock()
     bitbucket_mock.get_profile = mock.MagicMock()
     bitbucket_mock.get_profile.return_value = ProfileResponse(
         2, 2, 2, ["l2", "l3"], ["topic2", "topic3"])
     ra = ResponseAggregator(**{
         "github_service": github_mock,
         "bitbucket_service": bitbucket_mock
     })
     expected = ProfileResponse(
         3, 3, 3, ["l1", "l2", "l3"],
         ["topic1", "topic2", "topic3"]).json_format()
     actual = ra.get_profile("org1", "team1")
     assert expected == actual
 def test_count_languages_empty(self):
     pr = ProfileResponse(
         1, 2, 3, [],
         ["Java is coffee", "Ruby is shiny", "Python is slippery"])
     expected = []
     assert expected == pr.get_counts(pr.languages)