Skip to content

Commit

Permalink
fix: some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
irtazaakram committed Nov 7, 2024
1 parent 040ed3d commit 620c52e
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 7 deletions.
1 change: 0 additions & 1 deletion common/djangoapps/student/tests/test_linkedin.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ def test_linked_in_url(self, cert_mode, expected_cert_name):

self.assertEqual(actual_url, expected_url)


@ddt.data(
('honor', 'Honor+Code+Credential+for+Test+Course+%E2%98%83'),
('verified', 'Verified+Credential+for+Test+Course+%E2%98%83'),
Expand Down
5 changes: 4 additions & 1 deletion common/djangoapps/util/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ def wrapper(request, *args, **kwargs):
response = cache.get(cache_key)
if response:
# Ensure that response content is properly handled for caching
response.content = b''.join(response._container) if hasattr(response, '_container') else response.content
response.content = (
# pylint: disable=protected-access
b''.join(response._container) if hasattr(response, '_container') else response.content
)
else:
response = view_func(request, *args, **kwargs)
cache.set(cache_key, response, 60 * 3)
Expand Down
1 change: 0 additions & 1 deletion lms/djangoapps/learner_dashboard/tests/test_programs.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def assert_dict_contains_subset(self, superset, subset):
for key, value in subset.items():
assert key in superset and superset[key] == value, f"{key}: {value} not found in superset or does not match"


def test_login_required(self, mock_get_programs):
"""
Verify that login is required to access the page.
Expand Down
1 change: 0 additions & 1 deletion openedx/core/djangoapps/content_libraries/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ def assertDictContainsEntries(self, big_dict, subset_dict):
assert key in big_dict, f"Missing key: {key}"
assert big_dict[key] == value, f"Value for key {key} does not match: expected {value}, got {big_dict[key]}"


def assertOrderEqual(self, libraries_list, expected_order):
"""
Assert that the provided list of libraries match the order of expected
Expand Down
2 changes: 1 addition & 1 deletion openedx/core/djangoapps/cors_csrf/tests/test_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def _assert_cookie_sent(self, response, is_set):
"""Check that the cross-domain CSRF cookie was sent. """
if is_set:
assert self.COOKIE_NAME in response.cookies
cookie_header = response.cookies[self.COOKIE_NAME].output(header='').strip()
cookie_header = str(response.cookies[self.COOKIE_NAME])

expected = 'Set-Cookie: {name}={value}; Domain={domain};'.format(
name=self.COOKIE_NAME,
Expand Down
6 changes: 4 additions & 2 deletions openedx/core/djangoapps/crawlers/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ def is_crawler(cls, request):
if not req_user_agent or not crawler_agents:
return False

# In Python 3, req_user_agent should already be a string, so we don't need to check for bytes.
# Ensure crawler_agents are stripped of whitespace.
# Decode req_user_agent if it's bytes, so we can work with consistent string types.
if isinstance(req_user_agent, bytes):
req_user_agent = req_user_agent.decode('iso-8859-1')

crawler_agents = [crawler_agent.strip() for crawler_agent in crawler_agents]

# We perform prefix matching of the crawler agent here so that we don't
Expand Down

0 comments on commit 620c52e

Please sign in to comment.