test_integration.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:abidria-api 作者: jordifierro 项目源码 文件源码
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'
                                    }
                       }
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号