Skip to content

Commit

Permalink
docs: few comments to hightlight and a test to refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
mudassir-hafeez committed Aug 19, 2024
1 parent 1f40793 commit f3c04e9
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions compliance/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def mock_cybersource_wsdl(mocked_responses, settings, service_version=SERVICE_VE
Mocks the responses to achieve a functional WSDL
"""
# in order for zeep to load the wsdl, it will load the wsdl and the accompanying xsd definitions
# Note: open() defaults to read mode ("r")
with open(f"{DATA_DIR}/CyberSourceTransaction_{service_version}.wsdl") as wsdl: # noqa: PTH123
mocked_responses.add(
mocked_responses.GET,
Expand Down
3 changes: 1 addition & 2 deletions courses/serializers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import factory
import pytest
import pytz
from django.contrib.auth.models import AnonymousUser

from cms.constants import FORMAT_ONLINE, FORMAT_OTHER
Expand Down Expand Up @@ -107,7 +106,7 @@ def test_serialize_program( # noqa: PLR0913

non_live_run = CourseRunFactory.create(
course=course1,
end_date=datetime.max.replace(tzinfo=pytz.utc),
end_date=datetime.max.replace(tzinfo=timezone.utc),
expiration_date=None,
live=False,
)
Expand Down
2 changes: 2 additions & 0 deletions courses/views_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ def test_course_view( # noqa: PLR0913
url = reverse("user-dashboard")
class_name = "enrolled"

# Note: UTF-8 is the default encoding in Python 3.
assert (
f'<a class="enroll-button {class_name}" href="{url}">'.encode() in resp.content
) is has_button
Expand Down Expand Up @@ -346,6 +347,7 @@ def test_program_view( # noqa: PLR0913
url = reverse("user-dashboard")
class_name = "enrolled"

# Note: UTF-8 is the default encoding in Python 3.
assert (
f'<a class="enroll-button {class_name}" href="{url}">'.encode() in resp.content
) is has_button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def handle(self, *args, **kwargs): # noqa: ARG002
codes = Coupon.objects.filter(enabled=True, payment=payment).all()
else:
try:
# Note: open() defaults to read mode ("r")
with open(kwargs["codefile"]) as file: # noqa: PTH123
procCodes = [line.strip() for line in file]
except Exception as e: # noqa: BLE001
Expand Down
1 change: 1 addition & 0 deletions mitxpro/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ def create_tempfile_csv(rows_iter):
writer = csv.writer(f, delimiter=",")
for row in rows_iter:
writer.writerow(row)
# Note: open() defaults to read mode ("r")
with open(f.name) as user_csv: # noqa: PTH123
return SimpleUploadedFile(
f.name, user_csv.read().encode("utf8"), content_type="application/csv"
Expand Down

0 comments on commit f3c04e9

Please sign in to comment.