@@ -77,7 +77,6 @@ def __init__(self, load_error_blocks, course_id=None):
7777def get_dummy_course (
7878 start ,
7979 announcement = None ,
80- is_new = None ,
8180 advertised_start = None ,
8281 end = None ,
8382 certs = 'end' ,
@@ -89,7 +88,6 @@ def get_dummy_course(
8988 def to_attrb (n , v ):
9089 return '' if v is None else f'{ n } ="{ v } "' .lower ()
9190
92- is_new = to_attrb ('is_new' , is_new )
9391 announcement = to_attrb ('announcement' , announcement )
9492 advertised_start = to_attrb ('advertised_start' , advertised_start )
9593 end = to_attrb ('end' , end )
@@ -99,7 +97,6 @@ def to_attrb(n, v):
9997 graceperiod="1 day" url_name="test"
10098 start="{start}"
10199 {announcement}
102- {is_new}
103100 {advertised_start}
104101 {end}
105102 certificates_display_behavior="{certs}">
@@ -111,7 +108,6 @@ def to_attrb(n, v):
111108 org = ORG ,
112109 course = COURSE ,
113110 start = start ,
114- is_new = is_new ,
115111 announcement = announcement ,
116112 advertised_start = advertised_start ,
117113 end = end ,
@@ -176,112 +172,6 @@ def test_course_end(self):
176172 summary = xmodule .course_block .CourseSummary (test_course .id , end = bad_end_date )
177173 assert summary .has_ended ()
178174
179-
180- @ddt .ddt
181- class IsNewCourseTestCase (unittest .TestCase ):
182- """Make sure the property is_new works on courses"""
183-
184- def setUp (self ):
185- super ().setUp ()
186-
187- # Needed for test_is_newish
188- datetime_patcher = patch .object (
189- xmodule .course_metadata_utils , 'datetime' ,
190- Mock (wraps = datetime )
191- )
192- mocked_datetime = datetime_patcher .start ()
193- mocked_datetime .now .return_value = NOW
194- self .addCleanup (datetime_patcher .stop )
195-
196- @patch ('xmodule.course_metadata_utils.datetime.now' )
197- def test_sorting_score (self , gmtime_mock ):
198- gmtime_mock .return_value = NOW
199-
200- day1 = '2012-01-01T12:00'
201- day2 = '2012-01-02T12:00'
202-
203- dates = [
204- # Announce date takes priority over actual start
205- # and courses announced on a later date are newer
206- # than courses announced for an earlier date
207- ((day1 , day2 , None ), (day1 , day1 , None ), self .assertLess ),
208- ((day1 , day1 , None ), (day2 , day1 , None ), self .assertEqual ),
209-
210- # Announce dates take priority over advertised starts
211- ((day1 , day2 , day1 ), (day1 , day1 , day1 ), self .assertLess ),
212- ((day1 , day1 , day2 ), (day2 , day1 , day2 ), self .assertEqual ),
213-
214- # Later start == newer course
215- ((day2 , None , None ), (day1 , None , None ), self .assertLess ),
216- ((day1 , None , None ), (day1 , None , None ), self .assertEqual ),
217-
218- # Non-parseable advertised starts are ignored in preference to actual starts
219- ((day2 , None , "Spring" ), (day1 , None , "Fall" ), self .assertLess ),
220- ((day1 , None , "Spring" ), (day1 , None , "Fall" ), self .assertEqual ),
221-
222- # Partially parsable advertised starts should take priority over start dates
223- ((day2 , None , "October 2013" ), (day2 , None , "October 2012" ), self .assertLess ),
224- ((day2 , None , "October 2013" ), (day1 , None , "October 2013" ), self .assertEqual ),
225-
226- # Parseable advertised starts take priority over start dates
227- ((day1 , None , day2 ), (day1 , None , day1 ), self .assertLess ),
228- ((day2 , None , day2 ), (day1 , None , day2 ), self .assertEqual ),
229- ]
230-
231- for a , b , assertion in dates :
232- a_score = get_dummy_course (start = a [0 ], announcement = a [1 ], advertised_start = a [2 ]).sorting_score
233- b_score = get_dummy_course (start = b [0 ], announcement = b [1 ], advertised_start = b [2 ]).sorting_score
234- print (f"Comparing { a } to { b } " )
235- assertion (a_score , b_score )
236-
237- start_advertised_settings = [
238- # start, advertised, result, is_still_default, date_time_result
239- ('2012-12-02T12:00' , None , 'Dec 02, 2012' , False , 'Dec 02, 2012 at 12:00 UTC' ),
240- ('2012-12-02T12:00' , '2011-11-01T12:00' , 'Nov 01, 2011' , False , 'Nov 01, 2011 at 12:00 UTC' ),
241- ('2012-12-02T12:00' , 'Spring 2012' , 'Spring 2012' , False , 'Spring 2012' ),
242- ('2012-12-02T12:00' , 'November, 2011' , 'November, 2011' , False , 'November, 2011' ),
243- (xmodule .course_block .CourseFields .start .default , None , 'TBD' , True , 'TBD' ),
244- (xmodule .course_block .CourseFields .start .default , 'January 2014' , 'January 2014' , False , 'January 2014' ),
245- ]
246-
247- def test_start_date_is_default (self ):
248- for s in self .start_advertised_settings :
249- d = get_dummy_course (start = s [0 ], advertised_start = s [1 ])
250- assert d .start_date_is_still_default == s [3 ]
251-
252- def test_display_organization (self ):
253- block = get_dummy_course (start = '2012-12-02T12:00' , is_new = True )
254- assert block .location .org != block .display_org_with_default
255- assert block .display_org_with_default == f'{ ORG } _display'
256-
257- def test_display_coursenumber (self ):
258- block = get_dummy_course (start = '2012-12-02T12:00' , is_new = True )
259- assert block .location .course != block .display_number_with_default
260- assert block .display_number_with_default == f'{ COURSE } _display'
261-
262- def test_is_newish (self ):
263- block = get_dummy_course (start = '2012-12-02T12:00' , is_new = True )
264- assert block .is_newish is True
265-
266- block = get_dummy_course (start = '2013-02-02T12:00' , is_new = False )
267- assert block .is_newish is False
268-
269- block = get_dummy_course (start = '2013-02-02T12:00' , is_new = True )
270- assert block .is_newish is True
271-
272- block = get_dummy_course (start = '2013-01-15T12:00' )
273- assert block .is_newish is True
274-
275- block = get_dummy_course (start = '2013-03-01T12:00' )
276- assert block .is_newish is True
277-
278- block = get_dummy_course (start = '2012-10-15T12:00' )
279- assert block .is_newish is False
280-
281- block = get_dummy_course (start = '2012-12-31T12:00' )
282- assert block .is_newish is True
283-
284-
285175class DiscussionTopicsTestCase (unittest .TestCase ):
286176
287177 def test_default_discussion_topics (self ):
0 commit comments