Beispiel #1
0
def test_metric_invalid_step():
    with pytest.raises(ValueError) as e:
        Metric('key', 100, step='One')
    assert "Step can only be an integer >= 0" in str(e.value)

    with pytest.raises(ValueError) as e:
        Metric('key', 100, step=-1)
    assert "Step can only be an integer >= 0" in str(e.value)

    with pytest.raises(ValueError) as e:
        Metric('key', 100, step=2.3)
    assert "Step can only be an integer >= 0" in str(e.value)
Beispiel #2
0
def test_metric_invalid_changing_step():
    metric = Metric('key', 100, step=1)
    with pytest.raises(ValueError) as e:
        metric.step = 'One'
    assert "Step can only be an integer >= 0" in str(e.value)
Beispiel #3
0
def test_metric_valid_step():
    metric = Metric('key', 100, step=1)
    assert 1 == metric.step
    metric.step = 0
    assert 0 == metric.step
Beispiel #4
0
def test_metric_invalid_reassign_value():
    metric = Metric('key', 100)
    with pytest.raises(ValueError) as e:
        metric.value = 'value'
    assert "Value of a metric can only be a number" in str(e.value)
Beispiel #5
0
def test_metric_invalid_reassign_key():
    metric = Metric('key', 100)
    with pytest.raises(ValueError) as e:
        metric.key = 1999
    assert "Key of a metric can only be a string" in str(e.value)
Beispiel #6
0
def test_metric_invalid_value():
    with pytest.raises(ValueError) as e:
        Metric('key', 'value')
    assert "Value of a metric can only be a number" in str(e.value)
Beispiel #7
0
def test_metric_invalid_key():
    with pytest.raises(ValueError) as e:
        Metric(100, 100)
    assert "Key of a metric can only be a string" in str(e.value)
Beispiel #8
0
def test_metric_creates_object():
    metric = Metric('key', 100)
    assert 'key' == metric.key
    assert 100 == metric.value
    assert None is metric.step