Esempio n. 1
0
    def test_get_username_list_from_team_404(self):
        """
        Get list of open PR for non-existent team
        """
        responses.add(
            responses.GET, 'https://api.github.com/orgs/open-craft/teams',
            body=get_raw_fixture('github/api_teams.json'),
            content_type='application/json; charset=utf8',
            status=200)

        with self.assertRaises(KeyError, msg='non-existent'):
            github.get_username_list_from_team('open-craft', team_name='non-existent')
Esempio n. 2
0
    def test_get_username_list_from_team_404(self):
        """
        Get list of open PR for non-existent team
        """
        responses.add(responses.GET,
                      'https://api.github.com/orgs/open-craft/teams',
                      body=get_raw_fixture('github/api_teams.json'),
                      content_type='application/json; charset=utf8',
                      status=200)

        with self.assertRaises(KeyError, msg='non-existent'):
            github.get_username_list_from_team('open-craft',
                                               team_name='non-existent')
Esempio n. 3
0
    def github_admin_username_list(self):
        """
        Returns the github usernames of this instance admins

        Admins are all users listed in github_admin_users and the members of the default team of the
        organizations in github_admin_organizations.
        """
        admin_users = []
        for org in self.github_admin_organizations:
            admin_users += get_username_list_from_team(org)
        admin_users += self.github_admin_users
        return admin_users
Esempio n. 4
0
    def github_admin_username_list(self):
        """
        Returns the github usernames of this instance admins

        Admins are all users listed in github_admin_users and the members of the default team of the
        organizations in github_admin_organizations.
        """
        admin_users = []
        for org in self.github_admin_organizations:
            admin_users += get_username_list_from_team(org)
        admin_users += self.github_admin_users
        return admin_users
Esempio n. 5
0
def watch_pr():
    """
    Automatically create sandboxes for PRs opened by members of the watched
    organization on the watched repository
    """
    team_username_list = get_username_list_from_team(settings.WATCH_ORGANIZATION)

    for username in team_username_list:
        for pr in get_pr_list_from_username(username, settings.WATCH_FORK):
            instance, created = WatchedPullRequest.objects.get_or_create_from_pr(pr)
            if created:
                logger.info('New PR found, creating sandbox: %s', pr)
                spawn_appserver(instance.ref.pk, mark_active_on_success=True, num_attempts=2)
Esempio n. 6
0
def watch_pr():
    """
    Automatically create sandboxes for PRs opened by members of the watched
    organization on the watched repository
    """
    team_username_list = get_username_list_from_team(
        settings.WATCH_ORGANIZATION)

    for username in team_username_list:
        for pr in get_pr_list_from_username(username, settings.WATCH_FORK):
            instance, created = WatchedPullRequest.objects.get_or_create_from_pr(
                pr)
            if created:
                logger.info('New PR found, creating sandbox: %s', pr)
                spawn_appserver(instance.ref.pk,
                                mark_active_on_success=True,
                                num_attempts=2)
Esempio n. 7
0
    def test_get_username_list_from_team(self):
        """
        Get list of members in a team
        """
        responses.add(responses.GET,
                      'https://api.github.com/orgs/open-craft/teams',
                      body=get_raw_fixture('github/api_teams.json'),
                      content_type='application/json; charset=utf8',
                      status=200)
        responses.add(responses.GET,
                      'https://api.github.com/teams/799617/members',
                      body=get_raw_fixture('github/api_members.json'),
                      content_type='application/json; charset=utf8',
                      status=200)

        self.assertEqual(github.get_username_list_from_team('open-craft'), [
            'antoviaque', 'bradenmacdonald', 'e-kolpakov', 'itsjeyd',
            'Kelketek', 'mtyaka', 'smarnach'
        ])
Esempio n. 8
0
    def test_get_username_list_from_team(self):
        """
        Get list of members in a team
        """
        responses.add(
            responses.GET, 'https://api.github.com/orgs/open-craft/teams',
            body=get_raw_fixture('github/api_teams.json'),
            content_type='application/json; charset=utf8',
            status=200)
        responses.add(
            responses.GET, 'https://api.github.com/teams/799617/members',
            body=get_raw_fixture('github/api_members.json'),
            content_type='application/json; charset=utf8',
            status=200)

        self.assertEqual(
            github.get_username_list_from_team('open-craft'),
            ['antoviaque', 'bradenmacdonald', 'e-kolpakov', 'itsjeyd', 'Kelketek', 'mtyaka', 'smarnach']
        )