Refactor
This commit is contained in:
parent
723bdb5fca
commit
8cb11722f4
12
papi/main.py
12
papi/main.py
|
@ -64,17 +64,19 @@ def post_sonde_data(idsonde: str, body: dict = Body(...)):
|
|||
present = utils.prepare(mesures_[-1])
|
||||
all_channels = sorted(set((*previous["channels"], *present["channels"])))
|
||||
|
||||
diff, notify = utils.compare(all_channels, previous, present), {}
|
||||
if diff:
|
||||
diff = utils.compare(all_channels, previous, present)
|
||||
|
||||
content = [" ".join((date, *utils.clean_state(d))) for d in diff["changements"]]
|
||||
notify["changes"] = content
|
||||
content = (
|
||||
[" ".join((date, *utils.clean_state(d))) for d in diff["changements"]]
|
||||
if diff
|
||||
else ""
|
||||
)
|
||||
|
||||
return {
|
||||
"count": len(mesures_)
|
||||
if mesures_[0] != default_sample()
|
||||
else len(mesures_) - 1,
|
||||
"notify": notify,
|
||||
"notify": content,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -126,11 +126,7 @@ def test_onchange_notification():
|
|||
jresp = response.json()
|
||||
|
||||
assert jresp["notify"]
|
||||
# assert jresp["notify"]["targets"]
|
||||
assert jresp["notify"]["changes"]
|
||||
# assert jresp["notify"]["status"]
|
||||
|
||||
assert len(jresp["notify"]) == 1
|
||||
assert jresp["notify"][0].split(" ", 1)[1] == "test_historique absent ok"
|
||||
|
||||
data = testutils.probe_sample_body(
|
||||
channel_name="test_historique", channel_id=0, status="ok"
|
||||
|
|
Loading…
Reference in New Issue