Exemplo n.º 1
0
 def tearDownClass(cls):
     try:
         api.delete_resources([
             API_TEST_ID, API_TEST_ID2, API_TEST_ID3, API_TEST_ID4,
             API_TEST_ID5
         ])
     except Exception:
         pass
     for transformation in [
             API_TEST_TRANS, API_TEST_TRANS2, API_TEST_TRANS3
     ]:
         try:
             api.delete_transformation(transformation)
         except Exception:
             pass
     for preset in [
             API_TEST_PRESET, API_TEST_PRESET2, API_TEST_PRESET3,
             API_TEST_PRESET4
     ]:
         try:
             api.delete_upload_preset(preset)
         except Exception:
             pass
     cloudinary.api.delete_resources_by_tag(UNIQUE_TAG)
     cloudinary.api.delete_resources_by_tag(UNIQUE_TAG, resource_type='raw')
Exemplo n.º 2
0
    def tearDownClass(cls):
        try:
            api.delete_resources([API_TEST_ID, API_TEST_ID2, API_TEST_ID3, API_TEST_ID4, API_TEST_ID5])
        except Exception:
            pass
        for transformation in [API_TEST_TRANS, API_TEST_TRANS2, API_TEST_TRANS3, API_TEST_TRANS_SCALE100_STR]:
            try:
                api.delete_transformation(transformation)
            except Exception:
                pass
        presets_response = api.upload_presets(max_results=200)
        preset_names = [
            preset["name"] for preset in presets_response.get('presets', [])
            if UNIQUE_API_TAG in preset.get('settings', {}).get('tags', '')]
        for name in preset_names:
            try:
                api.delete_upload_preset(name)
            except Exception:
                pass
        cloudinary.api.delete_resources_by_tag(UNIQUE_API_TAG)
        cloudinary.api.delete_resources_by_tag(UNIQUE_API_TAG, resource_type='raw')

        try:
            api.delete_upload_mapping(MAPPING_TEST_ID)
        except Exception:
            pass
Exemplo n.º 3
0
 def test17_transformation_implicit(self, mocker):
     """ should allow deleting implicit transformation """
     mocker.return_value = MOCK_RESPONSE
     api.delete_transformation("c_scale,w_100")
     args, kargs = mocker.call_args
     self.assertEqual(args[0], 'DELETE')
     self.assertTrue(get_uri(args).endswith('/transformations/c_scale,w_100'))
Exemplo n.º 4
0
 def setUp(self):
     self.timestamp_tag = "api_test_tag_{0}".format(utils.now())
     if ApiTest.initialized: return
     ApiTest.initialized = True
     cloudinary.reset_config()
     if not cloudinary.config().api_secret: return
     try:
         api.delete_resources(["api_test", "api_test2", "api_test3"])
     except Exception:
         pass
     for transformation in ["api_test_transformation", "api_test_transformation2", "api_test_transformation3"]:
         try:
             api.delete_transformation(transformation)
         except Exception:
             pass
     for transformation in ["api_test_upload_preset", "api_test_upload_preset2", "api_test_upload_preset3",
                            "api_test_upload_preset4"]:
         try:
             api.delete_upload_preset(transformation)
         except Exception:
             pass
     
     for id in ["api_test", "api_test2"]:
         uploader.upload("tests/logo.png",
                         public_id=id, tags=["api_test_tag", self.timestamp_tag],
                         context="key=value", eager=[{"width": 100, "crop": "scale"}])
Exemplo n.º 5
0
def cleanup_test_transformation(params):
    for transformations_with_options in params:
        options = transformations_with_options[1] if len(
            transformations_with_options) > 1 else {}
        for transformation in transformations_with_options[0]:
            with ignore_exception(suppress_traceback_classes=(NotFound, )):
                api.delete_transformation(transformation, **options)
Exemplo n.º 6
0
 def setUp(self):
     self.timestamp_tag = "api_test_tag_{0}".format(utils.now())
     if ApiTest.initialized: return
     ApiTest.initialized = True
     cloudinary.reset_config()
     if not cloudinary.config().api_secret: return
     try:
         api.delete_resources(["api_test", "api_test2", "api_test3"])
     except Exception:
         pass
     for transformation in ["api_test_transformation", "api_test_transformation2", "api_test_transformation3"]:
         try:
             api.delete_transformation(transformation)
         except Exception:
             pass
     for transformation in ["api_test_upload_preset", "api_test_upload_preset2", "api_test_upload_preset3",
                            "api_test_upload_preset4"]:
         try:
             api.delete_upload_preset(transformation)
         except Exception:
             pass
     
     for id in ["api_test", "api_test2"]:
         uploader.upload("tests/logo.png",
                         public_id=id, tags=["api_test_tag", self.timestamp_tag],
                         context="key=value", eager=[{"width": 100, "crop": "scale"}])
Exemplo n.º 7
0
 def setUp(self):
     if TestApi.initialized: return
     TestApi.initialized = True
     cloudinary.reset_config()
     if not cloudinary.config().api_secret: return
     try:
         api.delete_resources(["api_test", "api_test2", "api_test3"])
     except:
         pass
     try:
         api.delete_transformation("api_test_transformation")
     except:
         pass
     uploader.upload("tests/logo.png",
                     public_id="api_test",
                     tags="api_test_tag",
                     eager=[{
                         "width": 100,
                         "crop": "scale"
                     }])
     uploader.upload("tests/logo.png",
                     public_id="api_test2",
                     tags="api_test_tag",
                     eager=[{
                         "width": 100,
                         "crop": "scale"
                     }])
Exemplo n.º 8
0
 def test17_transformation_implicit(self, mocker):
     """ should allow deleting implicit transformation """
     mocker.return_value = MOCK_RESPONSE
     api.delete_transformation(API_TEST_TRANS_SCALE100)
     args, kargs = mocker.call_args
     self.assertEqual(args[0], 'DELETE')
     self.assertTrue(get_uri(args).endswith('/transformations/{0}'.format(API_TEST_TRANS_SCALE100_STR)))
Exemplo n.º 9
0
 def test17_transformation_implicit(self, mocker):
     """ should allow deleting implicit transformation """
     mocker.return_value = MOCK_RESPONSE
     api.delete_transformation("c_scale,w_100")
     args, kargs = mocker.call_args
     self.assertEqual(args[0], 'DELETE')
     self.assertTrue(
         get_uri(args).endswith('/transformations/c_scale,w_100'))
Exemplo n.º 10
0
 def test17_transformation_implicit(self, mocker):
     """ should allow deleting implicit transformation """
     mocker.return_value = MOCK_RESPONSE
     api.delete_transformation(API_TEST_TRANS_SCALE100)
     args, kargs = mocker.call_args
     self.assertEqual(args[0], 'DELETE')
     self.assertTrue(get_uri(args).endswith('/transformations'))
     self.assertEqual(API_TEST_TRANS_SCALE100_STR, get_params(args)['transformation'])
Exemplo n.º 11
0
 def test16_transformation_delete(self):
     """ should allow deleting named transformation """
     api.create_transformation(API_TEST_TRANS2, {
         "crop": "scale",
         "width": 103
     })
     api.transformation(API_TEST_TRANS2)
     api.delete_transformation(API_TEST_TRANS2)
     self.assertRaises(api.NotFound, api.transformation, API_TEST_TRANS2)
Exemplo n.º 12
0
 def test16_transformation_delete(self):
     """ should allow deleting named transformation """
     api.create_transformation("api_test_transformation2", {
         "crop": "scale",
         "width": 103
     })
     api.transformation("api_test_transformation2")
     api.delete_transformation("api_test_transformation2")
     self.assertRaises(api.NotFound, api.transformation,
                       ("api_test_transformation2"))
Exemplo n.º 13
0
    def tearDownClass(cls):
        cloudinary.api.delete_resources_by_tag(UNIQUE_TAG)
        cloudinary.api.delete_resources_by_tag(UNIQUE_TAG, resource_type='raw')
        cloudinary.api.delete_resources_by_tag(UNIQUE_TAG, type='twitter_name')
        cloudinary.api.delete_resources([TEST_ID1, TEST_ID2])
        cloudinary.api.delete_resources([TEXT_ID], type='text')
        cloudinary.api.delete_resources([TEST_DOCX_ID], resource_type='raw')

        for trans in [TEST_TRANS_SCALE2_STR, TEST_TRANS_SCALE2_PNG_STR]:
            try:
                api.delete_transformation(trans)
            except Exception:
                pass
Exemplo n.º 14
0
 def setUp(self):
   if TestApi.initialized: return
   TestApi.initialized = True
   cloudinary.reset_config()
   if not cloudinary.config().api_secret: return 
   try:
     api.delete_resources(["api_test", "api_test2", "api_test3"])
   except:
     pass
   try:
     api.delete_transformation("api_test_transformation")
   except:
     pass
   uploader.upload("tests/logo.png", public_id="api_test", tags="api_test_tag", eager=[{"width": 100,"crop": "scale"}])
   uploader.upload("tests/logo.png", public_id="api_test2", tags="api_test_tag", eager=[{"width": 100,"crop": "scale"}])
Exemplo n.º 15
0
 def setUp(self):
     if ApiTest.initialized: return
     ApiTest.initialized = True
     cloudinary.reset_config()
     if not cloudinary.config().api_secret: return
     try:
         api.delete_resources(["api_test", "api_test2", "api_test3"])
     except:
         pass
     for transformation in ["api_test_transformation", "api_test_transformation2", "api_test_transformation3",
                            "api_test_upload_preset", "api_test_upload_preset2", "api_test_upload_preset3",
                            "api_test_upload_preset4"]:          
       try:
           api.delete_transformation(transformation)
       except:
           pass
     uploader.upload("tests/logo.png", public_id="api_test", tags="api_test_tag", context="key=value", eager=[{"width": 100,"crop": "scale"}])
     uploader.upload("tests/logo.png", public_id="api_test2", tags="api_test_tag", context="key=value", eager=[{"width": 100,"crop": "scale"}])
Exemplo n.º 16
0
    def tearDownClass(cls):
        try:
            api.delete_resources([
                API_TEST_ID, API_TEST_ID2, API_TEST_ID3, API_TEST_ID4,
                API_TEST_ID5
            ])
        except Exception:
            pass
        for transformation in [
                API_TEST_TRANS, API_TEST_TRANS2, API_TEST_TRANS3,
                API_TEST_TRANS_SCALE100_STR
        ]:
            try:
                api.delete_transformation(transformation)
            except Exception:
                pass
        cloudinary.api.delete_resources_by_tag(UNIQUE_API_TAG)
        cloudinary.api.delete_resources_by_tag(UNIQUE_API_TAG,
                                               resource_type='raw')

        try:
            api.delete_upload_mapping(MAPPING_TEST_ID)
        except Exception:
            pass
Exemplo n.º 17
0
    def tearDownClass(cls):
        try:
            api.delete_resources([API_TEST_ID, API_TEST_ID2, API_TEST_ID3, API_TEST_ID4, API_TEST_ID5])
        except Exception:
            pass
        for transformation in [API_TEST_TRANS, API_TEST_TRANS2, API_TEST_TRANS3]:
            try:
                api.delete_transformation(transformation)
            except Exception:
                pass
        presets_response = api.upload_presets(max_results=200)
        preset_names = [ preset["name"] for preset in presets_response.get('presets',[]) if UNIQUE_TAG in preset.get('settings',{}).get('tags','')]
        for name in preset_names:
            try:
                api.delete_upload_preset(name)
            except Exception:
                pass
        cloudinary.api.delete_resources_by_tag(UNIQUE_TAG)
        cloudinary.api.delete_resources_by_tag(UNIQUE_TAG, resource_type='raw')

        try:
            api.delete_upload_mapping(MAPPING_TEST_ID)
        except Exception:
            pass
Exemplo n.º 18
0
 def test16_transformation_delete(self):
     """ should allow deleting named transformation """
     api.create_transformation(API_TEST_TRANS2, {"crop": "scale", "width": 103})
     api.transformation(API_TEST_TRANS2)
     api.delete_transformation(API_TEST_TRANS2)
     self.assertRaises(api.NotFound, api.transformation, API_TEST_TRANS2)
Exemplo n.º 19
0
def cleanup_test_transformation(params):
    for transformations_with_options in params:
        options = transformations_with_options[1] if len(transformations_with_options) > 1 else {}
        for transformation in transformations_with_options[0]:
            with ignore_exception(suppress_traceback_classes=(api.NotFound,)):
                api.delete_transformation(transformation, **options)
Exemplo n.º 20
0
 def test17_transformation_implicit(self):
     """ should allow deleting implicit transformation """
     api.transformation("c_scale,w_100")
     api.delete_transformation("c_scale,w_100")
     self.assertRaises(api.NotFound, api.transformation, ("c_scale,w_100"))
Exemplo n.º 21
0
 def test16_transformation_delete(self):
     """ should allow deleting named transformation """
     api.create_transformation("api_test_transformation2", {"crop": "scale", "width": 103})
     api.transformation("api_test_transformation2")
     api.delete_transformation("api_test_transformation2")
     self.assertRaises(api.NotFound, api.transformation, ("api_test_transformation2"))
Exemplo n.º 22
0
 def test17_transformation_implicit(self):
     """ should allow deleting implicit transformation """
     api.transformation("c_scale,w_100")
     api.delete_transformation("c_scale,w_100")
     self.assertRaises(api.NotFound, api.transformation, ("c_scale,w_100"))