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
5033aad3
Commit
5033aad3
authored
Oct 12, 2017
by
Douglas Hall
Committed by
Douglas Hall
Oct 13, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix get_enterprise_customer api cache key.
ENT-704
parent
17d93360
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
7 deletions
+15
-7
openedx/features/enterprise_support/api.py
+1
-0
openedx/features/enterprise_support/tests/test_api.py
+14
-7
No files found.
openedx/features/enterprise_support/api.py
View file @
5033aad3
...
...
@@ -268,6 +268,7 @@ class EnterpriseApiServiceClient(EnterpriseServiceClientMixin, EnterpriseApiClie
"""
cache_key
=
get_cache_key
(
resource
=
'enterprise-customer'
,
resource_id
=
uuid
,
username
=
settings
.
ENTERPRISE_SERVICE_WORKER_USERNAME
,
)
enterprise_customer
=
cache
.
get
(
cache_key
)
...
...
openedx/features/enterprise_support/tests/test_api.py
View file @
5033aad3
...
...
@@ -88,17 +88,17 @@ class TestEnterpriseApi(EnterpriseServiceMockMixin, CacheIsolationTestCase):
# pylint: disable=protected-access
self
.
assertEqual
(
enterprise_api_service_client
.
client
.
_store
[
'session'
]
.
auth
.
token
,
'test-token'
)
def
_assert_get_enterprise_customer
(
self
,
api_client
):
def
_assert_get_enterprise_customer
(
self
,
api_client
,
enterprise_api_data_for_mock
):
"""
DRY method to verify caching for get enterprise customer method.
"""
dummy_enterprise_api_data
=
{
'name'
:
'dummy-enterprise-customer'
,
'uuid'
:
'enterprise-uuid'
}
cache_key
=
get_cache_key
(
resource
=
'enterprise-customer'
,
resource_id
=
enterprise_api_data_for_mock
[
'uuid'
],
username
=
settings
.
ENTERPRISE_SERVICE_WORKER_USERNAME
,
)
self
.
mock_get_enterprise_customer
(
'enterprise-uuid'
,
dummy_enterprise_api_data
,
200
)
self
.
_assert_get_enterprise_customer_with_cache
(
api_client
,
dummy_enterprise_api_data
,
cache_key
)
self
.
mock_get_enterprise_customer
(
enterprise_api_data_for_mock
[
'uuid'
],
enterprise_api_data_for_mock
,
200
)
self
.
_assert_get_enterprise_customer_with_cache
(
api_client
,
enterprise_api_data_for_mock
,
cache_key
)
def
_assert_get_enterprise_customer_with_cache
(
self
,
api_client
,
enterprise_customer_data
,
cache_key
):
"""
...
...
@@ -121,10 +121,17 @@ class TestEnterpriseApi(EnterpriseServiceMockMixin, CacheIsolationTestCase):
"""
self
.
_assert_api_service_client
(
EnterpriseApiServiceClient
,
mock_jwt_builder
)
#
Now verify that enterprise customer data is cached properly for
#
the
enterprise api client.
#
Verify that enterprise customer data is cached properly for the
# enterprise api client.
enterprise_api_client
=
EnterpriseApiServiceClient
()
self
.
_assert_get_enterprise_customer
(
enterprise_api_client
)
enterprise_api_data_for_mock_1
=
{
'name'
:
'dummy-enterprise-customer-1'
,
'uuid'
:
'enterprise-uuid-1'
}
self
.
_assert_get_enterprise_customer
(
enterprise_api_client
,
enterprise_api_data_for_mock_1
)
# Now try to get enterprise customer for another enterprise and verify
# that enterprise api client returns data according to the provided
# enterprise UUID.
enterprise_api_data_for_mock_2
=
{
'name'
:
'dummy-enterprise-customer-2'
,
'uuid'
:
'enterprise-uuid-2'
}
self
.
_assert_get_enterprise_customer
(
enterprise_api_client
,
enterprise_api_data_for_mock_2
)
@httpretty.activate
@mock.patch
(
'openedx.features.enterprise_support.api.JwtBuilder'
)
...
...
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