Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
masipcat committed Dec 21, 2018
1 parent 9be9d11 commit ec561f9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
1 change: 1 addition & 0 deletions guillotina/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ def __getattr__(self, name):
name
)
if value is not _marker:
self.__setattr__(name, value)
return value
raise AttributeError(name)

Expand Down
12 changes: 4 additions & 8 deletions guillotina/tests/test_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ def test_base_object():
)
async def update_default_dict(context, request):
context.images['new-key'] = 'value'
assert len(context.images) == 1
request._txn.register(context)
assert len(context.images) == 0 # wat?


@configure.service(
Expand All @@ -180,7 +180,7 @@ class ICustomContentType(interfaces.IItem):
key_type=schema.TextLine(),
value_type=schema.TextLine(),
required=False,
default={}
defaultFactory=dict
)


Expand Down Expand Up @@ -209,19 +209,15 @@ async def test_fail_to_add_key_val_dict(container_requester):

resp, status = await requester('GET', '/db/guillotina/test')
assert status == 200

# Should return {'new-key': 'value'}
assert resp['images'] == {}
assert resp['images'] == {'new-key': 'value'}

# Try using 'POST' instead of 'PATCH'
_, status = await requester('POST', '/db/guillotina/test/@update-dict')
assert status == 200

resp, status = await requester('GET', '/db/guillotina/test')
assert status == 200

# Should return {'new-key': 'value'}
assert resp['images'] == {}
assert resp['images'] == {'new-key': 'value'}


async def test_overwrite_dict_works(container_requester):
Expand Down

0 comments on commit ec561f9

Please sign in to comment.