Skip to content

Commit

Permalink
Switch to Django 2.0.13, Take 12
Browse files Browse the repository at this point in the history
  • Loading branch information
znick committed Mar 31, 2024
1 parent 5e5a423 commit e2f5068
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions anytask/issues/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,9 @@ def test_attached_file_in_s3(self):
self.task.rb_integrated = False
self.task.save()

call_command('s3migrate_issue_attachments', '--execute', '--do-rewrite-url')
stdout = StringIO()
stderr = StringIO()
call_command('s3migrate_issue_attachments', '--execute', '--do-rewrite-url', stdout=stdout, stderr=stderr)

# login
self.assertTrue(client.login(username=self.student.username, password=self.student_password),
Expand Down Expand Up @@ -1199,21 +1201,26 @@ def test_rewrite_url_only_existing_many_refs(self):
out = StringIO()
err = StringIO()
call_command('s3migrate_issue_attachments', '--execute', '--rewrite-only-existing', stdout=out, stderr=err)
cmd_out = out.getvalue()

expected_stdout = []
for file in [file_first, file_second]:
expected_s3_path = S3OverlayStorage.append_s3_prefix(file.file.name)
expected_stdout = ('''Note: destination already exists: {}\n'''
'''Note: updating model: {}, {}\n'''
'''Note: updated model: {}, {}\n'''
).format(
expected_s3_path, file, expected_s3_path, file, expected_s3_path)
expected_stdout = (expected_stdout * 2).strip()
expected_stdout.append(
"""Note: destination already exists: {}\n"""
"""Note: updating model: {}, {}\n"""
"""Note: updated model: {}, {}\n""".format(
expected_s3_path, file, expected_s3_path, file, expected_s3_path
)
)

file = File.objects.get(pk=file.pk)
cmd_out = out.getvalue().strip()
self.assertEqual(expected_stdout, cmd_out)
self.assertTrue(S3OverlayStorage.is_s3_stored(file.file.name))
self.assertTrue(self.s3_storage.exists(file.file.name))

expected_stdout = "".join(expected_stdout)
self.assertEqual(expected_stdout, cmd_out)

def test_upload_archives(self):
for ext in anyrb.unpacker.get_supported_extensions():
fail_msg = 'Failed for extension: {}'.format(ext)
Expand Down

0 comments on commit e2f5068

Please sign in to comment.