예제 #1
0
 def test_created_with_timestamp(self):
     yesterday = timezone.now() - timedelta(days=1)
     metric = MetricFactory.create(name='my-metric')
     obj = api.record('my-metric', 23, timestamp=yesterday)
     assert obj.pk is not None
     assert metric.record_set.count() == 1
     assert obj.timestamp == yesterday
예제 #2
0
    def test_created_with_timestamp_invalid_format(self):
        yesterday = 'yesterday'
        MetricFactory.create(name='my-metric')

        with pytest.raises(ValidationError):
            api.record('my-metric', 23, timestamp=yesterday)
예제 #3
0
 def test_invalid_value(self):
     MetricFactory.create(name='my-metric')
     with pytest.raises(InvalidValueException):
         api.record('my-metric', 'foo')
예제 #4
0
 def test_created(self):
     metric = MetricFactory.create(name='my-metric')
     obj = api.record('my-metric', 23)
     assert obj.pk is not None
     assert metric.record_set.count() == 1
예제 #5
0
 def test_invalid_metric(self):
     with pytest.raises(MetricNotFoundException):
         api.record('my-metric', 0)