Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
fix: CI checks are working/passing now
Browse files Browse the repository at this point in the history
pin django-oscar to 3.2,
removed migrations,
replace depreciated assertDictContainsSubset method with python code
  • Loading branch information
Muhammad Faraz Maqsood committed May 31, 2024
1 parent 0190f4d commit ce381be
Show file tree
Hide file tree
Showing 19 changed files with 115 additions and 237 deletions.
6 changes: 5 additions & 1 deletion ecommerce/core/tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@


import json
import sys

import ddt
import mock
Expand Down Expand Up @@ -177,7 +178,10 @@ def test_user_details_uses_jwt(self):

# Verify the headers passed to the API were correct.
expected = {'Authorization': 'JWT {}'.format(token), }
self.assertDictContainsSubset(expected, last_request.headers)
if sys.version_info > (3, 9):
self.assertLessEqual(expected.items(), last_request.headers.items())
else:
self.assertDictContainsSubset(expected, last_request.headers)

def test_no_user_details(self):
""" Verify False is returned when there is a connection error. """
Expand Down
15 changes: 13 additions & 2 deletions ecommerce/credit/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Tests for the checkout page.
"""


import sys
from datetime import timedelta

import ddt
Expand Down Expand Up @@ -130,7 +130,18 @@ def _assert_success_checkout_page(self, sku=None):

response = self.client.get(self.path)
self.assertEqual(response.status_code, 200)
self.assertDictContainsSubset({'course': self.course}, response.context)
if sys.version_info > (3, 9):
context = {}
for i, ctx in enumerate(response.context):
if isinstance(ctx, dict):
context.update(ctx)
elif hasattr(ctx, '__iter__') and not isinstance(ctx, str):
for item in ctx:
if isinstance(item, dict):
context.update(item)
self.assertLessEqual({'course': self.course}.items(), context.items())
else:
self.assertDictContainsSubset({'course': self.course}, response.context)

self.assertContains(
response,
Expand Down
6 changes: 5 additions & 1 deletion ecommerce/enterprise/tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@


import sys
import uuid

import ddt
Expand Down Expand Up @@ -122,7 +123,10 @@ def test_post_enterprise_customer_user(self, mock_helpers, expected_return):
self.learner.username
)

self.assertDictContainsSubset(expected_return, response)
if sys.version_info > (3, 9):
self.assertLessEqual(expected_return.items(), response.items())
else:
self.assertDictContainsSubset(expected_return, response)

@responses.activate
def test_ecu_needs_consent(self):
Expand Down
18 changes: 0 additions & 18 deletions ecommerce/extensions/basket/migrations/0018_line_tax_code.py

This file was deleted.

This file was deleted.

31 changes: 25 additions & 6 deletions ecommerce/extensions/checkout/tests/test_views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@


import sys
from decimal import Decimal
from urllib import parse

Expand Down Expand Up @@ -338,7 +339,10 @@ def test_get_receipt_for_existing_order(self, mock_learner_data):
}

self.assertEqual(response.status_code, 200)
self.assertDictContainsSubset(context_data, response.context_data)
if sys.version_info > (3, 9):
self.assertEqual(response.context_data, response.context_data | context_data)
else:
self.assertDictContainsSubset(context_data, response.context_data)

@patch('ecommerce.extensions.checkout.views.fetch_enterprise_learner_data')
@responses.activate
Expand Down Expand Up @@ -371,7 +375,10 @@ def test_get_receipt_for_existing_entitlement_order(self, mock_learner_data):
}

self.assertEqual(response.status_code, 200)
self.assertDictContainsSubset(context_data, response.context_data)
if sys.version_info > (3, 9):
self.assertEqual(response.context_data, response.context_data | context_data)
else:
self.assertDictContainsSubset(context_data, response.context_data)

@patch('ecommerce.extensions.checkout.views.fetch_enterprise_learner_data')
@responses.activate
Expand All @@ -387,7 +394,10 @@ def test_get_receipt_for_existing_order_as_staff_user(self, mock_learner_data):
}

self.assertEqual(response.status_code, 200)
self.assertDictContainsSubset(context_data, response.context_data)
if sys.version_info > (3, 9):
self.assertEqual(response.context_data, response.context_data | context_data)
else:
self.assertDictContainsSubset(context_data, response.context_data)

@patch('ecommerce.extensions.checkout.views.fetch_enterprise_learner_data')
@responses.activate
Expand All @@ -400,7 +410,10 @@ def test_get_receipt_for_existing_order_user_not_owner(self, mock_learner_data):
context_data = {'order_history_url': self.site.siteconfiguration.build_lms_url('account/settings')}

self.assertEqual(response.status_code, 404)
self.assertDictContainsSubset(context_data, response.context_data)
if sys.version_info > (3, 9):
self.assertEqual(response.context_data, response.context_data | context_data)
else:
self.assertDictContainsSubset(context_data, response.context_data)

@patch('ecommerce.extensions.checkout.views.fetch_enterprise_learner_data')
@responses.activate
Expand Down Expand Up @@ -456,7 +469,10 @@ def test_dashboard_link_for_course_purchase(self, mock_learner_data):
}

self.assertEqual(response.status_code, 200)
self.assertDictContainsSubset(context_data, response.context_data)
if sys.version_info > (3, 9):
self.assertEqual(response.context_data, response.context_data | context_data)
else:
self.assertDictContainsSubset(context_data, response.context_data)

@patch('ecommerce.extensions.checkout.views.fetch_enterprise_learner_data')
@responses.activate
Expand All @@ -482,7 +498,10 @@ def test_dashboard_link_for_bundle_purchase(self, mock_learner_data):
}

self.assertEqual(response.status_code, 200)
self.assertDictContainsSubset(context_data, response.context_data)
if sys.version_info > (3, 9):
self.assertEqual(response.context_data, response.context_data | context_data)
else:
self.assertDictContainsSubset(context_data, response.context_data)

@patch('ecommerce.extensions.checkout.views.fetch_enterprise_learner_data')
@responses.activate
Expand Down
8 changes: 6 additions & 2 deletions ecommerce/extensions/fulfillment/tests/test_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import datetime
import json
import sys
import uuid
from decimal import Decimal
from urllib.parse import urlencode
Expand Down Expand Up @@ -212,7 +213,10 @@ def test_enrollment_module_fulfill(self):
'X-Forwarded-For': self.user.tracking_context['lms_ip'],
}

self.assertDictContainsSubset(expected_headers, actual_headers)
if sys.version_info > (3, 9):
self.assertLessEqual(expected_headers.items(), actual_headers.items())
else:
self.assertDictContainsSubset(expected_headers, actual_headers)
self.assertEqual(expected_body, actual_body)

@responses.activate
Expand Down Expand Up @@ -377,7 +381,7 @@ def test_revoke_product(self):
'X-Forwarded-For': self.user.tracking_context['lms_ip'],
}

self.assertDictContainsSubset(expected_headers, actual_headers)
assert expected_headers.items() <= actual_headers.items()
self.assertEqual(expected_body, actual_body)

@responses.activate
Expand Down
51 changes: 0 additions & 51 deletions ecommerce/extensions/offer/migrations/0056_auto_20240528_0754.py

This file was deleted.

64 changes: 0 additions & 64 deletions ecommerce/extensions/order/migrations/0029_auto_20240528_0754.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


import json
import sys
from decimal import Decimal
from unittest import SkipTest

Expand Down Expand Up @@ -49,7 +50,10 @@ def assert_processor_response_recorded(self, processor_name, transaction_id, res
expected = {
'requestID': transaction_id,
}
self.assertDictContainsSubset(expected, ppr.response)
if sys.version_info > (3, 9):
self.assertLessEqual(expected.items(), ppr.response.items())
else:
self.assertDictContainsSubset(expected, ppr.response)
self.assertEqual(ppr.basket, basket)

return ppr.id
Expand Down
6 changes: 5 additions & 1 deletion ecommerce/extensions/voucher/tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-


import sys
import uuid

import ddt
Expand Down Expand Up @@ -523,7 +524,10 @@ def test_generate_coupon_report_with_deleted_product(self):

__, rows = generate_coupon_report([query_coupon.attr.coupon_vouchers])
self.assert_report_first_row(rows[0], query_coupon, first_voucher)
self.assertDictContainsSubset({'Redeemed For Course ID': 'Unknown'}, rows[2])
if sys.version_info > (3, 9):
self.assertLessEqual({'Redeemed For Course ID': 'Unknown'}.items(), rows[2].items())
else:
self.assertDictContainsSubset({'Redeemed For Course ID': 'Unknown'}, rows[2])

def test_report_for_inactive_coupons(self):
""" Verify the coupon report show correct status for inactive coupons. """
Expand Down
Loading

0 comments on commit ce381be

Please sign in to comment.