示例#1
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)
示例#2
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)
示例#3
0
    def test_get_pr_list_from_username(self, mock_get_pr_by_number):
        """
        Get list of open PR for user
        """
        responses.add(
            responses.GET, 'https://api.github.com/search/issues?sort=created'
                           '&q=is:open is:pr author:itsjeyd repo:edx/edx-platform',
            match_querystring=True,
            body=get_raw_fixture('github/api_search_open_prs_user.json'),
            content_type='application/json; charset=utf8',
            status=200)

        mock_get_pr_by_number.side_effect = lambda fork_name, pr_number: [fork_name, pr_number]

        self.assertEqual(
            github.get_pr_list_from_username('itsjeyd', 'edx/edx-platform'),
            [['edx/edx-platform', 9147], ['edx/edx-platform', 9146]]
        )
示例#4
0
    def test_get_pr_list_from_username(self, mock_get_pr_by_number):
        """
        Get list of open PR for user
        """
        responses.add(
            responses.GET, 'https://api.github.com/search/issues?sort=created'
                           '&q=is:open is:pr author:itsjeyd repo:edx/edx-platform',
            match_querystring=True,
            body=get_raw_fixture('github/api_search_open_prs_user.json'),
            content_type='application/json; charset=utf8',
            status=200)

        mock_get_pr_by_number.side_effect = lambda fork_name, pr_number: [fork_name, pr_number]

        self.assertEqual(
            github.get_pr_list_from_username('itsjeyd', 'edx/edx-platform'),
            [['edx/edx-platform', 9147], ['edx/edx-platform', 9146]]
        )