forked from openedx/edx-platform
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #838 from appsembler/omar/trial-fixes
trial workflow fixes
- Loading branch information
Showing
8 changed files
with
60 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,10 @@ | |
from mock import patch | ||
|
||
from django.urls import reverse | ||
from openedx.core.djangoapps.appsembler.sites.utils import make_amc_admin | ||
from rest_framework import status | ||
from rest_framework.test import APITestCase | ||
from edx_rest_framework_extensions.auth.session.authentication import SessionAuthenticationAllowInactiveUser | ||
|
||
from openedx.core.djangolib.testing.utils import skip_unless_lms | ||
from openedx.core.djangoapps.appsembler.multi_tenant_emails.tests.test_utils import ( | ||
|
@@ -47,7 +49,7 @@ def test_find_username(self): | |
create_org_user(red_org, email=email, username=username) | ||
|
||
response = self.get_username(email, red_org.name) | ||
assert response.status_code == status.HTTP_200_OK, response.content | ||
assert response.status_code == status.HTTP_200_OK, response.content.decode('utf-8') | ||
assert response.json()['username'] == username | ||
|
||
def test_organization_separation(self): | ||
|
@@ -64,11 +66,11 @@ def test_organization_separation(self): | |
pass | ||
|
||
response = self.get_username(email, blue_org.name) | ||
assert response.status_code == status.HTTP_404_NOT_FOUND, response.content # Should keep sites separated | ||
assert response.status_code == status.HTTP_404_NOT_FOUND, response.content.decode('utf-8') # Should keep sites separated | ||
|
||
blue_user = create_org_user(blue_org, email=email) | ||
response = self.get_username(email, blue_org.name) | ||
assert response.status_code == status.HTTP_200_OK, response.content | ||
assert response.status_code == status.HTTP_200_OK, response.content.decode('utf-8') | ||
assert response.json()['username'] == blue_user.username | ||
|
||
def test_not_found(self): | ||
|
@@ -79,4 +81,37 @@ def test_not_found(self): | |
pass | ||
|
||
response = self.get_username('[email protected]', red_org.name) | ||
assert response.status_code == status.HTTP_404_NOT_FOUND, response.content | ||
assert response.status_code == status.HTTP_404_NOT_FOUND, response.content.decode('utf-8') | ||
|
||
|
||
@skip_unless_lms | ||
@patch( | ||
'openedx.core.djangoapps.appsembler.sites.api.SiteViewSet.authentication_classes', | ||
[SessionAuthenticationAllowInactiveUser] | ||
) | ||
class TestSiteViewSet(APITestCase): | ||
""" | ||
Tests for the SiteViewSet AMC API. | ||
""" | ||
def setUp(self): | ||
super(TestSiteViewSet, self).setUp() | ||
self.url = reverse('site-list') | ||
self.color = 'red' | ||
with with_organization_context(site_color=self.color) as red_org: | ||
self.red_org = red_org | ||
self.admin = create_org_user( | ||
organization=red_org, | ||
is_amc_admin=True, | ||
email='[email protected]', | ||
username=self.color, | ||
password=self.color | ||
) | ||
|
||
def test_list_sites(self): | ||
with with_organization_context(site_color=self.color): | ||
assert self.client.login(username=self.admin.username, password=self.color) | ||
response = self.client.get( | ||
self.url, | ||
) | ||
content = response.content.decode('utf-8') | ||
assert response.status_code == status.HTTP_200_OK, content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters