Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add tests
michal69bedd9991c6
diff --git a/saleor/dashboard/customer/views.py b/saleor/dashboard/customer/views.pyindex 21f70347f0..9d14dbcd32 100644--- a/saleor/dashboard/customer/views.py+++ b/saleor/dashboard/customer/views.py@@ -47,6 +47,7 @@ def customer_promote_to_staff(request, pk):customer = get_object_or_404(User, pk=pk)if request.method == 'POST':customer.is_staff = True+ customer.save()msg = pgettext_lazy('Dashboard message','Customer %s promoted to staff member') % customerdiff --git a/saleor/registration/forms.py b/saleor/registration/forms.pyindex 49969cb8c3..57bc431675 100644--- a/saleor/registration/forms.py+++ b/saleor/registration/forms.py@@ -45,12 +45,6 @@ class SignupForm(forms.ModelForm):return user-class SetPasswordForm(django_forms.SetPasswordForm):- def __init__(self, *args, **kwargs):- super(SetPasswordForm, self).__init__(*args, **kwargs)- del self.fields['new_password2']--class PasswordSetUpForm(django_forms.PasswordResetForm):"""PasswordSetUpForm that overrides sending emails to use templated email.diff --git a/saleor/registration/views.py b/saleor/registration/views.pyindex bbc840a7b3..4f81f35d3a 100644--- a/saleor/registration/views.py+++ b/saleor/registration/views.py@@ -8,7 +8,7 @@ from django.utils.translation import ugettext_lazy as _from django.template.response import TemplateResponsefrom saleor.cart.utils import find_and_assign_anonymous_cart-from .forms import LoginForm, PasswordSetUpForm, SignupForm, SetPasswordForm+from .forms import LoginForm, PasswordSetUpForm, SignupForm@find_and_assign_anonymous_cart()diff --git a/tests/dashboard/test_customer.py b/tests/dashboard/test_customer.pynew file mode 100644index 0000000000..aa94182684--- /dev/null+++ b/tests/dashboard/test_customer.py@@ -0,0 +1,23 @@+from __future__ import unicode_literals++from django.core.urlresolvers import reverse++from saleor.userprofile.models import User+++def test_customer_promote_to_staff_with_POST(admin_client, customer_user):+ assert User.objects.filter(is_staff=True).count() == 1+ url = reverse(+ 'dashboard:customer-promote', kwargs={'pk': customer_user.pk})+ admin_client.get(url)+ assert User.objects.filter(is_staff=True).count() == 1+++def test_customer_promote_to_staff(admin_client, customer_user):+ assert User.objects.filter(is_staff=True).count() == 1+ url = reverse(+ 'dashboard:customer-promote', kwargs={'pk': customer_user.pk})+ data = {'pk': customer_user.pk}+ response = admin_client.post(url, data)+ assert User.objects.filter(is_staff=True).count() == 2+ assert response['Location'] == reverse('dashboard:staff-list')diff --git a/tests/dashboard/test_staff.py b/tests/dashboard/test_staff.pyindex 17815ed088..8758dfc993 100644--- a/tests/dashboard/test_staff.py+++ b/tests/dashboard/test_staff.py@@ -23,7 +23,7 @@ def test_staff_form_not_valid(db):def test_staff_form_create_valid(admin_client, staff_user, staff_group):- url = reverse('dashboard:staff-details', args=[staff_user.pk])+ url = reverse('dashboard:staff-details', kwargs={'pk': staff_user.pk})data = {'email': '[email protected]', 'groups': staff_group.pk}admin_client.post(url, data)staff_user = User.objects.get(pk=staff_user.pk)@@ -79,7 +79,7 @@ def test_create_staff_and_set_password(admin_client, staff_group):def test_staff_form_create_not_valid(admin_client, staff_user):- url = reverse('dashboard:staff-details', args=[staff_user.pk])+ url = reverse('dashboard:staff-details', kwargs={'pk': staff_user.pk})data = {'groups': 1}admin_client.post(url, data)staff_user = User.objects.get(pk=staff_user.pk)@@ -96,6 +96,6 @@ def test_delete_staff(admin_client, staff_user):def test_delete_staff_no_POST(admin_client, staff_user):- url = reverse('dashboard:staff-delete', args=[staff_user.pk])+ url = reverse('dashboard:staff-delete', kwargs={'pk': staff_user.pk})admin_client.get(url)assert User.objects.all().count() == 2