Exemplo n.º 1
0
    def test_send_all_metrics(self):
        buf = mock.Mock()
        self.mock(metrics_component, 'Buffer', lambda: buf)

        self.mock(config, 'get_buckets_async', mock.Mock())
        config.get_buckets_async.return_value = future(
            [project_config_pb2.Bucket(name='x')])
        self.mock(metrics, 'send_build_status_metric', mock.Mock())

        metrics.send_all_metrics()

        metrics.send_build_status_metric.assert_any_call(
            buf, 'x', metrics.METRIC_PENDING_BUILDS,
            model.BuildStatus.SCHEDULED)
        metrics.send_build_status_metric.assert_any_call(
            buf, 'x', metrics.METRIC_RUNNING_BUILDS, model.BuildStatus.STARTED)
Exemplo n.º 2
0
  def setUp(self):
    super(BuildBucketServiceTest, self).setUp()
    self.service = service.BuildBucketService()
    self.test_build = model.Build(
        bucket='chromium',
        parameters={
            'buildername': 'infra',
            'changes': [{
                'author': '*****@*****.**',
                'message': 'buildbucket: initial commit'
            }]
        }
    )

    self.current_identity = auth.Identity('service', 'unittest')
    self.mock(auth, 'get_current_identity', lambda: self.current_identity)
    self.mock(acl, 'can_async', lambda *_: future(True))
    self.mock(utils, 'utcnow', lambda: datetime.datetime(2015, 1, 1))
Exemplo n.º 3
0
    def setUp(self):
        super(BuildBucketServiceTest, self).setUp()
        self.service = service.BuildBucketService()
        self.test_build = model.Build(bucket='chromium',
                                      parameters={
                                          'buildername':
                                          'infra',
                                          'changes': [{
                                              'author':
                                              '*****@*****.**',
                                              'message':
                                              'buildbucket: initial commit'
                                          }]
                                      })

        self.current_identity = auth.Identity('service', 'unittest')
        self.mock(auth, 'get_current_identity', lambda: self.current_identity)
        self.mock(acl, 'can_async', lambda *_: future(True))
        self.mock(utils, 'utcnow', lambda: datetime.datetime(2015, 1, 1))
Exemplo n.º 4
0
 def can_async(_bucket, requested_action, _identity=None):
   return future(action != requested_action)
Exemplo n.º 5
0
 def can_async(_bucket, requested_action, _identity=None):
     return future(action != requested_action)