Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
d5e9e665
Commit
d5e9e665
authored
7 years ago
by
Douglas Hall
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #16230 from edx/douglashall/hotfix_10_13_2017
Fix get_enterprise_customer api cache key.
parents
17d93360
5033aad3
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
openedx/features/enterprise_support/api.py
+1
-0
1 addition, 0 deletions
openedx/features/enterprise_support/api.py
openedx/features/enterprise_support/tests/test_api.py
+14
-7
14 additions, 7 deletions
openedx/features/enterprise_support/tests/test_api.py
with
15 additions
and
7 deletions
openedx/features/enterprise_support/api.py
+
1
−
0
View file @
d5e9e665
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
openedx/features/enterprise_support/tests/test_api.py
+
14
−
7
View file @
d5e9e665
...
...
@@ -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 v
erify that enterprise customer data is cached properly for
#
the
enterprise api client.
#
V
erify 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
'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment