@@ -90,6 +90,38 @@ def test_get_unit(self):
9090 with self .assertNumQueries (0 ):
9191 assert result .versioning .has_unpublished_changes
9292
93+ def test_get_unit_version (self ):
94+ """
95+ Test get_unit_version()
96+ """
97+ unit = self .create_unit_with_components ([])
98+ draft = unit .versioning .draft
99+ with self .assertNumQueries (1 ):
100+ result = authoring_api .get_unit_version (draft .pk )
101+ assert result == draft
102+
103+ def test_get_latest_unit_version (self ):
104+ """
105+ Test test_get_latest_unit_version()
106+ """
107+ unit = self .create_unit_with_components ([])
108+ draft = unit .versioning .draft
109+ with self .assertNumQueries (2 ):
110+ result = authoring_api .get_latest_unit_version (unit .pk )
111+ assert result == draft
112+
113+ def test_get_containers (self ):
114+ """
115+ Test get_containers()
116+ """
117+ unit = self .create_unit_with_components ([])
118+ with self .assertNumQueries (1 ):
119+ result = list (authoring_api .get_containers (self .learning_package .id ))
120+ assert result == [unit .container ]
121+ # Versioning data should be pre-loaded via select_related()
122+ with self .assertNumQueries (0 ):
123+ assert result [0 ].versioning .has_unpublished_changes
124+
93125 def test_get_container (self ):
94126 """
95127 Test get_container()
@@ -102,6 +134,21 @@ def test_get_container(self):
102134 with self .assertNumQueries (0 ):
103135 assert result .versioning .has_unpublished_changes
104136
137+ def test_get_container_by_key (self ):
138+ """
139+ Test get_container_by_key()
140+ """
141+ unit = self .create_unit_with_components ([])
142+ with self .assertNumQueries (1 ):
143+ result = authoring_api .get_container_by_key (
144+ self .learning_package .id ,
145+ key = unit .publishable_entity .key ,
146+ )
147+ assert result == unit .container
148+ # Versioning data should be pre-loaded via select_related()
149+ with self .assertNumQueries (0 ):
150+ assert result .versioning .has_unpublished_changes
151+
105152 def test_unit_container_versioning (self ):
106153 """
107154 Test that the .versioning helper of a Unit returns a UnitVersion, and
@@ -807,6 +854,8 @@ def test_snapshots_of_published_unit(self):
807854 # At first the unit has one component (unpinned):
808855 unit = self .create_unit_with_components ([self .component_1 ])
809856 self .modify_component (self .component_1 , title = "Component 1 as of checkpoint 1" )
857+ before_publish = authoring_api .get_components_in_published_unit_as_of (unit , 0 )
858+ assert before_publish is None
810859
811860 # Publish everything, creating Checkpoint 1
812861 checkpoint_1 = authoring_api .publish_all_drafts (self .learning_package .id , message = "checkpoint 1" )
0 commit comments