|
1 | | -import asyncio |
2 | | -import datetime |
3 | 1 | import json |
4 | | -import time |
5 | | -from concurrent.futures import ThreadPoolExecutor |
6 | 2 |
|
7 | 3 | import pytest |
8 | 4 | from fastapi import HTTPException |
9 | 5 | from starlette import status |
10 | 6 |
|
11 | 7 | from print_service.models import File |
12 | 8 | from print_service.settings import get_settings |
13 | | -from print_service.utils import check_pdf_ok, generate_filename, get_file |
| 9 | +from print_service.utils import checking_for_pdf, get_file |
14 | 10 |
|
15 | 11 |
|
16 | 12 | url = '/file' |
@@ -91,8 +87,8 @@ def test_get_file_func_2_not_exists(dbsession, uploaded_file_os): |
91 | 87 |
|
92 | 88 |
|
93 | 89 | def test_file_check(): |
94 | | - assert check_pdf_ok(open("tests/test_routes/test_files/broken.pdf", "rb").read()) is False |
95 | | - assert check_pdf_ok(open("tests/test_routes/test_files/correct.pdf", "rb").read()) is True |
| 90 | + assert checking_for_pdf(open("tests/test_routes/test_files/broken.pdf", "rb").read()) == (False, 0) |
| 91 | + assert checking_for_pdf(open("tests/test_routes/test_files/correct.pdf", "rb").read()) == (True, 2) |
96 | 92 |
|
97 | 93 |
|
98 | 94 | def test_upload_and_print_correct_pdf(pin_pdf, client): |
@@ -130,9 +126,9 @@ def test_upload_and_print_encrypted_file(pin_pdf, client): |
130 | 126 | fileName = 'tests/test_routes/test_files/encrypted.pdf' |
131 | 127 | files = {'file': (f"{fileName}", open(f"{fileName}", 'rb'), "application/pdf")} |
132 | 128 | res = client.post(f"{url}/{pin}", files=files) |
133 | | - assert res.status_code == status.HTTP_200_OK |
| 129 | + assert res.status_code == status.HTTP_415_UNSUPPORTED_MEDIA_TYPE |
134 | 130 | res2 = client.get(f"{url}/{pin}") |
135 | | - assert res2.status_code == status.HTTP_200_OK |
| 131 | + assert res2.status_code == status.HTTP_415_UNSUPPORTED_MEDIA_TYPE |
136 | 132 |
|
137 | 133 |
|
138 | 134 | def test_incorrect_filename(union_member_user, client, dbsession): |
|
0 commit comments