@@ -60,24 +60,27 @@ def setUp(self):
6060 CourseOverviewFactory .create (id = self .course .id , display_name = self .course .display_name )
6161 chapter = BlockFactory .create (category = 'chapter' , parent = self .course )
6262 sequential = BlockFactory .create (category = 'sequential' , parent = chapter )
63- unit = BlockFactory .create (category = 'vertical' , parent = sequential )
64- self .regular_video_key = BlockFactory .create (category = 'video' , parent = unit ).usage_key
63+ self . unit = BlockFactory .create (category = 'vertical' , parent = sequential )
64+ self .regular_video_key = BlockFactory .create (category = 'video' , parent = self . unit ).usage_key
6565 self .downstream_video_key = BlockFactory .create (
66- category = 'video' , parent = unit , upstream = MOCK_UPSTREAM_REF , upstream_version = 123 ,
66+ category = 'video' , parent = self . unit , upstream = MOCK_UPSTREAM_REF , upstream_version = 123 ,
6767 ).usage_key
6868 self .downstream_html_key = BlockFactory .create (
69- category = 'html' , parent = unit , upstream = MOCK_HTML_UPSTREAM_REF , upstream_version = 1 ,
69+ category = 'html' , parent = self . unit , upstream = MOCK_HTML_UPSTREAM_REF , upstream_version = 1 ,
7070 ).usage_key
7171
7272 self .another_course = CourseFactory .create (display_name = "Another Course" )
7373 CourseOverviewFactory .create (id = self .another_course .id , display_name = self .another_course .display_name )
74- another_chapter = BlockFactory .create (category = 'chapter' , parent = self .another_course )
75- another_sequential = BlockFactory .create (category = 'sequential' , parent = another_chapter )
76- another_unit = BlockFactory .create (category = 'vertical' , parent = another_sequential )
74+ another_chapter = BlockFactory .create (category = "chapter" , parent = self .another_course )
75+ another_sequential = BlockFactory .create (category = "sequential" , parent = another_chapter )
76+ self .another_unit = BlockFactory .create (category = "vertical" , parent = another_sequential )
77+ self .another_video_keys = []
7778 for _ in range (3 ):
7879 # Adds 3 videos linked to the same upstream
79- BlockFactory .create (
80- category = 'video' , parent = another_unit , upstream = MOCK_UPSTREAM_REF , upstream_version = 123 ,
80+ self .another_video_keys .append (
81+ BlockFactory .create (
82+ category = "video" , parent = self .another_unit , upstream = MOCK_UPSTREAM_REF , upstream_version = 123 ,
83+ ).usage_key
8184 )
8285
8386 self .fake_video_key = self .course .id .make_usage_key ("video" , "NoSuchVideo" )
@@ -329,6 +332,7 @@ def test_200_all_upstreams(self):
329332 'created' : date_format ,
330333 'downstream_context_key' : str (self .course .id ),
331334 'downstream_usage_key' : str (self .downstream_video_key ),
335+ 'downstream_parent_usage_key' : str (self .unit .usage_key ),
332336 'id' : 1 ,
333337 'ready_to_sync' : False ,
334338 'updated' : date_format ,
@@ -342,6 +346,7 @@ def test_200_all_upstreams(self):
342346 'created' : date_format ,
343347 'downstream_context_key' : str (self .course .id ),
344348 'downstream_usage_key' : str (self .downstream_html_key ),
349+ 'downstream_parent_usage_key' : str (self .unit .usage_key ),
345350 'id' : 2 ,
346351 'ready_to_sync' : False ,
347352 'updated' : date_format ,
@@ -373,14 +378,32 @@ def test_200_downstream_context_list(self):
373378 data = response .json ()
374379 expected = [
375380 {
376- 'id' : str (self .course .id ),
377- 'display_name' : str (self .course .display_name ),
378- 'url' : f'/course/{ str (self .course .id )} ' ,
381+ "id" : str (self .course .id ),
382+ "display_name" : str (self .course .display_name ),
383+ "url" : f"/course/{ str (self .course .id )} " ,
384+ "containers" : [
385+ {
386+ "id" : str (self .unit .usage_key ),
387+ "display_name" : str (self .unit .display_name ),
388+ "url" : f"/container/{ str (self .unit .usage_key )} " ,
389+ "links" : [
390+ { "id" : str (self .downstream_video_key ) },
391+ ],
392+ },
393+ ],
379394 },
380395 {
381- 'id' : str (self .another_course .id ),
382- 'display_name' : str (self .another_course .display_name ),
383- 'url' : f'/course/{ str (self .another_course .id )} ' ,
396+ "id" : str (self .another_course .id ),
397+ "display_name" : str (self .another_course .display_name ),
398+ "url" : f"/course/{ str (self .another_course .id )} " ,
399+ "containers" : [
400+ {
401+ "id" : str (self .another_unit .usage_key ),
402+ "display_name" : str (self .another_unit .display_name ),
403+ "url" : f"/container/{ str (self .another_unit .usage_key )} " ,
404+ "links" : [ { "id" : str (key ) } for key in self .another_video_keys ],
405+ },
406+ ],
384407 },
385408 ]
386409 self .assertListEqual (data , expected )
0 commit comments