diff --git a/tests/test_papi.py b/tests/test_papi.py index 98ca4fe..f14cbc0 100644 --- a/tests/test_papi.py +++ b/tests/test_papi.py @@ -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% """