def setUp(self): self.cloud_name = 'test123' self.public_id = "sample" self.image_format = "jpg" self.full_public_id = "{id}.{format}".format(id=self.public_id, format=self.image_format) self.upload_url = "http://res.cloudinary.com/{cloud_name}/image/upload".format(cloud_name=self.cloud_name) self.common_format = {"url": self.upload_url, "id": self.full_public_id} self.image = CloudinaryImage(self.public_id, format=self.image_format) self.common_transformation = {"effect": "sepia"} self.common_transformation_str = 'e_sepia' self.common_image_options = {"cloud_name": self.cloud_name} self.common_image_options.update(self.common_transformation) self.custom_attributes = {'custom_attr1': 'custom_value1', 'custom_attr2': 'custom_value2'} self.min_width = 100 self.max_width = 399 self.breakpoint_list = [self.min_width, 200, 300, self.max_width] self.common_srcset = {"breakpoints": self.breakpoint_list} self.fill_transformation = {"width": self.max_width, "height": self.max_width, "crop": "fill"} self.fill_transformation_str = "c_fill,h_{h},w_{w}".format(h=self.max_width, w=self.max_width) cloudinary.reset_config() cloudinary.config(cloud_name=self.cloud_name, api_secret="1234", cname=None)
def setUp(self): self.cloud_name = 'test123' self.public_id = "sample" self.image_format = "jpg" self.full_public_id = "{id}.{format}".format(id=self.public_id, format=self.image_format) self.upload_url = "http://res.cloudinary.com/{cloud_name}/image/upload".format( cloud_name=self.cloud_name) self.common_format = { "url": self.upload_url, "id": self.full_public_id } self.image = CloudinaryImage(self.public_id, format=self.image_format) self.common_image_options = { "effect": "sepia", "cloud_name": self.cloud_name } self.common_transformation_str = 'e_sepia' self.breakpoint_list = [100, 200, 300, 399] self.common_srcset = {"breakpoints": self.breakpoint_list} self.custom_attributes = { 'custom_attr1': 'custom_value1', 'custom_attr2': 'custom_value2' } cloudinary.reset_config() cloudinary.config(cloud_name=self.cloud_name, api_secret="1234", cname=None)
def setUp(self): if self.initialized: return self.initialized = True cloudinary.reset_config() if not cloudinary.config().api_secret: return
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" }])
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"}])
def setUp(self): self.url_backup = os.environ.get("CLOUDINARY_URL") os.environ["CLOUDINARY_URL"] = "cloudinary://*****:*****@test123" cloudinary.reset_config() cloudinary.config(auth_token={ "key": KEY, "duration": 300, "start_time": 11111111 })
def setUpClass(cls): cloudinary.reset_config() if not cloudinary.config().api_secret: return uploader.upload(TEST_IMAGE, public_id=HTTP_CLIENT_TEST_ID, tags=[ HTTP_CLIENT_UNIQUE_TEST_TAG, ])
def setUp(self): cloudinary.reset_config() with ignore_exception( suppress_traceback_classes=(exceptions.BadRequest, )): api.add_metadata_field({ "external_id": METADATA_FIELD_UNIQUE_EXTERNAL_ID, "label": METADATA_FIELD_UNIQUE_EXTERNAL_ID, "type": "string", })
def setUpClass(cls): cloudinary.reset_config() if not cloudinary.config().api_secret: return for id in public_ids: res = uploader.upload(TEST_IMAGE, public_id=id, tags=[TEST_TAG, UNIQUE_TAG], context="stage=value", eager=[{"width": 100, "crop": "scale"}]) upload_results.append(res) time.sleep(3) # wait for the server to update
def setUpClass(cls): cloudinary.reset_config() if not cloudinary.config().api_secret: return for field in METADATA_FIELDS_TO_CREATE: if "label" not in field: field["label"] = field["external_id"] api.add_metadata_field(field)
def setUpClass(cls): cloudinary.reset_config() if not cloudinary.config().api_secret: return print("Running tests for cloud: {}".format(cloudinary.config().cloud_name)) for id in [API_TEST_ID, API_TEST_ID2]: uploader.upload("tests/logo.png", public_id=id, tags=[API_TEST_TAG, ], context="key=value", eager=[{"width": 100, "crop": "scale"}], overwrite=True)
def setUpClass(cls): cloudinary.reset_config() if not cloudinary.config().api_secret: return print("Running tests for cloud: {}".format(cloudinary.config().cloud_name)) for id in [API_TEST_ID, API_TEST_ID2]: uploader.upload(TEST_IMAGE, public_id=id, tags=[API_TEST_TAG, ], context="key=value", eager=[API_TEST_TRANS_SCALE100], overwrite=True)
def test_http_connector(self): """ should create proper http connector in case api_proxy is set """ cert_kwargs = { 'cert_reqs': 'CERT_NONE', } conf = cloudinary.config(api_proxy=None) http = utils.get_http_connector(conf, cert_kwargs) self.assertIsInstance(http, PoolManager) conf = cloudinary.config(api_proxy='http://www.example.com:3128') http = utils.get_http_connector(conf, cert_kwargs) cloudinary.reset_config() self.assertIsInstance(http, ProxyManager)
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"}])
def setUpClass(cls): cloudinary.reset_config() if not cloudinary.config().api_secret: return for id in [API_TEST_ID, API_TEST_ID2]: uploader.upload("tests/logo.png", public_id=id, tags=[ API_TEST_TAG, ], context="key=value", eager=[{ "width": 100, "crop": "scale" }], overwrite=True)
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"}])
def setUpClass(cls): cloudinary.reset_config() if not cloudinary.config().api_secret: return print("Running tests for cloud: {}".format(cloudinary.config().cloud_name)) api.add_metadata_field({ "external_id": METADATA_EXTERNAL_ID, "label": METADATA_EXTERNAL_ID, "type": "string", "default_value": METADATA_DEFAULT_VALUE }) for id in [API_TEST_ID, API_TEST_ID2]: uploader.upload(TEST_IMAGE, public_id=id, tags=[API_TEST_TAG, ], context="key=value", eager=[API_TEST_TRANS_SCALE100], overwrite=True)
def setUpClass(cls): cls.ready = False cloudinary.reset_config() if not cloudinary.config().api_secret: return for public_id in public_ids: res = uploader.upload(TEST_IMAGE, public_id=public_id, tags=[TEST_TAG, UNIQUE_TAG], context="stage=value") upload_results.append(res) attempt = 0 while attempt < MAX_INDEX_RETRIES: time.sleep(1) results = Search().expression("tags={0}".format(UNIQUE_TAG)).execute() if len(results['resources']) == len(public_ids): cls.ready = True break attempt += 1
def tearDown(self): with ignore_exception(): os.environ["CLOUDINARY_URL"] = self.url_backup cloudinary.reset_config()
def setUpClass(cls): cloudinary.reset_config() if not cloudinary.config().api_secret: return uploader.upload(TEST_IMAGE, public_id=HTTP_CLIENT_TEST_ID, tags=[HTTP_CLIENT_UNIQUE_TEST_TAG, ])
def setUp(self): cloudinary.reset_config() self.http_client = HttpClient()
def setUp(self): if StreamingProfilesTest.initialized: return StreamingProfilesTest.initialized = True cloudinary.reset_config() if not cloudinary.config().api_secret: return StreamingProfilesTest.test_id = "api_test_{0}".format(utils.now())
def setUpClass(cls): cloudinary.reset_config() uploader.upload("tests/logo.png", tags=[TEST_TAG]) uploader.upload("tests/logo.png", tags=[TEST_TAG], transformation=dict(width=10))
def setUp(self): cloudinary.reset_config() cloudinary.config(cloud_name="test", api_secret="1234") self.image = CloudinaryImage("hello", format="png")
from qr import make_png, make_svg app = Flask(__name__) # config heroku = Heroku(app) app.secret_key = environ.get('SECRET_KEY') app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False app.config['MAIL_PORT'] = environ.get('MAILGUN_SMTP_PORT', 25) app.config['MAIL_FROM'] = environ.get('MAIL_FROM', '*****@*****.**') app.config['CLOUDINARY_URL'] = environ.get('CLOUDINARY_URL') app.config['CLOUDINARY_BASE_URL'] = environ.get('CLOUDINARY_BASE_URL') try: app.config.from_object('local_settings') # this is required to use pycloudinary environ['CLOUDINARY_URL'] = app.config['CLOUDINARY_URL'] cloudinary.reset_config() except ImportError: pass # database db.init_app(app) migrate = Migrate(app, db) # emails mail.init_app(app) # converters FlaskUUID(app) # SSL redirection if environ.get('FORCE_SSL', False) == 'True': SSLify(app, permanent=True) @app.route('/', methods=['GET', 'POST'])
def setUpClass(cls): cloudinary.reset_config() cls.uploaded = uploader.upload(TEST_IMAGE, public_id=TEST_ID, tags=TEST_TAG)
def setUpClass(cls): cloudinary.reset_config() uploader.upload(TEST_IMAGE, tags=[TEST_TAG]) uploader.upload(TEST_IMAGE, tags=[TEST_TAG], transformation=dict(width=10))
def setUp(self): self.url_backup = os.environ.get("CLOUDINARY_URL") os.environ["CLOUDINARY_URL"] = "cloudinary://*****:*****@test123" cloudinary.reset_config() cloudinary.config(auth_token={"key": KEY, "duration": 300, "start_time": 11111111})
def setUp(self): if StreamingProfilesTest.initialized: return StreamingProfilesTest.initialized = True cloudinary.reset_config() if not cloudinary.config().api_secret: return StreamingProfilesTest.test_id = "api_test_{}".format(SUFFIX)
def setUp(self): cloudinary.reset_config()
def tearDown(self): os.environ["CLOUDINARY_URL"] = self.url_backup cloudinary.reset_config()
def setUp(self): cloudinary.reset_config() cloudinary.config(cloud_name="test", api_secret="1234") self.image = CloudinaryImage("hello", format = "png")