Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Update login logic in tests

Mira Szewczyk455dfbc47fec
diff --git a/tests/test_cart.py b/tests/test_cart.py
index 58bf2f6818..6181f9e558 100644
--- a/tests/test_cart.py
+++ b/tests/test_cart.py
@@ -230,8 +230,8 @@ def test_find_and_assign_anonymous_cart(
client.cookies[utils.COOKIE_NAME] = value
# Anonymous logs in
response = client.post(
- '/account/login',
- {'login': customer_user.email, 'password': 'password'})
+ reverse('account_login'),
+ {'username': customer_user.email, 'password': 'password'}, follow=True)
assert response.context['user'] == customer_user
# User should have only one cart, the same as he had previously in
# anonymous session
@@ -244,8 +244,8 @@ def test_find_and_assign_anonymous_cart(
def test_login_without_a_cart(customer_user, client):
assert utils.COOKIE_NAME not in client.cookies
response = client.post(
- '/account/login',
- {'login': customer_user.email, 'password': 'password'})
+ reverse('account_login'),
+ {'username': customer_user.email, 'password': 'password'}, follow=True)
assert response.context['user'] == customer_user
authenticated_user_carts = customer_user.carts.filter(
status=CartStatus.OPEN)
@@ -256,8 +256,8 @@ def test_login_with_incorrect_cookie_token(customer_user, client):
value = signing.get_cookie_signer(salt=utils.COOKIE_NAME).sign('incorrect')
client.cookies[utils.COOKIE_NAME] = value
response = client.post(
- '/account/login',
- {'login': customer_user.email, 'password': 'password'})
+ reverse('account_login'),
+ {'username': customer_user.email, 'password': 'password'}, follow=True)
assert response.context['user'] == customer_user
authenticated_user_carts = customer_user.carts.filter(
status=CartStatus.OPEN)
diff --git a/tests/test_core.py b/tests/test_core.py
index 743607119d..c1a85b3474 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -60,7 +60,7 @@ def test_create_superuser(db, client):
assert User.objects.all().count() == 1
# Test logging in
response = client.post('/account/login/',
- {'login': credentials['email'],
+ {'username': credentials['email'],
'password': credentials['password']},
follow=True)
assert response.context['request'].user == admin