Skip to content

Commit

Permalink
TLDR-517 TestApiArchiveReader params fix
Browse files Browse the repository at this point in the history
  • Loading branch information
raxtemur committed Nov 22, 2023
1 parent 805eb85 commit 010e66c
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions tests/api_tests/test_api_format_archives.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,43 @@


class TestApiArchiveReader(AbstractTestApiDocReader):
parameters = dict(with_attachments="True", need_content_analysis="True")

def _get_abs_path(self, file_name: str) -> str:
return os.path.join(self.data_directory_path, "archives", file_name)

def _check_archive_with_english_doc(self, file_name: str) -> None:
result = self._send_request(file_name, dict(with_attachments="True"))
result = self._send_request(file_name, self.parameters)
self.assertEqual(len(result["attachments"]), 4)
english_doc = [doc for doc in result["attachments"] if doc["metadata"]["file_name"].startswith("english_doc")][0]
self._check_english_doc(english_doc)

def test_zip(self) -> None:
file_name = "arch_with_attachs.zip"
result = self._send_request(file_name, dict(with_attachments="True"))
result = self._send_request(file_name, self.parameters)
self.assertEqual(len(result["attachments"]), 4)

def test_tar(self) -> None:
file_name = "arch_with_attachs.tar"
result = self._send_request(file_name, dict(with_attachments="True"))
result = self._send_request(file_name, self.parameters)

self.assertEqual(len(result["attachments"]), 4)

def test_targz(self) -> None:
file_name = "arch_with_attachs.tar.gz"
result = self._send_request(file_name, dict(with_attachments="True"))
result = self._send_request(file_name, self.parameters)

self.assertEqual(len(result["attachments"]), 4)

def test_rar(self) -> None:
file_name = "arch_with_attachs.rar"
result = self._send_request(file_name, dict(with_attachments="True"))
result = self._send_request(file_name, self.parameters)

self.assertEqual(len(result["attachments"]), 4)

def test_7zip(self) -> None:
file_name = "arch_with_attachs.7z"
result = self._send_request(file_name, dict(with_attachments="True"))
result = self._send_request(file_name, self.parameters)

self.assertEqual(len(result["attachments"]), 4)

Expand All @@ -65,7 +66,7 @@ def test_archive_subfolder_7z(self) -> None:

def test_zip_with_unsupported_file(self) -> None:
file_name = "arch_with_unsupport_atchs.zip"
result = self._send_request(file_name, dict(with_attachments="True"))
result = self._send_request(file_name, self.parameters)
attachs = result["attachments"]

self.assertEqual(len(attachs), 6)
Expand All @@ -74,7 +75,7 @@ def test_zip_with_unsupported_file(self) -> None:

def test_broken_archive(self) -> None:
file_name = "broken.zip"
result = self._send_request(file_name, dict(with_attachments="True"))
result = self._send_request(file_name, self.parameters)
self.assertEqual(len(result["attachments"]), 7)
english_doc = [doc for doc in result["attachments"] if doc["metadata"]["file_name"].startswith("english_doc")][0]
self._check_english_doc(english_doc)

0 comments on commit 010e66c

Please sign in to comment.