def testNoErrors(self): """Test that we don't print anything when there are no errors.""" with cros_test_lib.LoggingCapturer() as logs: with stats.UploadContext() as queue: queue.put([stats.Stats()]) self.AssertLogsContain(logs, stats.UNCAUGHT_UPLOAD_ERROR, inverted=True) self.assertEquals(stats.StatsUploader._Upload.call_count, 1)
def _LoadLinesV1(cls, stat_lines): """Load stat lines in Version 1 format.""" data = {} for line in stat_lines: # Each line has following format: # attribute_name Rest of line is value for attribute_name # Note that some attributes may have no value after their name. attr, _sep, value = line.rstrip().partition(' ') if not attr: attr = line.rstrip() data[attr] = value return stats.Stats(**data)
def testKeyboardInterruptHandling(self): """Test that KeyboardInterrupts during upload aren't logged. This must use the parallel library so that exceptions are converted into BackgroundFailures as they are in a real run. """ self.PatchObject(stats.StatsUploader, '_Upload', side_effect=KeyboardInterrupt()) with cros_test_lib.LoggingCapturer() as logs: with stats.UploadContext() as queue: queue.put([stats.Stats()]) self.AssertLogsContain(logs, stats.UNCAUGHT_UPLOAD_ERROR, inverted=True)
def testConditionsMet(self): stat = stats.Stats(username='******', host='build42-m2.golo.chromium.org') self.assertTrue(stats.StatsUploader._UploadConditionsMet(stat))
def testIt(self): """Test normal stats creation, exercising default functionality.""" cmd_stat = stats.Stats() self.VerifyStats(cmd_stat)
def setUp(self): self.module_mock = StatsModuleMock() self.StartPatcher(self.module_mock) self.cmd_stats = stats.Stats(host='test.golo.chromium.org', username='******')
def testConditionsNotMet2(self): stat = stats.Stats(username='******', host='typewriter.noname.com') self.assertFalse(stats.StatsUploader._UploadConditionsMet(stat))
def testConditionsMet2(self): stat = stats.Stats(username='******', host='typewriter.mtv.corp.google.com') self.assertTrue(stats.StatsUploader._UploadConditionsMet(stat))