def test_app_keychange(): # This test has to happen last, because once the app key is changed, # there is no more logging in from other tests. app = App("testkey",session="sync") result = app.update(name="My Test App") assert not "access_token" in result result = app.update(access_token=True) with pytest.raises(HeedyException): app.read() assert result["access_token"]!="testkey" newapp = App(result["access_token"],url=app.session.url) assert newapp.name == "My Test App"
def test_appschema(): a = App("testkey") with pytest.raises(Exception): a.settings = {"lol": 12} a.settings_schema = {"lol": {"type": "number", "default": 42}} assert a.settings["lol"] == 42 a.settings = {"lol": 12} assert a.settings["lol"] == 12 with pytest.raises(Exception): a.settings = {"lol": "hi"} with pytest.raises(Exception): a.settings = {"lol": 24, "hee": 1} with pytest.raises(Exception): a.settings_schema = {"lol": {"type": "string", "default": "hi"}} a.update( settings={"lol": "hi"}, settings_schema={"lol": { "type": "string", "default": "hello" }}, ) assert a.settings["lol"] == "hi" a.settings_schema = {"lol": {"type": "string"}, "li": {"type": "number"}} with pytest.raises(Exception): a.settings_schema = { "lol": { "type": "string" }, "li": { "type": "number" }, "required": ["li"], }