Skip to content

Commit 84520f0

Browse files
committed
test_file: query DB rather than use mocks
1 parent fad1c74 commit 84520f0

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

contentcuration/contentcuration/tests/viewsets/test_file.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from le_utils.constants import content_kinds
77
from le_utils.constants import file_formats
88
from le_utils.constants import format_presets
9-
from mock import MagicMock
109

1110
from contentcuration import models
1211
from contentcuration.tests import testdata
@@ -15,6 +14,7 @@
1514
from contentcuration.tests.viewsets.base import generate_delete_event
1615
from contentcuration.tests.viewsets.base import generate_update_event
1716
from contentcuration.tests.viewsets.base import SyncTestMixin
17+
from contentcuration.viewsets.sync.constants import CONTENTNODE
1818
from contentcuration.viewsets.sync.constants import FILE
1919

2020

@@ -129,13 +129,16 @@ def test_update_file_with_complete_contentnode(self):
129129

130130
self.assertEqual(complete_except_no_file.complete, False)
131131

132-
models.Change.create_change = MagicMock()
133-
134132
self.sync_changes(
135133
[generate_update_event(file.id, FILE, {"contentnode": complete_except_no_file.id}, channel_id=self.channel.id)],
136134
)
137135

138-
self.assertTrue(models.Change.create_change.called)
136+
# We should see two Changes, one of them should be for the CONTENTNODE table
137+
self.assertEqual(models.Change.objects.count(), 2)
138+
self.assertEqual(
139+
models.Change.objects.filter(table=CONTENTNODE).count(),
140+
1
141+
)
139142

140143
complete_except_no_file.refresh_from_db()
141144

0 commit comments

Comments
 (0)