示例#1
0
    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')
示例#2
0
    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": ["*****@*****.**"]})
示例#4
0
    def testInequality(self):
        ownership0 = histogram.Ownership(['*****@*****.**'], 'foo')
        ownership1 = histogram.Ownership(['*****@*****.**'], 'bar')

        self.assertNotEqual(ownership0, ownership1)
示例#5
0
    def testComponent(self):
        ownership = histogram.Ownership([])
        self.assertIsNone(ownership.component)

        ownership = histogram.Ownership([], 'fooBar')
        self.assertEqual(ownership.component, 'fooBar')
示例#6
0
    def testEmails(self):
        ownership = histogram.Ownership([])
        self.assertEqual(ownership.emails, [])

        ownership = histogram.Ownership(['*****@*****.**'])
        self.assertEqual(ownership.emails, ['*****@*****.**'])
示例#7
0
 def testInitRequiredComponentAsStr(self):
     with self.assertRaises(TypeError):
         _ = histogram.Ownership([], ['foo'])
示例#8
0
 def testInitEmailsDefaultValue(self):
     owner_empty_emails = histogram.Ownership(None)
     self.assertEqual(owner_empty_emails.emails, [])
     self.assertIsNone(owner_empty_emails.component)
示例#9
0
 def testInitRequiresEmailsAsIterable(self):
     with self.assertRaises(TypeError):
         _ = histogram.Ownership(123)