def test22_raw_conversion(self): """ should support requesting raw_convert """ resource = uploader.upload("tests/docx.docx", resource_type="raw") with self.assertRaisesRegexp(api.BadRequest, 'Illegal value'): api.update(resource["public_id"], raw_convert="illegal", resource_type="raw")
def test26_1_ocr(self, mocker): """ should support requesting ocr """ mocker.return_value = MOCK_RESPONSE api.update(API_TEST_ID, ocr='adv_ocr') args, kargs = mocker.call_args params = get_params(args) self.assertEqual(params['ocr'], 'adv_ocr')
def test26_2_quality_override(self, mocker): """ should support quality_override """ mocker.return_value = MOCK_RESPONSE test_values = ['auto:advanced', 'auto:best', '80:420', 'none'] for quality in test_values: api.update("api_test", quality_override=quality) quality_override = get_param(mocker, 'quality_override') self.assertEqual(quality_override, quality)
def test26_2_quality_override(self, mocker): """ should support quality_override """ mocker.return_value = MOCK_RESPONSE test_values = ['auto:advanced', 'auto:best', '80:420', 'none'] for quality in test_values: api.update("api_test", quality_override=quality) params = mocker.call_args[0][2] self.assertEqual(params['quality_override'], quality)
def test22_raw_conversion(self): """ should support requesting raw_convert """ resource = uploader.upload(TEST_DOC, resource_type="raw", tags=[UNIQUE_API_TAG]) with six.assertRaisesRegex(self, api.BadRequest, 'Illegal value'): api.update(resource["public_id"], raw_convert="illegal", resource_type="raw")
def test_update_access_control(self, mocker): """ should allow the user to define ACL in the update parameters """ mocker.return_value = MOCK_RESPONSE acl = OrderedDict((("access_type", "anonymous"), ("start", "2018-02-22 16:20:57 +0200"), ("end", "2018-03-22 00:00 +0200"))) exp_acl = '[{"access_type":"anonymous","start":"2018-02-22 16:20:57 +0200","end":"2018-03-22 00:00 +0200"}]' api.update(API_TEST_ID, access_control=acl) params = get_params(mocker.call_args[0]) self.assertIn("access_control", params) self.assertEqual(exp_acl, params["access_control"])
def test20_manual_moderation(self): """ should support setting manual moderation status """ resource = uploader.upload(TEST_IMAGE, moderation="manual", tags=[UNIQUE_API_TAG]) self.assertEqual(resource["moderation"][0]["status"], "pending") self.assertEqual(resource["moderation"][0]["kind"], "manual") api_result = api.update(resource["public_id"], moderation_status="approved") self.assertEqual(api_result["moderation"][0]["status"], "approved") self.assertEqual(api_result["moderation"][0]["kind"], "manual")
def test20_manual_moderation(self): """ should support setting manual moderation status """ resource = uploader.upload("tests/logo.png", moderation="manual") self.assertEqual(resource["moderation"][0]["status"], "pending") self.assertEqual(resource["moderation"][0]["kind"], "manual") api_result = api.update(resource["public_id"], moderation_status="approved") self.assertEqual(api_result["moderation"][0]["status"], "approved") self.assertEqual(api_result["moderation"][0]["kind"], "manual")
def test23_categorization(self): """ should support requesting categorization """ with six.assertRaisesRegex(self, BadRequest, 'Illegal value'): api.update(API_TEST_ID, categorization="illegal")
def test32_background_removal(self): """ should support requesting background_removal """ with self.assertRaisesRegexp(api.BadRequest, 'Illegal value'): api.update("api_test", background_removal="illegal")
def test26_auto_tagging(self): """ should support requesting auto_tagging """ with self.assertRaisesRegexp(api.BadRequest, 'Must use'): api.update("api_test", auto_tagging=0.5)
def test26_1_ocr(self, mocker): """ should support requesting ocr """ mocker.return_value = MOCK_RESPONSE api.update("api_test", ocr='adv_ocr') params = mocker.call_args[0][2] self.assertEqual(params['ocr'], 'adv_ocr')
def test32_background_removal(self): """ should support requesting background_removal """ with six.assertRaisesRegex(self, api.BadRequest, 'Illegal value'): api.update(API_TEST_ID, background_removal="illegal")
def test25_similarity_search(self): """ should support requesting similarity_search """ with self.assertRaisesRegexp(api.BadRequest, "Illegal value"): api.update("api_test", similarity_search="illegal")
def test21_ocr_info(self): """ should support requesting ocr info """ with self.assertRaisesRegexp(api.BadRequest, "Illegal value"): api.update("api_test", ocr="illegal")
def test23_categorization(self): """ should support requesting categorization """ with self.assertRaisesRegexp(api.BadRequest, 'Illegal value'): api.update("api_test", categorization="illegal")
def test21_notification_url(self, mocker): """ should support notification_url param """ mocker.return_value = MOCK_RESPONSE api.update("api_test", notification_url="http://example.com") notification_url = get_param(mocker, 'notification_url') self.assertEqual(notification_url, "http://example.com")
def test21_notification_url(self, mocker): """ should support notification_url param """ mocker.return_value = MOCK_RESPONSE api.update("api_test", notification_url="http://example.com") params = mocker.call_args[0][2] self.assertEqual(params['notification_url'], "http://example.com")
def test25_similarity_search(self): """ should support requesting similarity_search """ with self.assertRaisesRegexp(api.BadRequest, 'Illegal value'): api.update("api_test", similarity_search="illegal")
def test24_detection(self): """ should support requesting detection """ with six.assertRaisesRegex(self, api.BadRequest, 'Illegal value'): api.update(API_TEST_ID, detection="illegal")
def test24_detection(self): """ should support requesting detection """ with self.assertRaisesRegexp(api.BadRequest, 'Illegal value'): api.update("api_test", detection="illegal")
def test21_ocr_info(self): """ should support requesting ocr info """ with self.assertRaisesRegexp(api.BadRequest, 'Illegal value'): api.update("api_test", ocr="illegal")