Skip to content

Commit

Permalink
Merge branch 'master' into knguyen/version-bump
Browse files Browse the repository at this point in the history
  • Loading branch information
katrinan029 authored Jul 8, 2024
2 parents c5a295a + 9146ab2 commit 0e6353f
Showing 1 changed file with 0 additions and 33 deletions.
33 changes: 0 additions & 33 deletions lms/djangoapps/commerce/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,39 +134,6 @@ def setUp(self):
self.user = UserFactory()
self.base_url = get_ecommerce_api_base_url()

@httpretty.activate
def test_tracking_context(self):
"""
Ensure the tracking context is set up in the api client correctly and automatically.
"""
with freeze_time('2015-7-2'):
# fake an E-Commerce API request.
httpretty.register_uri(
httpretty.POST,
f"{settings.ECOMMERCE_API_URL.strip('/')}/baskets/1/",
status=200, body='{}',
adding_headers={'Content-Type': JSON}
)

mock_tracker = mock.Mock()
mock_tracker.resolve_context = mock.Mock(return_value={'ip': '127.0.0.1'})
with mock.patch('openedx.core.djangoapps.commerce.utils.tracker.get_tracker', return_value=mock_tracker):
api_url = urljoin(f"{self.base_url}/", "baskets/1/")
get_ecommerce_api_client(self.user).post(api_url)

# Verify the JWT includes the tracking context for the user
actual_header = httpretty.last_request().headers['Authorization']

claims = {
'tracking_context': {
'lms_user_id': self.user.id,
'lms_ip': '127.0.0.1',
}
}
expected_jwt = create_jwt_for_user(self.user, additional_claims=claims, scopes=self.SCOPES)
expected_header = f'JWT {expected_jwt}'
assert actual_header == expected_header

@httpretty.activate
def test_client_unicode(self):
"""
Expand Down

0 comments on commit 0e6353f

Please sign in to comment.