def testAsDict(self): sample_emails = ['*****@*****.**'] ownership_no_component = histogram.Ownership(sample_emails) ownership_dict_no_component = ownership_no_component.AsDict() sample_emails.append('*****@*****.**') ownership_with_component = histogram.Ownership(sample_emails, 'fooBar') self.assertEqual(ownership_dict_no_component['emails'], ['*****@*****.**']) self.assertNotIn('component', ownership_dict_no_component) self.assertEqual(ownership_with_component.AsDict()['component'], 'fooBar')
def GetOwnership(self): """Returns an Ownership Diagnostic containing the benchmark's information. Returns: Diagnostic with the benchmark's owners' e-mails and component name """ return histogram.Ownership(decorators.GetEmails(self), decorators.GetComponent(self))
def testAsDictInfo(self): sample_emails = ["*****@*****.**"] ownership_no_component = histogram.Ownership(sample_emails) ownership_dict_no_comp = {} ownership_no_component._AsDictInto(ownership_dict_no_comp) sample_emails.append("*****@*****.**") ownership_with_component = histogram.Ownership(sample_emails, "fooBar") ownership_dict_with_comp = {} ownership_with_component._AsDictInto(ownership_dict_with_comp) self.assertDeepEqual(ownership_dict_with_comp, {"emails": sample_emails, "component": "fooBar"}) self.assertDeepEqual(ownership_dict_no_comp, {"emails": ["*****@*****.**"]})
def testInequality(self): ownership0 = histogram.Ownership(['*****@*****.**'], 'foo') ownership1 = histogram.Ownership(['*****@*****.**'], 'bar') self.assertNotEqual(ownership0, ownership1)
def testComponent(self): ownership = histogram.Ownership([]) self.assertIsNone(ownership.component) ownership = histogram.Ownership([], 'fooBar') self.assertEqual(ownership.component, 'fooBar')
def testEmails(self): ownership = histogram.Ownership([]) self.assertEqual(ownership.emails, []) ownership = histogram.Ownership(['*****@*****.**']) self.assertEqual(ownership.emails, ['*****@*****.**'])
def testInitRequiredComponentAsStr(self): with self.assertRaises(TypeError): _ = histogram.Ownership([], ['foo'])
def testInitEmailsDefaultValue(self): owner_empty_emails = histogram.Ownership(None) self.assertEqual(owner_empty_emails.emails, []) self.assertIsNone(owner_empty_emails.component)
def testInitRequiresEmailsAsIterable(self): with self.assertRaises(TypeError): _ = histogram.Ownership(123)