def setUp(self): self.monorail_client = mock.create_autospec( monorail_client.MonorailClient, spec_set=True, instance=True) self.logger = mock.create_autospec(logging.Logger, spec_set=True, instance=True) ts_mon.reset_for_unittest()
def setUp(self): super(InstrumentedHttplib2Test, self).setUp() self.mock_time = mock.create_autospec(time.time, spec_set=True) self.mock_time.return_value = 42 self.http = infra_libs.InstrumentedHttp('test', time_fn=self.mock_time) self.http._request = mock.Mock() ts_mon.reset_for_unittest()
def setUp(self): super(InstrumentedHttplib2Test, self).setUp() self.mock_time = mock.create_autospec(time.time, spec_set=True) self.mock_time.return_value = 42 self.http = infra_libs.InstrumentedHttp('test', time_fn=self.mock_time) self.http._request = mock.Mock() ts_mon.reset_for_unittest()
def test_catches_exceptions(self): a = MockApplication() a.main.side_effect = Exception ts_mon.reset_for_unittest(disable=True) with self.assertRaises(SystemExit) as cm: a.run(['appname']) self.assertEqual(1, cm.exception.code)
def setUp(self): ts_mon.reset_for_unittest() self.response = requests.Response() self.response.elapsed = datetime.timedelta(seconds=2, milliseconds=500) self.response.status_code = 200 self.response.request = requests.PreparedRequest() self.response.request.prepare_headers(None) self.hook = instrumented_requests.instrumentation_hook('foo')
def setUp(self): ts_mon.reset_for_unittest() self.tempdir = tempfile.mkdtemp() self.filename = os.path.join(self.tempdir, 'last_run_summary.yaml') self.fh = open(self.filename, 'w') self.mock_lastrunfile = mock.patch( 'infra.services.sysmon.puppet_metrics._lastrunfile').start() self.mock_lastrunfile.return_value = self.filename
def setUp(self): super(FlakeIssuesTestCase, self).setUp() ts_mon.reset_for_unittest(disable=True) self.mock_api = MockIssueTrackerAPI() self.patchers = [ mock.patch('issue_tracker.issue_tracker_api.IssueTrackerAPI', lambda *args, **kwargs: self.mock_api), mock.patch('issue_tracker.issue.Issue', MockIssue), ] for patcher in self.patchers: patcher.start()
def test_catches_exceptions_with_ts_mon_disabled(self): class Application(MockApplication): USES_TS_MON = False a = Application() a.main.side_effect = Exception ts_mon.reset_for_unittest(disable=True) with self.assertRaises(SystemExit) as cm: a.run(['appname']) self.assertEqual(1, cm.exception.code)
def setUp(self): self.temp_dir = tempfile.mkdtemp() self.gitiles_helper_ctor = (mock.patch( 'infra.services.bugdroid.gob_helper.GitilesHelper', autospec=True).start()) self.gitiles = self.gitiles_helper_ctor.return_value self.handler = mock.create_autospec(poller_handlers.BasePollerHandler, instance=True) self.handler.must_succeed = False self.poller = gitiles_poller.GitilesPoller( 'http://example.com', 'foo', datadir=self.temp_dir, start_commits={'refs/heads/master': 'last commit'}) self.poller.add_handler(self.handler) ts_mon.reset_for_unittest()
def setUp(self): self.temp_dir = tempfile.mkdtemp() self.gerrit_helper_ctor = (mock.patch( 'infra.services.bugdroid.gob_helper.GerritHelper', autospec=True).start()) self.gerrit = self.gerrit_helper_ctor.return_value self.since_date = datetime.datetime(2000, 1, 1, 16, 20, 9, 171530) self.gerrit.GenerateTimeStamp.return_value = 'Wed Jan 1 16:20:14 2000' self.gerrit.ParseTimeStamp.return_value = self.since_date self.handler = mock.create_autospec(poller_handlers.BasePollerHandler, instance=True) self.handler.must_succeed = False self.poller = gerrit_poller.GerritPoller('http://example.com', 'foo', datadir=self.temp_dir) self.poller.add_handler(self.handler) ts_mon.reset_for_unittest()
def setUp(self): super(PollerTest, self).setUp() ts_mon.reset_for_unittest()
def setUp(self): super(CQStatusTestCase, self).setUp() ts_mon.reset_for_unittest(disable=True)
def setUp(self): super(StatusLoggerTest, self).setUp() ts_mon.reset_for_unittest(disable=True)
def setUp(self): ts_mon.reset_for_unittest()
def setUp(self): super(MasterManagerTest, self).setUp() ts_mon.reset_for_unittest()
def setUp(self): interface.state = interface.State() interface.state.reset_for_unittest() interface.state.target = targets.TaskTarget('test_service', 'test_job', 'test_region', 'test_host') ts_mon.reset_for_unittest()
def setUp(self): interface.state.target = targets.TaskTarget( 'test_service', 'test_job', 'test_region', 'test_host') ts_mon.reset_for_unittest()
def setUp(self): self.old_all_version_files = cipd_metrics.ALL_VERSION_DIRS ts_mon.reset_for_unittest()
def setUp(self): ts_mon.reset_for_unittest()