def test_twelve_char_request(self, post):
     """trigger_arbitrary_job should raise an BuildapiAuthError if it receives a bad response."""
     with self.assertRaises(AssertionError):
         buildapi_client.trigger_arbitrary_job(
             repo_name="repo",
             builder="builder",
             revision=TWELVE_CHAR_CHANGESET,
             auth=None,
             dry_run=False,
         )
 def test_call_without_dry_run(self, post):
     """trigger_arbitrary_job should call requests.post."""
     buildapi_client.trigger_arbitrary_job("repo", "builder", "123456123456", auth=None, dry_run=False)
     # We expect that trigger_arbitrary_job will call requests.post
     # once with the following arguments
     post.assert_called_once_with(
         '%s/%s/builders/%s/%s' % (HOST_ROOT, "repo", "builder", "123456123456"),
         headers={'Accept': 'application/json'},
         data={'properties':
               '{"branch": "repo", "revision": "123456123456"}'},
         auth=None)
 def test_call_without_dry_run(self, post):
     """trigger_arbitrary_job should call requests.post."""
     buildapi_client.trigger_arbitrary_job(
         "repo", "builder", FORTY_CHAR_CHANGESET, auth=None, dry_run=False)
     # We expect that trigger_arbitrary_job will call requests.post
     # once with the following arguments
     post.assert_called_once_with(
         '%s/%s/builders/%s/%s' % (SELF_SERVE, "repo", "builder", FORTY_CHAR_CHANGESET),
         headers={'Accept': 'application/json'},
         data={'properties':
               '{"branch": "repo", "revision": "%s"}' % FORTY_CHAR_CHANGESET},
         auth=None,
         timeout=TCP_TIMEOUT,
     )
Пример #4
0
 def schedule_arbitrary_job(self, repo_name, revision, uuid, *args, **kwargs):
     return trigger_arbitrary_job(repo_name=repo_name,
                                  builder=uuid,
                                  revision=revision,
                                  auth=get_credentials(),
                                  *args,
                                  **kwargs)
Пример #5
0
def trigger(builder,
            revision,
            files=None,
            dry_run=False,
            extra_properties=None):
    """Helper to trigger a job.

    Returns a request.
    """
    _add_builder_to_scheduling_manager(revision=revision, buildername=builder)

    repo_name = query_repo_name_from_buildername(builder)

    if is_downstream(builder) and not files:
        raise MozciError(
            'We have requested to trigger a test job, however, we have not provided '
            'which files to run against.')

    return trigger_arbitrary_job(repo_name=repo_name,
                                 builder=builder,
                                 revision=revision,
                                 auth=get_credentials(),
                                 files=files,
                                 dry_run=dry_run,
                                 extra_properties=extra_properties)
 def test_call_with_dry_run(self, post):
     """trigger_arbitrary_job should return None when dry_run is True."""
     self.assertEquals(
         buildapi_client.trigger_arbitrary_job(
             "repo", "builder", "123456123456", auth=None, dry_run=True), None)
     # trigger_arbitrary_job should not call requests.post when dry_run is True
     assert post.call_count == 0
Пример #7
0
 def schedule_arbitrary_job(self, repo_name, revision, uuid, *args,
                            **kwargs):
     return trigger_arbitrary_job(repo_name=repo_name,
                                  builder=uuid,
                                  revision=revision,
                                  auth=get_credentials(),
                                  *args,
                                  **kwargs)
 def test_call_with_dry_run(self, post):
     """trigger_arbitrary_job should return None when dry_run is True."""
     self.assertEquals(
         buildapi_client.trigger_arbitrary_job(
             repo_name="repo",
             builder="builder",
             revision=FORTY_CHAR_CHANGESET,
             auth=None,
             dry_run=True), None)
     # trigger_arbitrary_job should not call requests.post when dry_run is True
     assert post.call_count == 0
Пример #9
0
def trigger(builder, revision, files=[], dry_run=False, extra_properties=None):
    """Helper to trigger a job.

    Returns a request.
    """
    global SCHEDULING_MANAGER
    sch_mgr = SCHEDULING_MANAGER

    if revision not in sch_mgr:
        sch_mgr[revision] = []

    sch_mgr[revision].append(builder)

    repo_name = query_repo_name_from_buildername(builder)
    return trigger_arbitrary_job(repo_name, builder, revision, files, dry_run, extra_properties)
Пример #10
0
def trigger(builder, revision, files=[], dry_run=False, extra_properties=None):
    """Helper to trigger a job.

    Returns a request.
    """
    _add_builder_to_scheduling_manager(revision=revision, buildername=builder)

    repo_name = query_repo_name_from_buildername(builder)
    return trigger_arbitrary_job(repo_name=repo_name,
                                 builder=builder,
                                 revision=revision,
                                 auth=get_credentials(),
                                 files=files,
                                 dry_run=dry_run,
                                 extra_properties=extra_properties)
Пример #11
0
def trigger(builder, revision, files=[], dry_run=False, extra_properties=None):
    """Helper to trigger a job.

    Returns a request.
    """
    _add_builder_to_scheduling_manager(revision=revision, buildername=builder)

    repo_name = query_repo_name_from_buildername(builder)
    return trigger_arbitrary_job(repo_name=repo_name,
                                 builder=builder,
                                 revision=revision,
                                 auth=get_credentials(),
                                 files=files,
                                 dry_run=dry_run,
                                 extra_properties=extra_properties)
Пример #12
0
def trigger(builder, revision, files=[], dry_run=False, extra_properties=None):
    """Helper to trigger a job.

    Returns a request.
    """
    global SCHEDULING_MANAGER
    sch_mgr = SCHEDULING_MANAGER

    if revision not in sch_mgr:
        sch_mgr[revision] = []

    sch_mgr[revision].append(builder)

    repo_name = query_repo_name_from_buildername(builder)
    return trigger_arbitrary_job(repo_name, builder, revision, files, dry_run,
                                 extra_properties)
Пример #13
0
def trigger(builder, revision, files=None, dry_run=False, extra_properties=None):
    """Helper to trigger a job.

    Returns a request.
    """
    _add_builder_to_scheduling_manager(revision=revision, buildername=builder)

    repo_name = query_repo_name_from_buildername(builder)

    if is_downstream(builder) and not files:
        raise MozciError('We have requested to trigger a test job, however, we have not provided '
                         'which files to run against.')

    return trigger_arbitrary_job(repo_name=repo_name,
                                 builder=builder,
                                 revision=revision,
                                 auth=get_credentials(),
                                 files=files,
                                 dry_run=dry_run,
                                 extra_properties=extra_properties)
 def test_bad_response(self, post):
     """trigger_arbitrary_job should raise an BuildapiAuthError if it receives a bad response."""
     with self.assertRaises(buildapi_client.BuildapiAuthError):
         buildapi_client.trigger_arbitrary_job("repo", "builder", "123456123456", auth=None, dry_run=False)