### Protocol Version Changes
* V2: Added the `visible` key to the response. Invisible items are no longer represented as having value null.
+* V2: `load` now sends changes compared to values before the load, not the whole list of config items.
before_ranges = get_ranges(config)
before_visible = get_visible(config)
- if "load" in req: # if we're loading a different sdkconfig, response should have all items in it
- before = {}
- before_ranges = {}
- before_visible = {}
+ if "load" in req: # load a new sdkconfig
+
+ if req.get("version", default_version) == 1:
+ # for V1 protocol, send all items when loading new sdkconfig.
+ # (V2+ will only send changes, same as when setting an item)
+ before = {}
+ before_ranges = {}
+ before_visible = {}
# if no new filename is supplied, use existing sdkconfig path, otherwise update the path
if req["load"] is None:
test_load_save(p, temp_sdkconfig_path)
- p.send("%s\n" % json.dumps({"version": 2, "load": temp_sdkconfig_path}))
- load_result = expect_json(p)
- print("Load result: %s" % (json.dumps(load_result)))
- assert len(load_result["values"]) > 0 # loading same file should return all config items
- assert len(load_result["ranges"]) > 0
print("Done. All passed.")
finally:
after = os.stat(temp_sdkconfig_path).st_mtime
assert after > before # something got written to disk
+ # Do a V2 load
+ load_result = send_request(p, {"version": 2, "load": temp_sdkconfig_path})
+ print("V2 Load result: %s" % (json.dumps(load_result)))
+ assert "error" not in load_result
+ assert len(load_result["values"]) == 0 # in V2, loading same file should return no config items
+ assert len(load_result["ranges"]) == 0
+
# Do a V1 load
load_result = send_request(p, {"version": 1, "load": temp_sdkconfig_path})
print("V1 Load result: %s" % (json.dumps(load_result)))