Пример #1
0
 def test_lookup_github_fullname(self):
     """ Test lookup_github_full_name. """
     with responses.RequestsMock() as rsps:
         rsps.add('GET', 'https://api.github.com/users/{}'.format(self.gh_username),
                  json={"name": self.gh_full_name}, status=200)
         name = lookup_github_full_name(self.gh_username)
         self.assertEqual(name, self.gh_full_name)
Пример #2
0
def _get_slack_username_by_github_username(github_username):  # pylint: disable=invalid-name
    slack_client = SlackClient(os.environ.get('SLACK_BOT_TOKEN'))
    response = slack_client.api_call("users.list")
    users = response.get('members', [])

    if github_username:
        slack_username = _match_slack_github_username(users, github_username)
        if not slack_username:
            full_name = lookup_github_full_name(github_username)
            slack_username = _match_slack_un_by_fullname(users, full_name)
        return slack_username
    return None
 def test_network_lookup_github_fullname(self):
     """ Test lookup_github_full_name with a network request to github. """
     name = lookup_github_full_name(self.gh_username)
     self.assertEqual(name, self.gh_full_name)