Bump utils to 40.2.1

Brings in:
- re-usable `SerialisedModel`
- speed improvements to processing CSVs against email templates

I chose not to rename `JSONModel` or `ModelList` to keep the diff nice
and small.
This commit is contained in:
Chris Hill-Scott
2020-07-03 14:07:40 +01:00
parent 98eb3c61f6
commit c4458efa21
4 changed files with 19 additions and 29 deletions

View File

@@ -30,14 +30,17 @@ def test_prefers_property_to_dict():
))
def test_model_raises_for_unknown_attributes(json_response):
model = JSONModel(json_response)
class Custom(JSONModel):
ALLOWED_PROPERTIES = set()
model = Custom(json_response)
assert model.ALLOWED_PROPERTIES == set()
with pytest.raises(AttributeError) as e:
model.foo
assert str(e.value) == (
"'JSONModel' object has no attribute 'foo' and 'foo' is not a "
"'Custom' object has no attribute 'foo' and 'foo' is not a "
"field in the underlying JSON"
)
@@ -60,6 +63,7 @@ def test_model_raises_keyerror_if_item_missing_from_dict():
def test_model_doesnt_swallow_attribute_errors(json_response):
class Custom(JSONModel):
ALLOWED_PROPERTIES = set()
@property
def foo(self):
raise AttributeError('Something has gone wrong')