Skip to content

Commit c9d2adc

Browse files
committed
Revert "test: fix tests"
This reverts commit fac60e2.
1 parent 2db7399 commit c9d2adc

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

lti_consumer/tests/test_utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,20 @@ def setUp(self):
117117
"""Set up mock patches for xblock imports"""
118118
self.mock_load_xblock = Mock()
119119
self.mock_load_xblock.return_value = getattr(self, 'xblock', None)
120+
self.mock_save_xblock = Mock()
121+
self.mock_save_xblock.return_value = None
120122

121123
# Patch the imports
122124
self.patcher_load = patch('lti_consumer.plugin.compat.load_enough_xblock', self.mock_load_xblock)
125+
self.patcher_save = patch('lti_consumer.plugin.compat.save_xblock', self.mock_save_xblock)
123126

124127
self.patcher_load.start()
128+
self.patcher_save.start()
125129

126130
super().setUp()
127131

128132
def tearDown(self):
129133
"""Clean up patches"""
130134
self.patcher_load.stop()
135+
self.patcher_save.stop()
131136
super().tearDown()

lti_consumer/tests/unit/test_migrations.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class FakeBlock:
6464
}
6565

6666
with mock.patch("lti_consumer.plugin.compat.load_enough_xblock", return_value=fake_block) as mock_load, \
67+
mock.patch("lti_consumer.plugin.compat.save_xblock") as mock_save_xblock, \
6768
mock.patch("lti_consumer.utils.model_to_dict", return_value=values):
6869
self.executor.loader.build_graph()
6970
self.executor.migrate(self.migrate_to)
@@ -85,6 +86,7 @@ class FakeBlock:
8586

8687
mock_load.assert_called_once()
8788
self.assertEqual(str(mock_load.call_args.args[0]), self.location)
89+
mock_save_xblock.assert_not_called()
8890

8991
def test_migration_creates_passport_when_xblock_load_fails(self):
9092
"""Missing location skips XBlock path but still creates passport from DB."""
@@ -103,7 +105,7 @@ def test_migration_creates_passport_when_xblock_load_fails(self):
103105
with mock.patch(
104106
"lti_consumer.plugin.compat.load_enough_xblock",
105107
side_effect=Exception("boom"),
106-
) as mock_load, \
108+
) as mock_load, mock.patch("lti_consumer.plugin.compat.save_xblock") as mock_save_xblock, \
107109
mock.patch("lti_consumer.utils.model_to_dict", return_value=values), \
108110
mock.patch("builtins.print") as mock_print:
109111
self.executor.loader.build_graph()
@@ -125,6 +127,7 @@ def test_migration_creates_passport_when_xblock_load_fails(self):
125127
self.assertEqual(passport.lti_1p3_tool_keyset_url, "https://db.example/jwks.json")
126128

127129
mock_load.assert_not_called()
130+
mock_save_xblock.assert_not_called()
128131
mock_print.assert_not_called()
129132

130133
def test_migration_keeps_db_values_when_block_not_new(self):
@@ -146,6 +149,7 @@ class FakeBlock:
146149
}
147150

148151
with mock.patch("lti_consumer.plugin.compat.load_enough_xblock", return_value=fake_block) as mock_load, \
152+
mock.patch("lti_consumer.plugin.compat.save_xblock") as mock_save_xblock, \
149153
mock.patch("lti_consumer.utils.model_to_dict", return_value=values):
150154
self.executor.loader.build_graph()
151155
self.executor.migrate(self.migrate_to)
@@ -162,6 +166,7 @@ class FakeBlock:
162166
self.assertEqual(passport.lti_1p3_tool_keyset_url, "https://db.example/jwks.json")
163167

164168
self.assertEqual(str(mock_load.call_args.args[0]), self.location)
169+
mock_save_xblock.assert_not_called()
165170

166171
def test_backwards_copies_passport_values_back_to_configuration(self):
167172
"""Reverse migration restores passport-backed values onto the configuration."""

0 commit comments

Comments
 (0)