def test_create_experience_creates_and_returns_experience(self):
orm_person = ORMPerson.objects.create(username='usr.nm', 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': 'Experience title', 'description': 'Some description'},
**auth_headers)
body = json.loads(response.content)
created_experience = ORMExperience.objects.get(id=body['id'], title='Experience title',
description='Some description')
assert created_experience is not None
assert body == {
'id': str(created_experience.id),
'title': 'Experience title',
'description': 'Some description',
'picture': None,
'author_id': orm_person.id,
'author_username': orm_person.username
}
评论列表
文章目录