class CommentFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = Comment

    contact = factory.SubFactory(ContactFactory)
    message = factory.Faker('text')
    user = factory.LazyAttribute(lambda x: create_user())
Exemplo n.º 2
0
def test_api_token_auth(client):
    user = create_user()
    username = getattr(user, user.USERNAME_FIELD)
    password = get_random_string()
    user.set_password(password)
    user.save()

    res = client.post('/api-token-auth/', data={
        'username': username, 'password': password})

    assert res.status_code == status.HTTP_200_OK
    assert 'token' in res.data
Exemplo n.º 3
0
def api_client():
    user = create_user()
    client = APIClient()
    client.force_login(user)
    client.user = user
    return client