Skip to content

Commit 0773c8b

Browse files
committed
added exception tests
1 parent a099ecb commit 0773c8b

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

docs/rest-framework.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ customize the look up with the lookup attribute.
2929

3030
Other default attributes:
3131

32-
`partial = False`: Accept updates without all the fields.
32+
`partial = False`: Accept updates without all the input fields.
3333

3434
.. code:: python
3535

graphene_django/rest_framework/tests/test_mutation.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,20 @@ def test_model_update_mutate_and_get_payload_success():
110110
assert result.errors is None
111111
assert result.cool_name == 'New Narf'
112112

113+
@mark.django_db
114+
def test_model_invalid_update_mutate_and_get_payload_success():
115+
class InvalidModelMutation(SerializerMutation):
116+
class Meta:
117+
serializer_class = MyModelSerializer
118+
model_operations = ['update']
119+
120+
with raises(Exception) as exc:
121+
result = InvalidModelMutation.mutate_and_get_payload(None, None, **{
122+
'cool_name': 'Narf',
123+
})
124+
125+
assert '"id" required' in str(exc.value)
126+
113127
def test_mutate_and_get_payload_error():
114128

115129
class MyMutation(SerializerMutation):
@@ -124,3 +138,12 @@ def test_model_mutate_and_get_payload_error():
124138
# missing required fields
125139
result = MyModelMutation.mutate_and_get_payload(None, None, **{})
126140
assert len(result.errors) > 0
141+
142+
def test_invalid_serializer_operations():
143+
with raises(Exception) as exc:
144+
class MyModelMutation(SerializerMutation):
145+
class Meta:
146+
serializer_class = MyModelSerializer
147+
model_operations = ['Add']
148+
149+
assert 'model_operations' in str(exc.value)

0 commit comments

Comments
 (0)