Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/openedx/edx-enterprise in…
Browse files Browse the repository at this point in the history
…to hamza/ENT-5039
  • Loading branch information
hamzawaleed01 committed Sep 22, 2023
2 parents 48df722 + 7fbfa8d commit 403ff13
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions tests/test_integrated_channels/test_moodle/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def test_successful_create_content_metadata(self):
client._get_courses = unittest.mock.MagicMock(name='_get_courses') # pylint: disable=protected-access
mock_response = Response()
mock_response.status_code = 200
mock_response._content = self._get_courses_response_empty
mock_response._content = self._get_courses_response_empty # pylint: disable=protected-access
client._get_courses.return_value = mock_response # pylint: disable=protected-access
client.create_content_metadata(SERIALIZED_DATA)
client._post.assert_called_once_with(expected_data) # pylint: disable=protected-access
Expand All @@ -151,7 +151,7 @@ def test_duplicate_shortname_create_content_metadata(self):
client._get_courses = unittest.mock.MagicMock(name='_get_courses') # pylint: disable=protected-access
mock_response = Response()
mock_response.status_code = 200
mock_response._content = self._get_courses_response_empty
mock_response._content = self._get_courses_response_empty # pylint: disable=protected-access
client._get_courses.return_value = mock_response # pylint: disable=protected-access
client.create_content_metadata(SERIALIZED_DATA)
client._post.assert_called_once_with(expected_data) # pylint: disable=protected-access
Expand All @@ -168,7 +168,7 @@ def test_duplicate_courseidnumber_create_content_metadata(self):
client._get_courses = unittest.mock.MagicMock(name='_get_courses') # pylint: disable=protected-access
mock_response = Response()
mock_response.status_code = 200
mock_response._content = self._get_courses_response_empty
mock_response._content = self._get_courses_response_empty # pylint: disable=protected-access
client._get_courses.return_value = mock_response # pylint: disable=protected-access
client.create_content_metadata(SERIALIZED_DATA)
client._post.assert_called_once_with(expected_data) # pylint: disable=protected-access
Expand All @@ -186,7 +186,7 @@ def test_multi_duplicate_create_content_metadata(self):
client._get_courses = unittest.mock.MagicMock(name='_get_courses') # pylint: disable=protected-access
mock_response = Response()
mock_response.status_code = 200
mock_response._content = self._get_courses_response_empty
mock_response._content = self._get_courses_response_empty # pylint: disable=protected-access
client._get_courses.return_value = mock_response # pylint: disable=protected-access
with self.assertRaises(MoodleClientError):
client.create_content_metadata(MULTI_SERIALIZED_DATA)
Expand All @@ -199,13 +199,13 @@ def test_multi_duplicate_courseidnumber_create_content_metadata(self):
"""
expected_data = MULTI_SERIALIZED_DATA.copy()
expected_data['wsfunction'] = 'core_course_create_courses'

client = MoodleAPIClient(self.enterprise_config)
client._post = unittest.mock.MagicMock(name='_post', return_value=COURSEIDNUMBERTAKEN_RESPONSE) # pylint: disable=protected-access
client._get_courses = unittest.mock.MagicMock(name='_get_courses') # pylint: disable=protected-access
mock_response = Response()
mock_response.status_code = 200
mock_response._content = self._get_courses_response_empty
mock_response._content = self._get_courses_response_empty # pylint: disable=protected-access
client._get_courses.return_value = mock_response # pylint: disable=protected-access
with self.assertRaises(MoodleClientError):
client.create_content_metadata(MULTI_SERIALIZED_DATA)
Expand All @@ -232,7 +232,8 @@ def test_delete_content_metadata(self):
Test core logic for formatting a delete request to Moodle.
Mark a course visible:0 rather than doing a true delete
"""
expected_data = {'wsfunction': 'core_course_update_courses', 'courses[0][id]': self.moodle_course_id, 'courses[0][visible]': 0}
expected_data = {'wsfunction': 'core_course_update_courses',
'courses[0][id]': self.moodle_course_id, 'courses[0][visible]': 0}

client = MoodleAPIClient(self.enterprise_config)
client._post = unittest.mock.MagicMock(name='_post', return_value=SUCCESSFUL_RESPONSE) # pylint: disable=protected-access
Expand Down Expand Up @@ -389,14 +390,15 @@ def test_successful_update_existing_content_metadata(self):
expected_data['wsfunction'] = 'core_course_update_courses'
expected_data['courses[0][visible]'] = 1
expected_data['courses[0][id]'] = self.moodle_course_id

client = MoodleAPIClient(self.enterprise_config)
client._post = unittest.mock.MagicMock(name='_post', return_value=SUCCESSFUL_RESPONSE) # pylint: disable=protected-access
client._get_courses = unittest.mock.MagicMock(name='_get_courses') # pylint: disable=protected-access
client._post = unittest.mock.MagicMock( # pylint: disable=protected-access
name='_post', return_value=SUCCESSFUL_RESPONSE) # pylint: disable=protected-access
client._get_courses = unittest.mock.MagicMock( # pylint: disable=protected-access
name='_get_courses') # pylint: disable=protected-access
mock_response = Response()
mock_response.status_code = 200
mock_response._content = self._get_courses_response

mock_response._content = self._get_courses_response # pylint: disable=protected-access
client._get_course_id = unittest.mock.MagicMock(name='_get_course_id') # pylint: disable=protected-access
client._get_course_id.return_value = self.moodle_course_id # pylint: disable=protected-access
client._get_courses.return_value = mock_response # pylint: disable=protected-access
Expand Down

0 comments on commit 403ff13

Please sign in to comment.