def test_standalone(self): instance = Dummy() uri = "/uri/patent/usa/granted/1/" with ForceChanger(instance): instance.uri = uri assert instance.uri == uri instance.d = {"a": 1, "b": 2, "c": None} assert instance.d == {"a": 1, "b": 2, "c": None} assert instance.d["a"] == 1 instance.d = {"a": 11} assert instance.d == {"a": 11, "b": 2, "c": None} instance.d = {"b": 22} assert instance.d == {"a": 11, "b": 22, "c": None} instance.d = {} assert instance.d == {"a": 11, "b": 22, "c": None}
def test_model_getter(self): instance = Dummy() uri = "/uri/patent/usa/granted/1/" with ForceChanger(instance): instance.uri = uri assert instance.uri == uri instance.d = {"a": 1, "b": 2, "c": None} assert instance.d == {"a": 1, "b": 2, "c": None} assert instance.d["a"] == 1
def test(self): instance = Dummy() instance.d = {"a": 1, "b": 2, "c": now()} actor = Actor() with ForceChanger(instance): assert instance.data["owner"] is None instance.owner = actor assert instance.data["owner"] == actor.id instance.owner = None assert instance.data["owner"] is None instance.owner = actor assert instance.data["owner"] == actor.id
def test_check_schema(self): instance = Dummy() with self.assertRaises(AttributeError): instance.no_subfield = None with self.assertRaises(AssertionError): instance.d = {"c": 1}