Skip to content

Commit 470c1b9

Browse files
committed
Issue #25: Test coverage improved. Minor version increased.
1 parent 472ec74 commit 470c1b9

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

domain_models/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Domain models."""
22

3-
VERSION = '0.0.8'
3+
VERSION = '0.0.9'

domain_models/models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ def get(self, field_name, default=None):
192192
converted to right type value.
193193
If the field does not exist, `AttributeError` is raised as well.
194194
195-
:param field_name: string
196-
:param default: object
195+
:type field_name: string
196+
:type default: object
197197
"""
198198
try:
199199
field = self.__class__.__fields__[field_name]
@@ -215,7 +215,7 @@ def get_data(self):
215215
def set_data(self, data):
216216
"""Set dictionary data to model.
217217
218-
:param data: dict
218+
:type data: dict
219219
"""
220220
for name, field in six.iteritems(self.__class__.__fields__):
221221
field.init_model(self, data.get(name))

tests/test_context_view.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,31 @@ class WrongContext(views.ContextView):
145145
__include__ = (Profile.birth_date,)
146146
__exclude__ = (Profile.business_address,)
147147

148+
with self.assertRaises(TypeError):
149+
class WrongContext(views.ContextView):
150+
__model_cls__ = Profile
151+
__include__ = [Profile.name]
152+
153+
with self.assertRaises(TypeError):
154+
class WrongContext(views.ContextView):
155+
__model_cls__ = Profile
156+
__exclude__ = [Profile.name]
157+
158+
with self.assertRaises(AttributeError):
159+
class WrongContext(views.ContextView):
160+
__model_cls__ = Profile
161+
__exclude__ = (Profile.id, Profile.name)
162+
163+
@property
164+
def name(self):
165+
return "Any name"
166+
167+
with self.assertRaises(AttributeError):
168+
class WrongContext(views.ContextView):
169+
__model_cls__ = Profile
170+
__include__ = (Profile.wrong_field,)
171+
__exclude__ = (Profile.one_more_wrong_field,)
172+
148173
def test_context_view(self):
149174
public_profile = ProfilePublicContext(self.profile)
150175
private_profile = ProfilePrivateContext(self.profile)

0 commit comments

Comments
 (0)