Skip to content

Commit

Permalink
Add test to verify that put_metric sets non-given values to None (rep…
Browse files Browse the repository at this point in the history
…laces the instance).
  • Loading branch information
dougthor42 committed Feb 20, 2019
1 parent ebbf62b commit c50bfa1
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,29 @@ def test_api_put_metric(client, populated_db):
assert d['new_value']['units'] == "lines"


def test_api_put_metric_sets_other_values_to_none(client, populated_db):
name = "with_everything"

original = client.get("/api/v1/metric/{}".format(name))
assert original.status_code == 200
original = original.get_json()
assert original['units'] == 'percent'
assert original['upper_limit'] == 100.0
assert original['lower_limit'] == 20.0

data = {"name": name}
rv = client.put("/api/v1/metric/{}".format(name), json=data)
assert rv.status_code == 200

new = client.get("/api/v1/metric/{}".format(name))
assert new.status_code == 200
new = new.get_json()

assert new['units'] is None
assert new['upper_limit'] is None
assert new['lower_limit'] is None


def test_api_put_metric_not_found(client, populated_db):
name = "missing"
data = {
Expand Down

0 comments on commit c50bfa1

Please sign in to comment.