Skip to content

Commit e5cc410

Browse files
committed
fixup! Make mirror_file fail if file object already exists (#7134)
1 parent 66a24e2 commit e5cc410

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

test/indexer/test_mirror_controller.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,15 @@ def test_mirroring(self):
9696
with self.subTest('mirror_partition'):
9797
file, file_message = self._test_mirror_partition(partition_message)
9898

99-
with self.subTest('mirror_file', corrupted=False):
99+
with self.subTest('mirror_file', corrupted=False, exists=False):
100100
self._test_mirror_file(file, file_message)
101101

102102
# Force reupload attempts even if the info object is present
103103
with patch.object(MirrorService, 'is_mirrored', return_value=False):
104104
with self.subTest('mirror_file', corrupted=True):
105105
self._test_corrupted_download(file_message)
106-
106+
with self.subTest('mirror_file', corrupted=False, exists=True):
107+
self._test_reuploaded_file(file_message)
107108

108109
_file_contents = b'lorem ipsum dolor sit\n'
109110

@@ -172,6 +173,14 @@ def _test_corrupted_download(self, file_message):
172173
self.mirror_controller.mirror(event)
173174
self.assertTrue(R.caused(e.exception))
174175

176+
def _test_reuploaded_file(self, file_message):
177+
event = [self._mock_sqs_record(file_message)]
178+
with patch.object(MirrorService, '_download', return_value=self._file_contents):
179+
with self.assertRaises(AssertionError) as e:
180+
self.mirror_controller.mirror(event)
181+
self.assertTrue(R.caused(e.exception))
182+
self.assertEqual(e.exception.args[0].args[0], 'Object exists')
183+
175184
def test_info_schema(self):
176185
client = http_client(log)
177186
file = MagicMock(content_type='text/plain')

0 commit comments

Comments
 (0)