示例#1
0
 def setUp(self):
     self.__metric_source = domain.MetricSource()
     self.__subject = domain.Product(
         name='Product',
         metric_source_ids={self.__metric_source: 'http://url'})
     self.__project = domain.Project(
         metric_sources={domain.MetricSource: self.__metric_source})
     self.__metric = MetricSourceAgeMetricUnderTest(self.__subject,
                                                    project=self.__project)
 def test_datetime(self):
     """ Test that the datetime is now by default. """
     self.assertTrue(
         datetime.datetime.now() -
         domain.MetricSource().datetime() < datetime.timedelta(seconds=10))
 def test_given_name(self):
     """ Test that the name can be given as a parameter. """
     self.assertEqual('ABC', domain.MetricSource(name='ABC').name())
 def test_metric_source_url(self):
     """ Test that the metric source id is returned as url. """
     self.assertEqual(
         ['http://url/to/subject'],
         domain.MetricSource().metric_source_urls('http://url/to/subject'))
 def test_default_name(self):
     """ Test the default name of a metric source. """
     self.assertEqual('Unknown metric source', domain.MetricSource().name())