@@ 2346-2407 (lines=62) @@ | ||
2343 | ) |
|
2344 | assert res.content_type == 'application/pdf' |
|
2345 | ||
2346 | def test_api__get_pdf_preview__ok__err__400_page_of_preview_not_found(self) -> None: # nopep8 |
|
2347 | """ |
|
2348 | get full pdf preview of a txt file |
|
2349 | """ |
|
2350 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
2351 | admin = dbsession.query(models.User) \ |
|
2352 | .filter(models.User.email == '[email protected]') \ |
|
2353 | .one() |
|
2354 | workspace_api = WorkspaceApi( |
|
2355 | current_user=admin, |
|
2356 | session=dbsession, |
|
2357 | config=self.app_config |
|
2358 | ) |
|
2359 | content_api = ContentApi( |
|
2360 | current_user=admin, |
|
2361 | session=dbsession, |
|
2362 | config=self.app_config |
|
2363 | ) |
|
2364 | business_workspace = workspace_api.get_one(1) |
|
2365 | tool_folder = content_api.get_one(1, content_type=CONTENT_TYPES.Any_SLUG) |
|
2366 | test_file = content_api.create( |
|
2367 | content_type_slug=CONTENT_TYPES.File.slug, |
|
2368 | workspace=business_workspace, |
|
2369 | parent=tool_folder, |
|
2370 | label='Test file', |
|
2371 | do_save=True, |
|
2372 | do_notify=False, |
|
2373 | ) |
|
2374 | with new_revision( |
|
2375 | session=dbsession, |
|
2376 | tm=transaction.manager, |
|
2377 | content=test_file, |
|
2378 | ): |
|
2379 | test_file.file_extension = '.txt' |
|
2380 | test_file.depot_file = FileIntent( |
|
2381 | b'Test file', |
|
2382 | 'Test_file.txt', |
|
2383 | 'text/plain', |
|
2384 | ) |
|
2385 | content_api.update_content(test_file, 'Test_file', '<p>description</p>') # nopep8 |
|
2386 | dbsession.flush() |
|
2387 | transaction.commit() |
|
2388 | content_id = int(test_file.content_id) |
|
2389 | self.testapp.authorization = ( |
|
2390 | 'Basic', |
|
2391 | ( |
|
2392 | '[email protected]', |
|
2393 | '[email protected]' |
|
2394 | ) |
|
2395 | ) |
|
2396 | self.testapp.put( |
|
2397 | '/api/v2/workspaces/1/files/{}/raw'.format(content_id), |
|
2398 | upload_files=[ |
|
2399 | ('files', test_file.file_name, test_file.depot_file.file.read()) |
|
2400 | ], |
|
2401 | status=204, |
|
2402 | ) |
|
2403 | params = {'page': 1} |
|
2404 | self.testapp.get( |
|
2405 | '/api/v2/workspaces/1/files/{}/preview/pdf'.format(content_id), |
|
2406 | status=400, |
|
2407 | params=params, |
|
2408 | ) |
|
2409 | ||
2410 | def test_api__get_pdf_revision_preview__ok__200__nominal_case(self) -> None: |
|
@@ 2167-2228 (lines=62) @@ | ||
2164 | new_image = Image.open(io.BytesIO(res.body)) |
|
2165 | assert 256, 256 == new_image.size |
|
2166 | ||
2167 | def test_api__get_full_pdf_preview__ok__200__nominal_case(self) -> None: |
|
2168 | """ |
|
2169 | get full pdf preview of a txt file |
|
2170 | """ |
|
2171 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
2172 | admin = dbsession.query(models.User) \ |
|
2173 | .filter(models.User.email == '[email protected]') \ |
|
2174 | .one() |
|
2175 | workspace_api = WorkspaceApi( |
|
2176 | current_user=admin, |
|
2177 | session=dbsession, |
|
2178 | config=self.app_config |
|
2179 | ) |
|
2180 | content_api = ContentApi( |
|
2181 | current_user=admin, |
|
2182 | session=dbsession, |
|
2183 | config=self.app_config |
|
2184 | ) |
|
2185 | business_workspace = workspace_api.get_one(1) |
|
2186 | tool_folder = content_api.get_one(1, content_type=CONTENT_TYPES.Any_SLUG) |
|
2187 | test_file = content_api.create( |
|
2188 | content_type_slug=CONTENT_TYPES.File.slug, |
|
2189 | workspace=business_workspace, |
|
2190 | parent=tool_folder, |
|
2191 | label='Test file', |
|
2192 | do_save=True, |
|
2193 | do_notify=False, |
|
2194 | ) |
|
2195 | with new_revision( |
|
2196 | session=dbsession, |
|
2197 | tm=transaction.manager, |
|
2198 | content=test_file, |
|
2199 | ): |
|
2200 | test_file.file_extension = '.txt' |
|
2201 | test_file.depot_file = FileIntent( |
|
2202 | b'Test file', |
|
2203 | 'Test_file.txt', |
|
2204 | 'text/plain', |
|
2205 | ) |
|
2206 | content_api.update_content(test_file, 'Test_file', '<p>description</p>') # nopep8 |
|
2207 | dbsession.flush() |
|
2208 | transaction.commit() |
|
2209 | content_id = int(test_file.content_id) |
|
2210 | self.testapp.authorization = ( |
|
2211 | 'Basic', |
|
2212 | ( |
|
2213 | '[email protected]', |
|
2214 | '[email protected]' |
|
2215 | ) |
|
2216 | ) |
|
2217 | self.testapp.put( |
|
2218 | '/api/v2/workspaces/1/files/{}/raw'.format(content_id), |
|
2219 | upload_files=[ |
|
2220 | ('files', test_file.file_name, test_file.depot_file.file.read()) |
|
2221 | ], |
|
2222 | status=204, |
|
2223 | ) |
|
2224 | res = self.testapp.get( |
|
2225 | '/api/v2/workspaces/1/files/{}/preview/pdf/full'.format(content_id), # nopep8 |
|
2226 | status=200 |
|
2227 | ) |
|
2228 | assert res.content_type == 'application/pdf' |
|
2229 | ||
2230 | def test_api__get_full_pdf_preview__err__400__png_UnavailablePreviewType(self) -> None: # nopep8 |
|
2231 | """ |