From 4c7d987ea283ebf9835cc08682a85012292dec4c Mon Sep 17 00:00:00 2001 From: Tim McCormack Date: Mon, 8 Jul 2024 14:31:34 -0400 Subject: [PATCH] test: Delete flaky test DeprecatedRestApiClientTest::test_tracking_context (#35094) Deleted according to flaky test process: https://2u-internal.atlassian.net/wiki/spaces/TE/pages/12812492/Flaky+Test+Process Flaky test ticket: https://2u-internal.atlassian.net/browse/CR-6899 Failed multiple times with this error, but not consistently: ``` FAILED lms/djangoapps/commerce/tests/__init__.py::DeprecatedRestApiClientTest::test_tracking_context - requests.exceptions.ConnectionError: HTTPSConnectionPool(host='ecommerce.example.com', port=443): Max retries exceeded with url: /api/v2/baskets/1/ (Caused by NewConnectionError(': Failed to establish a new connection: [Errno -2] Name or service not known')) ``` Note that there is another test class with a name differing by only one letter earlier in this file, `DeprecatedRestApiClientTests` (plural), with a method with the same name. That one hasn't been failing. --- lms/djangoapps/commerce/tests/__init__.py | 33 ----------------------- 1 file changed, 33 deletions(-) diff --git a/lms/djangoapps/commerce/tests/__init__.py b/lms/djangoapps/commerce/tests/__init__.py index f96852a74cc5..e2acd14f32e7 100644 --- a/lms/djangoapps/commerce/tests/__init__.py +++ b/lms/djangoapps/commerce/tests/__init__.py @@ -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): """