@@ 2312-2360 (lines=49) @@ | ||
2309 | ) |
|
2310 | assert res.content_type == 'application/pdf' |
|
2311 | ||
2312 | def test_api__get_full_pdf_preview__err__400__png_UnavailablePreviewType(self) -> None: # nopep8 |
|
2313 | """ |
|
2314 | get full pdf preview of a png image -> error UnavailablePreviewType |
|
2315 | """ |
|
2316 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
2317 | admin = dbsession.query(models.User) \ |
|
2318 | .filter(models.User.email == '[email protected]') \ |
|
2319 | .one() |
|
2320 | workspace_api = WorkspaceApi( |
|
2321 | current_user=admin, |
|
2322 | session=dbsession, |
|
2323 | config=self.app_config |
|
2324 | ) |
|
2325 | content_api = ContentApi( |
|
2326 | current_user=admin, |
|
2327 | session=dbsession, |
|
2328 | config=self.app_config |
|
2329 | ) |
|
2330 | business_workspace = workspace_api.get_one(1) |
|
2331 | tool_folder = content_api.get_one(1, content_type=CONTENT_TYPES.Any_SLUG) |
|
2332 | test_file = content_api.create( |
|
2333 | content_type_slug=CONTENT_TYPES.File.slug, |
|
2334 | workspace=business_workspace, |
|
2335 | parent=tool_folder, |
|
2336 | label='Test file', |
|
2337 | do_save=True, |
|
2338 | do_notify=False, |
|
2339 | ) |
|
2340 | dbsession.flush() |
|
2341 | transaction.commit() |
|
2342 | content_id = int(test_file.content_id) |
|
2343 | image = create_1000px_png_test_image() |
|
2344 | self.testapp.authorization = ( |
|
2345 | 'Basic', |
|
2346 | ( |
|
2347 | '[email protected]', |
|
2348 | '[email protected]' |
|
2349 | ) |
|
2350 | ) |
|
2351 | self.testapp.put( |
|
2352 | '/api/v2/workspaces/1/files/{}/raw'.format(content_id), |
|
2353 | upload_files=[ |
|
2354 | ('files', image.name, image.getvalue()) |
|
2355 | ], |
|
2356 | status=204, |
|
2357 | ) |
|
2358 | self.testapp.get( |
|
2359 | '/api/v2/workspaces/1/files/{}/preview/pdf/full'.format(content_id), # nopep8 |
|
2360 | status=400 |
|
2361 | ) |
|
2362 | ||
2363 | def test_api__get_pdf_preview__ok__200__nominal_case(self) -> None: |
|
@@ 2125-2173 (lines=49) @@ | ||
2122 | new_image = Image.open(io.BytesIO(res.body)) |
|
2123 | assert 256, 256 == new_image.size |
|
2124 | ||
2125 | def test_api__get_sized_jpeg_preview__err__400__SizeNotAllowed(self) -> None: # nopep8 |
|
2126 | """ |
|
2127 | get 256x256 preview of a txt file |
|
2128 | """ |
|
2129 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
2130 | admin = dbsession.query(models.User) \ |
|
2131 | .filter(models.User.email == '[email protected]') \ |
|
2132 | .one() |
|
2133 | workspace_api = WorkspaceApi( |
|
2134 | current_user=admin, |
|
2135 | session=dbsession, |
|
2136 | config=self.app_config |
|
2137 | ) |
|
2138 | content_api = ContentApi( |
|
2139 | current_user=admin, |
|
2140 | session=dbsession, |
|
2141 | config=self.app_config |
|
2142 | ) |
|
2143 | business_workspace = workspace_api.get_one(1) |
|
2144 | tool_folder = content_api.get_one(1, content_type=CONTENT_TYPES.Any_SLUG) |
|
2145 | test_file = content_api.create( |
|
2146 | content_type_slug=CONTENT_TYPES.File.slug, |
|
2147 | workspace=business_workspace, |
|
2148 | parent=tool_folder, |
|
2149 | label='Test file', |
|
2150 | do_save=True, |
|
2151 | do_notify=False, |
|
2152 | ) |
|
2153 | dbsession.flush() |
|
2154 | transaction.commit() |
|
2155 | content_id = int(test_file.content_id) |
|
2156 | image = create_1000px_png_test_image() |
|
2157 | self.testapp.authorization = ( |
|
2158 | 'Basic', |
|
2159 | ( |
|
2160 | '[email protected]', |
|
2161 | '[email protected]' |
|
2162 | ) |
|
2163 | ) |
|
2164 | self.testapp.put( |
|
2165 | '/api/v2/workspaces/1/files/{}/raw'.format(content_id), |
|
2166 | upload_files=[ |
|
2167 | ('files', image.name, image.getvalue()) |
|
2168 | ], |
|
2169 | status=204, |
|
2170 | ) |
|
2171 | self.testapp.get( |
|
2172 | '/api/v2/workspaces/1/files/{}/preview/jpg/512x512'.format(content_id), # nopep8 |
|
2173 | status=400 |
|
2174 | ) |
|
2175 | ||
2176 | def test_api__get_sized_jpeg_revision_preview__ok__200__nominal_case(self) -> None: # nopep8 |