Skip to content

Commit 88ac91e

Browse files
authored
feat: adding sync to note.update (and small wording updates) (#304)
1 parent caf7df4 commit 88ac91e

4 files changed

Lines changed: 36 additions & 2 deletions

File tree

card.temp.rsp.notecard.api.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
],
1515
"properties": {
1616
"calibration": {
17-
"description": "The calibration differential of the Notecard's onboard sensor.",
17+
"description": "The calibration differential, in degrees centigrade, applied to the Notecard's onboard temperature sensor. This per-device offset is added to the raw sensor reading to produce `value`.",
1818
"type": "number"
1919
},
2020
"humidity": {

note.update.req.notecard.api.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
"description": "A base64-encoded binary payload. A Note must have either a `body` or `payload`, and can have both.",
3131
"type": "string"
3232
},
33+
"sync": {
34+
"description": "Set to `true` to sync the Notefile immediately after updating the Note. Only the specified Notefile is guaranteed to sync.",
35+
"type": "boolean"
36+
},
3337
"verify": {
3438
"description": "If set to `true` and using a templated Notefile, the Notefile will be written to flash immediately, rather than being cached in RAM and written to flash later.",
3539
"type": "boolean"
@@ -107,6 +111,11 @@
107111
"title": "Update with Command",
108112
"description": "Update a Note using command syntax (no response expected).",
109113
"json": "{\"cmd\": \"note.update\", \"file\": \"cache.db\", \"note\": \"temp-data\", \"body\": {\"status\": \"updated\"}}"
114+
},
115+
{
116+
"title": "Update and Sync",
117+
"description": "Update a Note and trigger an immediate sync of the Notefile.",
118+
"json": "{\"req\": \"note.update\", \"file\": \"my-settings.db\", \"note\": \"measurements\", \"body\": {\"interval\": 60}, \"sync\": true}"
110119
}
111120
]
112121
}

ntn.gps.req.notecard.api.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"type": "boolean"
2020
},
2121
"on": {
22-
"description": "When `true`, a Starnote will use the GPS/GNSS location from its paired Notecard, instead of its own GPS/GNSS location.",
22+
"description": "When `true`, a Starnote will use the location known to its paired Notecard, instead of the Starnote's own GPS/GNSS module.",
2323
"type": "boolean"
2424
},
2525
"req": {

tests/test_note_update_req.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,17 @@ def test_valid_req_with_verify(schema):
4141
}
4242
jsonschema.validate(instance=instance, schema=schema)
4343

44+
def test_valid_req_with_sync(schema):
45+
"""Tests a valid request with sync parameter."""
46+
instance = {
47+
"req": "note.update",
48+
"file": "my-settings.db",
49+
"note": "measurements",
50+
"body": {"interval": 60},
51+
"sync": True
52+
}
53+
jsonschema.validate(instance=instance, schema=schema)
54+
4455
def test_valid_api_reference_example(schema):
4556
"""Tests the exact example from API reference."""
4657
instance = {
@@ -215,6 +226,20 @@ def test_verify_invalid_type_integer(schema):
215226
jsonschema.validate(instance=instance, schema=schema)
216227
assert "1 is not of type 'boolean'" in str(excinfo.value)
217228

229+
def test_sync_invalid_type_string(schema):
230+
"""Tests invalid string type for sync."""
231+
instance = {"req": "note.update", "file": "data.db", "note": "test", "body": {"data": "test"}, "sync": "true"}
232+
with pytest.raises(jsonschema.ValidationError) as excinfo:
233+
jsonschema.validate(instance=instance, schema=schema)
234+
assert "'true' is not of type 'boolean'" in str(excinfo.value)
235+
236+
def test_sync_invalid_type_integer(schema):
237+
"""Tests invalid integer type for sync."""
238+
instance = {"req": "note.update", "file": "data.db", "note": "test", "body": {"data": "test"}, "sync": 1}
239+
with pytest.raises(jsonschema.ValidationError) as excinfo:
240+
jsonschema.validate(instance=instance, schema=schema)
241+
assert "1 is not of type 'boolean'" in str(excinfo.value)
242+
218243
def test_invalid_additional_property(schema):
219244
"""Tests invalid request with additional property."""
220245
instance = {"req": "note.update", "file": "data.db", "note": "test", "body": {"data": "test"}, "extra": "not allowed"}

0 commit comments

Comments
 (0)