Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add populatedb admin creation test
Krzysztof Wolski41c6a71e2a9e
diff --git a/tests/test_core.py b/tests/test_core.pyindex 105aac6442..dd1caabe0f 100644--- a/tests/test_core.py+++ b/tests/test_core.py@@ -2,7 +2,8 @@ import pytestfrom mock import Mockfrom saleor.core.utils import (- Country, get_country_by_ip, get_currency_for_country)+ Country, get_country_by_ip, get_currency_for_country, create_superuser)+from saleor.userprofile.models import User@pytest.mark.parametrize('ip_data, expected_country', [@@ -26,3 +27,22 @@ def test_get_country_by_ip(ip_data, expected_country, monkeypatch):def test_get_currency_for_country(country, expected_currency, monkeypatch):currency = get_currency_for_country(country)assert currency == expected_currency+++def test_create_superuser(db, client):+ credentials = {'email': '[email protected]', 'password': 'admin'}+ # 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+ # Test duplicating+ create_superuser(credentials)+ assert User.objects.all().count() == 1+ # Test logging in+ response = client.post('/account/login/',+ {'login': credentials['email'],+ 'password': credentials['password']},+ follow=True)+ assert response.context['request'].user == admin