Skip to content

Commit

Permalink
Debug is_s3_stored
Browse files Browse the repository at this point in the history
  • Loading branch information
znick committed Aug 30, 2022
1 parent 358c483 commit c8a0133
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 8 additions & 2 deletions anytask/issues/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,8 @@ def test_attached_file_in_s3(self):

@skipIf(not IS_S3_REACHABLE, "S3 seems misconfigured")
class S3MigrateIssueAttachments(TestCase, SerializeMixin):
maxDiff = None

def setUp(self):
self.teacher_password = 'password1'
self.teacher = User.objects.create_user(username='teacher',
Expand Down Expand Up @@ -1162,7 +1164,8 @@ def test_rewrite_url_only_existing_many_refs(self):
out.getvalue().strip())

out = StringIO()
call_command('s3migrate_issue_attachments', '--execute', '--rewrite-only-existing', stdout=out)
err = StringIO()
call_command('s3migrate_issue_attachments', '--execute', '--rewrite-only-existing', stdout=out, stderr=err)

for file in [file_first, file_second]:
expected_s3_path = S3OverlayStorage.append_s3_prefix(file.file.name)
Expand All @@ -1173,9 +1176,12 @@ def test_rewrite_url_only_existing_many_refs(self):
expected_s3_path, file, expected_s3_path, file, expected_s3_path)
expected_stdout = (expected_stdout * 2).strip()
file = File.objects.get(pk=file.pk)
cmd_out = out.getvalue().strip()
print(f">>>>>>>>>>>>>>>>>>>filename:{file.file.name} {S3OverlayStorage.is_s3_stored(file.file.name)}")
print(f"==============\n{expected_stdout}\n!=\n{cmd_out}\n======\n{err.getvalue().strip()\n!!!!!!\n")
self.assertEqual(expected_stdout, cmd_out)
self.assertTrue(S3OverlayStorage.is_s3_stored(file.file.name))
self.assertTrue(self.s3_storage.exists(file.file.name))
self.assertEqual(expected_stdout, out.getvalue().strip())

def test_upload_archives(self):
for ext in anyrb.unpacker.get_supported_extensions():
Expand Down
3 changes: 3 additions & 0 deletions anytask/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ def _dispatch(self, name, method_name, *args, **kwargs):

@classmethod
def is_s3_stored(cls, name):
ret = name.lstrip('/').startswith(cls.S3_STORED_MAGIC + '/')
name_stripped = name.lstrip('/')
print(f"!!!!!!!!!! NAMAE:{name} {name_stripped} {ret}")
return name.lstrip('/').startswith(cls.S3_STORED_MAGIC + '/')

@classmethod
Expand Down

0 comments on commit c8a0133

Please sign in to comment.