diff --git a/anytask/issues/tests.py b/anytask/issues/tests.py index 65ad2ec1..26afaf9f 100644 --- a/anytask/issues/tests.py +++ b/anytask/issues/tests.py @@ -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', @@ -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) @@ -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(): diff --git a/anytask/storage.py b/anytask/storage.py index 2e8efaf5..08f3e2f7 100644 --- a/anytask/storage.py +++ b/anytask/storage.py @@ -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