Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
julianajlk committed Feb 5, 2021
1 parent 67f4de8 commit dc4a20c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 2 additions & 0 deletions common/djangoapps/course_modes/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def test_expiration_timezone(self):
'mode_slug': 'verified',
'mode_display_name': 'verified',
'min_price': 10,
"price": 10.00,
'currency': 'usd',
'_expiration_datetime_0': expiration.date(), # due to django admin datetime widget passing as separate vals
'_expiration_datetime_1': expiration.time(),
Expand Down Expand Up @@ -208,6 +209,7 @@ def _admin_form(self, mode, upgrade_deadline=None):
"_expiration_datetime": upgrade_deadline,
"currency": "usd",
"min_price": 10,
"price": 10.00,
}, instance=course_mode)

def _set_form_verification_deadline(self, form, deadline):
Expand Down
18 changes: 10 additions & 8 deletions common/djangoapps/course_modes/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def create_mode(
mode_slug,
mode_name,
min_price=0,
price=0.00,
suggested_prices='',
currency='usd',
expiration_datetime=None,
Expand All @@ -70,7 +71,7 @@ def create_mode(

def test_save(self):
""" Verify currency is always lowercase. """
cm, __ = self.create_mode('honor', 'honor', 0, '', 'USD')
cm, __ = self.create_mode('honor', 'honor', 0, 0.00, '', 'USD')
self.assertEqual(cm.currency, 'usd')

cm.currency = 'GHS'
Expand All @@ -92,7 +93,7 @@ def test_nodes_for_course_single(self):

self.create_mode('verified', 'Verified Certificate', 10)
modes = CourseMode.modes_for_course(self.course_key)
mode = Mode(u'verified', u'Verified Certificate', 10, '', 'usd', None, None, None, None)
mode = Mode(u'verified', u'Verified Certificate', 10, 10.00, '', 'usd', None, None, None, None)
self.assertEqual([mode], modes)

modes_dict = CourseMode.modes_for_course_dict(self.course_key)
Expand All @@ -104,8 +105,8 @@ def test_modes_for_course_multiple(self):
"""
Finding the modes when there's multiple modes
"""
mode1 = Mode(u'honor', u'Honor Code Certificate', 0, '', 'usd', None, None, None, None)
mode2 = Mode(u'verified', u'Verified Certificate', 10, '', 'usd', None, None, None, None)
mode1 = Mode(u'honor', u'Honor Code Certificate', 0, 0.00, '', 'usd', None, None, None, None)
mode2 = Mode(u'verified', u'Verified Certificate', 10, 10.00, '', 'usd', None, None, None, None)
set_modes = [mode1, mode2]
for mode in set_modes:
self.create_mode(mode.slug, mode.name, mode.min_price, mode.suggested_prices)
Expand All @@ -124,9 +125,9 @@ def test_min_course_price_for_currency(self):
self.assertEqual(0, CourseMode.min_course_price_for_currency(self.course_key, 'usd'))

# create some modes
mode1 = Mode(u'honor', u'Honor Code Certificate', 10, '', 'usd', None, None, None, None)
mode2 = Mode(u'verified', u'Verified Certificate', 20, '', 'usd', None, None, None, None)
mode3 = Mode(u'honor', u'Honor Code Certificate', 80, '', 'cny', None, None, None, None)
mode1 = Mode(u'honor', u'Honor Code Certificate', 10, 10.00, '', 'usd', None, None, None, None)
mode2 = Mode(u'verified', u'Verified Certificate', 20, 20.00, '', 'usd', None, None, None, None)
mode3 = Mode(u'honor', u'Honor Code Certificate', 80, 80.00, '', 'cny', None, None, None, None)
set_modes = [mode1, mode2, mode3]
for mode in set_modes:
self.create_mode(mode.slug, mode.name, mode.min_price, mode.suggested_prices, mode.currency)
Expand All @@ -141,7 +142,7 @@ def test_modes_for_course_expired(self):
modes = CourseMode.modes_for_course(self.course_key)
self.assertEqual([CourseMode.DEFAULT_MODE], modes)

mode1 = Mode(u'honor', u'Honor Code Certificate', 0, '', 'usd', None, None, None, None)
mode1 = Mode(u'honor', u'Honor Code Certificate', 0, 0.00, '', 'usd', None, None, None, None)
self.create_mode(mode1.slug, mode1.name, mode1.min_price, mode1.suggested_prices)
modes = CourseMode.modes_for_course(self.course_key)
self.assertEqual([mode1], modes)
Expand All @@ -153,6 +154,7 @@ def test_modes_for_course_expired(self):
u'verified',
u'Verified Certificate',
10,
10.00,
'',
'usd',
expiration_datetime,
Expand Down

0 comments on commit dc4a20c

Please sign in to comment.