def test_wrong_attributes_doesnt_create_and_returns_error(self):
orm_person = ORMPerson.objects.create(is_email_confirmed=True)
orm_auth_token = ORMAuthToken.objects.create(person_id=orm_person.id)
auth_headers = {'HTTP_AUTHORIZATION': 'Token {}'.format(orm_auth_token.access_token), }
client = Client()
response = client.post(reverse('experiences'), {'title': '', 'description': 'Some description'}, **auth_headers)
assert not ORMExperience.objects.filter(title='', description='Some description').exists()
body = json.loads(response.content)
assert body == {
'error': {
'source': 'title',
'code': 'wrong_size',
'message': 'Title must be between 1 and 30 chars'
}
}
评论列表
文章目录