Exemplo n.º 1
0
    def setUp(self):
        super(TSMonJSHandlerTest, self).setUp()

        config.reset_for_unittest()
        target = targets.TaskTarget('test_service', 'test_job', 'test_region',
                                    'test_host')
        self.mock_state = interface.State(target=target)
        mock.patch('infra_libs.ts_mon.common.interface.state',
                   new=self.mock_state).start()
        self.request = webapp2.Request.blank('/_/ts_mon_js')
        self.response = webapp2.Response()
        self.ts_mon_handler = handlers.TSMonJSHandler(request=self.request,
                                                      response=self.response)
        self.ts_mon_handler.register_metrics([
            metrics.BooleanMetric(
                'frontend/boolean_test',
                'Boolean metric test',
                field_spec=[metrics.StringField('client_id')]),
        ])
        self.ts_mon_handler.xsrf_is_valid = mock.Mock(return_value=True)
        self.mock_timestamp = 1537821859

        def time_fn():
            return self.mock_timestamp

        self.ts_mon_handler.time_fn = time_fn
Exemplo n.º 2
0
    def setUp(self):
        super(HandlersTest, self).setUp()

        config.reset_for_unittest()
        target = targets.TaskTarget('test_service', 'test_job', 'test_region',
                                    'test_host')
        self.mock_state = interface.State(target=target)
        mock.patch('infra_libs.ts_mon.common.interface.state',
                   new=self.mock_state).start()
Exemplo n.º 3
0
    def setUp(self):
        super(InitializeTest, self).setUp()

        config.reset_for_unittest()
        target = targets.TaskTarget('test_service', 'test_job', 'test_region',
                                    'test_host')
        self.mock_state = interface.State(target=target)
        self.mock_state.metrics = copy.copy(interface.state.metrics)
        mock.patch('infra_libs.ts_mon.common.interface.state',
                   new=self.mock_state).start()

        mock.patch('infra_libs.ts_mon.common.monitors.HttpsMonitor',
                   autospec=True).start()
Exemplo n.º 4
0
  def setUp(self):
    super(InitializeTest, self).setUp()

    config.reset_for_unittest()
    target = targets.TaskTarget('test_service', 'test_job',
                                'test_region', 'test_host')
    self.mock_state = interface.State(target=target)
    self.mock_state.metrics = copy.copy(interface.state.metrics)
    mock.patch('infra_libs.ts_mon.common.interface.state',
        new=self.mock_state).start()

    mock.patch('infra_libs.ts_mon.common.monitors.PubSubMonitor',
               autospec=True).start()
Exemplo n.º 5
0
    def setUp(self):
        super(HandlersTest, self).setUp()

        config.reset_for_unittest()
        target = targets.TaskTarget('test_service', 'test_job', 'test_region',
                                    'test_host')
        self.mock_state = interface.State(target=target)
        mock.patch('infra_libs.ts_mon.common.interface.state',
                   new=self.mock_state).start()

        # Workaround the fact that 'system' module is not mocked.
        class _memory_usage(object):
            def current(self):
                return 10.0

        self.mock(runtime, 'memory_usage', _memory_usage)
Exemplo n.º 6
0
 def tearDown(self):
     config.reset_for_unittest()
     mock.patch.stopall()
     super(InstrumentEndpointTest, self).tearDown()
Exemplo n.º 7
0
 def tearDown(self):
     config.reset_for_unittest()
     mock.patch.stopall()
     super(InitializeTest, self).tearDown()
Exemplo n.º 8
0
 def tearDown(self):
     mock.patch.stopall()
     config.reset_for_unittest()
     super(HandlersTest, self).tearDown()
Exemplo n.º 9
0
 def tearDown(self):
   config.reset_for_unittest()
   self.assertEqual([], list(shared.global_metrics_callbacks))
   mock.patch.stopall()
   super(InstrumentEndpointTest, self).tearDown()