Skip to content

Commit

Permalink
Merge branch 'master' into demo
Browse files Browse the repository at this point in the history
  • Loading branch information
maarcingebala committed Jan 5, 2018
2 parents f334882 + 8181c8d commit 055ab1c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 3 additions & 1 deletion saleor/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from django.contrib.staticfiles.views import serve
from django.views.i18n import JavaScriptCatalog
from graphene_django.views import GraphQLView
from impersonate.views import impersonate, stop_impersonate

from .cart.urls import urlpatterns as cart_urls
from .checkout.urls import urlpatterns as checkout_urls
Expand All @@ -30,7 +31,8 @@
url(r'^dashboard/',
include((dashboard_urls, 'dashboard'), namespace='dashboard')),
url(r'^graphql', GraphQLView.as_view(graphiql=settings.DEBUG)),
url(r'^impersonate/', include('impersonate.urls')),
url(r'^impersonate/stop/$', stop_impersonate, name='impersonate-stop'),
url(r'^impersonate/(?P<uid>\d+)/$', impersonate, name='impersonate-start'),
url(r'^jsi18n/$', JavaScriptCatalog.as_view(), name='javascript-catalog'),
url(r'^order/', include((order_urls, 'order'), namespace='order')),
url(r'^products/',
Expand Down
18 changes: 18 additions & 0 deletions tests/test_impersonation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import pytest
from django.core.urlresolvers import reverse
from django.urls.exceptions import NoReverseMatch

from saleor.userprofile.models import User

Expand All @@ -14,3 +16,19 @@ def test_staff_with_permission_can_impersonate(
assert response.context['user'] == customer_user
assert response.context['user'].is_impersonate
assert response.context['request'].impersonator == staff_user

response = staff_client.get(reverse('impersonate-stop'), follow=True)
assert response.context['user'] == staff_user
assert response.context['user'].is_impersonate is False


def test_impersonate_list_search_urls_are_disabled():
with pytest.raises(NoReverseMatch):
reverse('impersonate-list')
with pytest.raises(NoReverseMatch):
reverse('impersonate-search')


def test_impersonate_start_url_uid_arg_is_number():
with pytest.raises(NoReverseMatch):
reverse('impersonate', args=['string'])

0 comments on commit 055ab1c

Please sign in to comment.