Exemplo n.º 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
Exemplo n.º 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)
Exemplo n.º 3
0
 def test_invalid_value(self):
     MetricFactory.create(name='my-metric')
     with pytest.raises(InvalidValueException):
         api.record('my-metric', 'foo')
Exemplo n.º 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
Exemplo n.º 5
0
 def test_invalid_metric(self):
     with pytest.raises(MetricNotFoundException):
         api.record('my-metric', 0)