Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
8173182c
Commit
8173182c
authored
Jun 20, 2017
by
Afzal Wali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Taking the url change behind the waffle switch. Required for the Learner-1146
Learner-1111
parent
f318661d
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
35 additions
and
4 deletions
+35
-4
common/djangoapps/course_modes/tests/test_views.py
+4
-0
openedx/core/djangoapps/api_admin/tests/test_views.py
+16
-2
openedx/core/djangoapps/catalog/management/commands/cache_programs.py
+0
-1
openedx/core/djangoapps/catalog/models.py
+5
-1
openedx/core/djangoapps/catalog/tests/test_models.py
+4
-0
openedx/core/lib/tests/test_edx_api_utils.py
+6
-0
No files found.
common/djangoapps/course_modes/tests/test_views.py
View file @
8173182c
...
...
@@ -9,6 +9,7 @@ from datetime import datetime
import
ddt
import
freezegun
import
httpretty
import
waffle
from
django.conf
import
settings
from
django.core.urlresolvers
import
reverse
from
mock
import
patch
...
...
@@ -157,6 +158,7 @@ class CourseModeViewTest(CatalogIntegrationMixin, UrlResetMixin, ModuleStoreTest
self
.
assertEquals
(
response
.
status_code
,
200
)
@httpretty.activate
@waffle.testutils.override_switch
(
"populate-multitenant-programs"
,
True
)
def
test_enterprise_learner_context
(
self
):
"""
Test: Track selection page should show the enterprise context message if user belongs to the Enterprise.
...
...
@@ -177,6 +179,7 @@ class CourseModeViewTest(CatalogIntegrationMixin, UrlResetMixin, ModuleStoreTest
)
@httpretty.activate
@waffle.testutils.override_switch
(
"populate-multitenant-programs"
,
True
)
def
test_enterprise_learner_context_with_multiple_organizations
(
self
):
"""
Test: Track selection page should show the enterprise context message with multiple organization names
...
...
@@ -209,6 +212,7 @@ class CourseModeViewTest(CatalogIntegrationMixin, UrlResetMixin, ModuleStoreTest
)
@httpretty.activate
@waffle.testutils.override_switch
(
"populate-multitenant-programs"
,
True
)
def
test_enterprise_learner_context_audit_disabled
(
self
):
"""
Track selection page should hide the audit choice by default in an Enterprise Customer/Learner context
...
...
openedx/core/djangoapps/api_admin/tests/test_views.py
View file @
8173182c
...
...
@@ -4,15 +4,18 @@ import json
import
ddt
import
httpretty
import
waffle
from
django.conf
import
settings
from
django.core.urlresolvers
import
reverse
from
django.test
import
TestCase
from
django.test.utils
import
override_settings
from
oauth2_provider.models
import
get_application_model
from
openedx.core.djangoapps.api_admin.models
import
ApiAccess
Request
,
ApiAccessConfig
from
openedx.core.djangoapps.api_admin.models
import
ApiAccess
Config
,
ApiAccessRequest
from
openedx.core.djangoapps.api_admin.tests.factories
import
(
ApiAccessRequestFactory
,
ApplicationFactory
,
CatalogFactory
ApiAccessRequestFactory
,
ApplicationFactory
,
CatalogFactory
)
from
openedx.core.djangoapps.api_admin.tests.utils
import
VALID_DATA
from
openedx.core.djangolib.testing.utils
import
skip_unless_lms
...
...
@@ -263,6 +266,7 @@ class CatalogSearchViewTest(CatalogTest):
self
.
assertEqual
(
response
.
status_code
,
200
)
@httpretty.activate
@waffle.testutils.override_switch
(
"populate-multitenant-programs"
,
True
)
def
test_post
(
self
):
catalog_user
=
UserFactory
()
self
.
mock_catalog_endpoint
({
'results'
:
[]})
...
...
@@ -285,6 +289,7 @@ class CatalogListViewTest(CatalogTest):
self
.
url
=
reverse
(
'api_admin:catalog-list'
,
kwargs
=
{
'username'
:
self
.
catalog_user
.
username
})
@httpretty.activate
@waffle.testutils.override_switch
(
"populate-multitenant-programs"
,
True
)
def
test_get
(
self
):
catalog
=
CatalogFactory
(
viewers
=
[
self
.
catalog_user
.
username
])
self
.
mock_catalog_endpoint
({
'results'
:
[
catalog
.
attributes
]})
...
...
@@ -293,6 +298,7 @@ class CatalogListViewTest(CatalogTest):
self
.
assertIn
(
catalog
.
name
,
response
.
content
.
decode
(
'utf-8'
))
@httpretty.activate
@waffle.testutils.override_switch
(
"populate-multitenant-programs"
,
True
)
def
test_get_no_catalogs
(
self
):
"""Verify that the view works when no catalogs are set up."""
self
.
mock_catalog_endpoint
({},
status_code
=
404
)
...
...
@@ -300,6 +306,7 @@ class CatalogListViewTest(CatalogTest):
self
.
assertEqual
(
response
.
status_code
,
200
)
@httpretty.activate
@waffle.testutils.override_switch
(
"populate-multitenant-programs"
,
True
)
def
test_post
(
self
):
catalog_data
=
{
'name'
:
'test-catalog'
,
...
...
@@ -314,6 +321,7 @@ class CatalogListViewTest(CatalogTest):
self
.
assertRedirects
(
response
,
reverse
(
'api_admin:catalog-edit'
,
kwargs
=
{
'catalog_id'
:
catalog_id
}))
@httpretty.activate
@waffle.testutils.override_switch
(
"populate-multitenant-programs"
,
True
)
def
test_post_invalid
(
self
):
catalog
=
CatalogFactory
(
viewers
=
[
self
.
catalog_user
.
username
])
self
.
mock_catalog_endpoint
({
'results'
:
[
catalog
.
attributes
]})
...
...
@@ -339,6 +347,7 @@ class CatalogEditViewTest(CatalogTest):
self
.
url
=
reverse
(
'api_admin:catalog-edit'
,
kwargs
=
{
'catalog_id'
:
self
.
catalog
.
id
})
@httpretty.activate
@waffle.testutils.override_switch
(
"populate-multitenant-programs"
,
True
)
def
test_get
(
self
):
self
.
mock_catalog_endpoint
(
self
.
catalog
.
attributes
,
catalog_id
=
self
.
catalog
.
id
)
response
=
self
.
client
.
get
(
self
.
url
)
...
...
@@ -346,6 +355,7 @@ class CatalogEditViewTest(CatalogTest):
self
.
assertIn
(
self
.
catalog
.
name
,
response
.
content
.
decode
(
'utf-8'
))
@httpretty.activate
@waffle.testutils.override_switch
(
"populate-multitenant-programs"
,
True
)
def
test_delete
(
self
):
self
.
mock_catalog_endpoint
(
self
.
catalog
.
attributes
,
...
...
@@ -362,6 +372,7 @@ class CatalogEditViewTest(CatalogTest):
self
.
assertEqual
(
len
(
httpretty
.
httpretty
.
latest_requests
),
1
)
@httpretty.activate
@waffle.testutils.override_switch
(
"populate-multitenant-programs"
,
True
)
def
test_edit
(
self
):
self
.
mock_catalog_endpoint
(
self
.
catalog
.
attributes
,
method
=
httpretty
.
PATCH
,
catalog_id
=
self
.
catalog
.
id
)
new_attributes
=
dict
(
self
.
catalog
.
attributes
,
**
{
'delete-catalog'
:
'off'
,
'name'
:
'changed'
})
...
...
@@ -370,6 +381,7 @@ class CatalogEditViewTest(CatalogTest):
self
.
assertRedirects
(
response
,
reverse
(
'api_admin:catalog-edit'
,
kwargs
=
{
'catalog_id'
:
self
.
catalog
.
id
}))
@httpretty.activate
@waffle.testutils.override_switch
(
"populate-multitenant-programs"
,
True
)
def
test_edit_invalid
(
self
):
self
.
mock_catalog_endpoint
(
self
.
catalog
.
attributes
,
catalog_id
=
self
.
catalog
.
id
)
new_attributes
=
dict
(
self
.
catalog
.
attributes
,
**
{
'delete-catalog'
:
'off'
,
'name'
:
''
})
...
...
@@ -389,6 +401,7 @@ class CatalogPreviewViewTest(CatalogTest):
self
.
url
=
reverse
(
'api_admin:catalog-preview'
)
@httpretty.activate
@waffle.testutils.override_switch
(
"populate-multitenant-programs"
,
True
)
def
test_get
(
self
):
data
=
{
'count'
:
1
,
'results'
:
[
'test data'
],
'next'
:
None
,
'prev'
:
None
}
httpretty
.
register_uri
(
...
...
@@ -401,6 +414,7 @@ class CatalogPreviewViewTest(CatalogTest):
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
json
.
loads
(
response
.
content
),
data
)
@waffle.testutils.override_switch
(
"populate-multitenant-programs"
,
True
)
def
test_get_without_query
(
self
):
response
=
self
.
client
.
get
(
self
.
url
)
self
.
assertEqual
(
response
.
status_code
,
200
)
...
...
openedx/core/djangoapps/catalog/management/commands/cache_programs.py
View file @
8173182c
...
...
@@ -9,7 +9,6 @@ from openedx.core.djangoapps.catalog.cache import PROGRAM_CACHE_KEY_TPL, PROGRAM
from
openedx.core.djangoapps.catalog.models
import
CatalogIntegration
from
openedx.core.djangoapps.catalog.utils
import
create_catalog_api_client
logger
=
logging
.
getLogger
(
__name__
)
User
=
get_user_model
()
# pylint: disable=invalid-name
...
...
openedx/core/djangoapps/catalog/models.py
View file @
8173182c
"""Models governing integration with the catalog service."""
import
waffle
from
config_models.models
import
ConfigurationModel
from
django.conf
import
settings
from
django.contrib.auth
import
get_user_model
...
...
@@ -54,7 +55,10 @@ class CatalogIntegration(ConfigurationModel):
def
get_internal_api_url
(
self
):
""" Returns the internal Catalog API URL associated with the request's site. """
return
helpers
.
get_value
(
'COURSE_CATALOG_API_URL'
,
settings
.
COURSE_CATALOG_API_URL
)
if
waffle
.
switch_is_active
(
"populate-multitenant-programs"
):
return
helpers
.
get_value
(
'COURSE_CATALOG_API_URL'
,
settings
.
COURSE_CATALOG_API_URL
)
else
:
return
self
.
internal_api_url
def
get_service_user
(
self
):
# NOTE: We load the user model here to avoid issues at startup time that result from the hacks
...
...
openedx/core/djangoapps/catalog/tests/test_models.py
View file @
8173182c
"""Catalog model tests."""
import
ddt
import
mock
import
waffle
from
django.test
import
TestCase
,
override_settings
from
openedx.core.djangoapps.catalog.tests
import
mixins
...
...
@@ -31,6 +32,7 @@ class TestCatalogIntegration(mixins.CatalogIntegrationMixin, TestCase):
self
.
assertEqual
(
catalog_integration
.
is_cache_enabled
,
is_cache_enabled
)
@override_settings
(
COURSE_CATALOG_API_URL
=
COURSE_CATALOG_API_URL
)
@waffle.testutils.override_switch
(
"populate-multitenant-programs"
,
True
)
def
test_get_internal_api_url
(
self
,
_mock_cache
):
""" Requests made without a microsite should return the value from settings. """
self
.
assert_get_internal_api_url_value
(
COURSE_CATALOG_API_URL
)
...
...
@@ -39,6 +41,7 @@ class TestCatalogIntegration(mixins.CatalogIntegrationMixin, TestCase):
@override_settings
(
COURSE_CATALOG_API_URL
=
COURSE_CATALOG_API_URL
)
@with_site_configuration
(
configuration
=
{})
@waffle.testutils.override_switch
(
"populate-multitenant-programs"
,
True
)
def
test_get_internal_api_url_without_microsite_override
(
self
,
_mock_cache
):
""" Requests made to microsites that do not have COURSE_CATALOG_API_URL overridden should
return the default value from settings. """
...
...
@@ -46,6 +49,7 @@ class TestCatalogIntegration(mixins.CatalogIntegrationMixin, TestCase):
@override_settings
(
COURSE_CATALOG_API_URL
=
COURSE_CATALOG_API_URL
)
@with_site_configuration
(
configuration
=
{
'COURSE_CATALOG_API_URL'
:
'foo'
})
@waffle.testutils.override_switch
(
"populate-multitenant-programs"
,
True
)
def
test_get_internal_api_url_with_microsite_override
(
self
,
_mock_cache
):
""" If a microsite has overridden the value of COURSE_CATALOG_API_URL, the overridden
value should be returned. """
...
...
openedx/core/lib/tests/test_edx_api_utils.py
View file @
8173182c
...
...
@@ -4,6 +4,7 @@ import json
import
httpretty
import
mock
import
waffle
from
django.core.cache
import
cache
from
django.test.utils
import
override_settings
from
edx_oauth2_provider.tests.factories
import
ClientFactory
...
...
@@ -73,6 +74,7 @@ class TestGetEdxApiData(CatalogIntegrationMixin, CredentialsApiConfigMixin, Cach
# Verify the API was actually hit (not the cache)
self
.
_assert_num_requests
(
1
)
@waffle.testutils.override_switch
(
"populate-multitenant-programs"
,
True
)
def
test_get_paginated_data
(
self
):
"""Verify that paginated data can be retrieved."""
catalog_integration
=
self
.
create_catalog_integration
()
...
...
@@ -100,6 +102,7 @@ class TestGetEdxApiData(CatalogIntegrationMixin, CredentialsApiConfigMixin, Cach
self
.
_assert_num_requests
(
len
(
expected_collection
))
@waffle.testutils.override_switch
(
"populate-multitenant-programs"
,
True
)
def
test_get_paginated_data_do_not_traverse_pagination
(
self
):
"""
Verify that pagination is not traversed if traverse_pagination=False is passed as argument.
...
...
@@ -128,6 +131,7 @@ class TestGetEdxApiData(CatalogIntegrationMixin, CredentialsApiConfigMixin, Cach
self
.
assertEqual
(
actual_collection
,
expected_response
)
self
.
_assert_num_requests
(
1
)
@waffle.testutils.override_switch
(
"populate-multitenant-programs"
,
True
)
def
test_get_specific_resource
(
self
):
"""Verify that a specific resource can be retrieved."""
catalog_integration
=
self
.
create_catalog_integration
()
...
...
@@ -151,6 +155,7 @@ class TestGetEdxApiData(CatalogIntegrationMixin, CredentialsApiConfigMixin, Cach
self
.
_assert_num_requests
(
1
)
@waffle.testutils.override_switch
(
"populate-multitenant-programs"
,
True
)
def
test_get_specific_resource_with_falsey_id
(
self
):
"""
Verify that a specific resource can be retrieved, and pagination parsing is
...
...
@@ -180,6 +185,7 @@ class TestGetEdxApiData(CatalogIntegrationMixin, CredentialsApiConfigMixin, Cach
self
.
_assert_num_requests
(
1
)
@waffle.testutils.override_switch
(
"populate-multitenant-programs"
,
True
)
def
test_cache_utilization
(
self
):
"""Verify that when enabled, the cache is used."""
catalog_integration
=
self
.
create_catalog_integration
(
cache_ttl
=
5
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment