예제 #1
0
def test_create_superuser(db, client, media_root):
    credentials = {"email": "*****@*****.**", "password": "******"}
    # Test admin creation
    assert User.objects.all().count() == 0
    create_superuser(credentials)
    assert User.objects.all().count() == 1
    admin = User.objects.all().first()
    assert admin.is_superuser
    assert not admin.avatar
    # Test duplicating
    create_superuser(credentials)
    assert User.objects.all().count() == 1
예제 #2
0
def test_create_superuser(db, client, media_root):
    credentials = {"email": "*****@*****.**", "password": "******"}
    # Test admin creation
    assert User.objects.all().count() == 0
    create_superuser(credentials)
    assert User.objects.all().count() == 1
    admin = User.objects.all().first()
    assert admin.is_superuser
    assert admin.avatar
    # Test duplicating
    create_superuser(credentials)
    assert User.objects.all().count() == 1
    # Test logging in
    response = client.post(
        reverse("account:login"),
        {"username": credentials["email"], "password": credentials["password"]},
        follow=True,
    )
    assert response.context["request"].user == admin