add notification test

This commit is contained in:
Colin Goutte 2021-09-27 16:39:40 +02:00
parent baee17b37f
commit e421f644f4
1 changed files with 30 additions and 0 deletions

View File

@ -112,6 +112,36 @@ def test_historique():
assert perte_supervision[-1] == f"{data['date']} test_historique error absent"
def test_onchange_notification():
id_sonde = "masonde_notif"
histo = {"identifiant": id_sonde, "nom": "Test notification"}
assert client.post("/sonde/", json=histo).ok
data = testutils.probe_sample_body(
channel_name="test_historique", channel_id=0, status="ok"
)
response = client.post(f"/sonde/{id_sonde}/", json=data)
assert response.ok
jresp = response.json()
assert jresp["notify"]
assert jresp["notify"]["targets"]
assert jresp["notify"]["changes"]
assert jresp["notify"]["status"]
assert len(jresp["notify"]) == 1
data = testutils.probe_sample_body(
channel_name="test_historique", channel_id=0, status="ok"
)
response = client.post(f"/sonde/{id_sonde}/", json=data)
assert response.ok
jresp = response.json()
assert not jresp["notify"]
class CodeCoverageTestCase(TestCase):
""" Get covergage to 100% """