@@ -55,6 +55,7 @@ def test_configuration_for_new_course(self):
5555 config_data = CourseDiscussionConfigurationData (
5656 course_key = new_key ,
5757 provider_type = "openedx" ,
58+ plugin_configuration = {},
5859 )
5960 assert not DiscussionsConfiguration .objects .filter (context_key = new_key ).exists ()
6061 update_course_discussion_config (config_data )
@@ -191,3 +192,33 @@ def test_enabled_units_change(self):
191192 assert existing_topic_link .title == "Section 10|Subsection 10|Unit 10"
192193 # If there is no stored context, then continue using the Unit name.
193194 assert existing_topic_link_2 .title == "Unit 11"
195+
196+ def test_new_config_uses_enabled_from_configuration (self ):
197+ """
198+ When creating a new DiscussionsConfiguration, the handler should use
199+ the enabled value from the configuration data.
200+ """
201+ new_key = CourseKey .from_string ("course-v1:test+test+disabled" )
202+ config_data = CourseDiscussionConfigurationData (
203+ course_key = new_key ,
204+ provider_type = "openedx" ,
205+ enabled = False ,
206+ plugin_configuration = {},
207+ )
208+ update_course_discussion_config (config_data )
209+ db_config = DiscussionsConfiguration .objects .get (context_key = new_key )
210+ assert db_config .enabled is False
211+
212+ def test_existing_config_updated_enabled_from_configuration (self ):
213+ """
214+ When the configuration already exists, the handler should update
215+ enabled from the configuration data.
216+ """
217+ config_data = CourseDiscussionConfigurationData (
218+ course_key = self .course_key ,
219+ provider_type = "openedx" ,
220+ enabled = False ,
221+ )
222+ update_course_discussion_config (config_data )
223+ db_config = DiscussionsConfiguration .objects .get (context_key = self .course_key )
224+ assert db_config .enabled is False
0 commit comments