Skip to content

Commit 794cafe

Browse files
committed
Fix failing tests and rebasing mistakes
1 parent 5086384 commit 794cafe

File tree

4 files changed

+30
-11
lines changed

4 files changed

+30
-11
lines changed

contentcuration/contentcuration/tests/test_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ def test_filter_edit_queryset__admin(self, mock_ensure_db_exists):
710710
)
711711
self.assertQuerysetContains(queryset, pk=submission_a.id)
712712

713-
def test_mark_live(self):
713+
def test_mark_live(self, mock_ensure_db_exists):
714714
submission_a = testdata.community_library_submission()
715715
submission_b = testdata.community_library_submission()
716716

contentcuration/contentcuration/tests/viewsets/test_channel.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,8 +547,11 @@ def test_sync_added_to_community_library_change(self):
547547
self.assertEqual(len(response.json()["allowed"]), 0, response.content)
548548
self.assertEqual(len(response.json()["disallowed"]), 1, response.content)
549549

550+
@mock.patch("contentcuration.utils.publish.ensure_versioned_database_exists")
550551
@mock.patch("contentcuration.viewsets.channel.export_channel_to_kolibri_public")
551-
def test_process_added_to_community_library_change(self, mock_export_func):
552+
def test_process_added_to_community_library_change(
553+
self, mock_export_func, mock_ensure_db_exists
554+
):
552555
# Creating the change on the backend should be supported
553556
self.client.force_authenticate(self.admin_user)
554557

contentcuration/contentcuration/tests/viewsets/test_community_library_submission.py

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ def setUp(self):
4444
self.country1 = testdata.country(name="Country 1", code="C1")
4545
self.country2 = testdata.country(name="Country 2", code="C2")
4646

47+
# Mock to allow creating submissions without having to set up content databases
48+
self.ensure_db_exists_patcher = mock.patch(
49+
"contentcuration.utils.publish.ensure_versioned_database_exists"
50+
)
51+
self.ensure_db_exists_patcher.start()
52+
4753
self.channel_with_submission1 = testdata.channel()
4854
self.channel_with_submission1.public = False
4955
self.channel_with_submission1.version = 1
@@ -93,6 +99,10 @@ def setUp(self):
9399
self.existing_submission2.countries.add(self.country1)
94100
self.existing_submission2.save()
95101

102+
def tearDown(self):
103+
self.ensure_db_exists_patcher.stop()
104+
super().tearDown()
105+
96106
def test_create_submission__is_editor(self):
97107
self.client.force_authenticate(user=self.editor_user)
98108
submission = self.new_submission_metadata
@@ -463,6 +473,19 @@ class AdminViewSetTestCase(StudioAPITestCase):
463473
def setUp(self):
464474
super().setUp()
465475

476+
self.resolved_time = datetime.datetime(2023, 10, 1, tzinfo=pytz.utc)
477+
self.datetime_patcher = mock.patch(
478+
"contentcuration.viewsets.community_library_submission.timezone.now",
479+
return_value=self.resolved_time,
480+
)
481+
self.mock_datetime = self.datetime_patcher.start()
482+
483+
# Mock to allow creating submissions without having to set up content databases
484+
self.ensure_db_exists_patcher = mock.patch(
485+
"contentcuration.utils.publish.ensure_versioned_database_exists"
486+
)
487+
self.ensure_db_exists_patcher.start()
488+
466489
self.submission = testdata.community_library_submission()
467490
self.submission.channel.version = 3
468491
self.submission.channel.save()
@@ -504,15 +527,9 @@ def setUp(self):
504527
"internal_notes": self.internal_notes,
505528
}
506529

507-
self.resolved_time = datetime.datetime(2023, 10, 1, tzinfo=pytz.utc)
508-
self.patcher = mock.patch(
509-
"contentcuration.viewsets.community_library_submission.timezone.now",
510-
return_value=self.resolved_time,
511-
)
512-
self.mock_datetime = self.patcher.start()
513-
514530
def tearDown(self):
515-
self.patcher.stop()
531+
self.datetime_patcher.stop()
532+
self.ensure_db_exists_patcher.stop()
516533
super().tearDown()
517534

518535
def _manually_reject_submission(self):

contentcuration/kolibri_public/utils/export_channel_to_kolibri_public.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ def export_channel_to_kolibri_public(
8484
)
8585
mapper = ChannelMapper(
8686
channel=channel,
87-
channel_version=channel_version,
8887
public=public,
8988
categories=categories,
9089
countries=countries,

0 commit comments

Comments
 (0)