Rename Sud's Download/Upload to Save/Load throughout
Renames everywhere the concept appears: Sud.download()/upload() -> save()/load(), the 'Download'/'Upload' websocket messages -> 'Save'/'Load', the brewpi_gui menu actions, handlers and sud_download_path -> sud_save_path, and the demo script. Behavior is unchanged - this is naming only, from the client's perspective (save to / load from a local file) rather than the server's.
This commit is contained in:
+11
-11
@@ -5,7 +5,7 @@ from pathlib import Path
|
||||
|
||||
from components.sud import Sud, SudState
|
||||
|
||||
# Console-only walkthrough of Sud.download()/upload() (no plot - there's no
|
||||
# Console-only walkthrough of Sud.save()/load() (no plot - there's no
|
||||
# numeric data here, just JSON plumbing). Runs against a scratch copy of a
|
||||
# real sud.json so sude/sud_0010.json itself is never touched.
|
||||
|
||||
@@ -17,29 +17,29 @@ if __name__ == '__main__':
|
||||
sud = Sud(str(path))
|
||||
print(f"Loaded '{sud.name}', {len(sud.schedule)} steps")
|
||||
|
||||
doc = sud.download()
|
||||
doc = sud.save()
|
||||
assert doc['Name'] == sud.name
|
||||
print("download() returned the on-disk document")
|
||||
print("save() returned the on-disk document")
|
||||
|
||||
sud.state = SudState.RAMPING
|
||||
assert sud.upload(doc) is False
|
||||
print("upload() refused while RAMPING")
|
||||
assert sud.load(doc) is False
|
||||
print("load() refused while RAMPING")
|
||||
|
||||
sud.state = SudState.IDLE
|
||||
doc['Name'] = 'Sud-Renamed'
|
||||
doc['steps'][0]['descr'] = 'Edited step'
|
||||
assert sud.upload(doc) is True
|
||||
assert sud.load(doc) is True
|
||||
assert sud.name == 'Sud-Renamed'
|
||||
assert sud.schedule[0]['descr'] == 'Edited step'
|
||||
assert sud.state == SudState.IDLE
|
||||
print("upload() applied the edit and reset to IDLE")
|
||||
print("load() applied the edit and reset to IDLE")
|
||||
|
||||
on_disk = json.loads(path.read_text())
|
||||
assert on_disk['Name'] == 'Sud-Renamed'
|
||||
print("upload() persisted the edit to disk")
|
||||
print("load() persisted the edit to disk")
|
||||
|
||||
assert sud.upload({'Name': 'broken'}) is False
|
||||
assert sud.load({'Name': 'broken'}) is False
|
||||
assert sud.name == 'Sud-Renamed'
|
||||
print("upload() rejected malformed data, left schedule untouched")
|
||||
print("load() rejected malformed data, left schedule untouched")
|
||||
|
||||
print("All sud upload/download checks passed")
|
||||
print("All sud save/load checks passed")
|
||||
Reference in New Issue
Block a user