def test_tags(self): """should successfully upload file """ result = uploader.upload("tests/logo.png") uploader.add_tag("tag1", result["public_id"]) uploader.add_tag("tag2", result["public_id"]) self.assertEqual(api.resource(result["public_id"])["tags"], ["tag1", "tag2"]) uploader.remove_tag("tag1", result["public_id"]) self.assertEqual(api.resource(result["public_id"])["tags"], ["tag2"]) uploader.replace_tag("tag3", result["public_id"]) self.assertEqual(api.resource(result["public_id"])["tags"], ["tag3"])
def test_remove_all_tags(self): """should successfully remove all tags""" result = uploader.upload(TEST_IMAGE, tags=[UNIQUE_TAG]) result2 = uploader.upload(TEST_IMAGE, tags=[UNIQUE_TAG]) uploader.add_tag("tag1", [result["public_id"], result2["public_id"]]) uploader.add_tag("tag2", result["public_id"]) self.assertEqual(api.resource(result["public_id"])["tags"], ["tag1", "tag2", UNIQUE_TAG]) self.assertEqual(api.resource(result2["public_id"])["tags"], ["tag1", UNIQUE_TAG]) uploader.remove_all_tags([result["public_id"], result2["public_id"]]) self.assertFalse("tags" in api.resource(result["public_id"])) self.assertFalse("tags" in api.resource(result2["public_id"]))
def test_remove_all_tags(self): """should successfully remove all tags""" result = uploader.upload(TEST_IMAGE, public_id=TEST_ID1) result2 = uploader.upload(TEST_IMAGE, public_id=TEST_ID2) uploader.add_tag("tag1", [result["public_id"], result2["public_id"]]) uploader.add_tag("tag2", result["public_id"]) self.assertEqual(api.resource(result["public_id"])["tags"], ["tag1", "tag2"]) self.assertEqual(api.resource(result2["public_id"])["tags"], ["tag1"]) uploader.remove_all_tags([result["public_id"], result2["public_id"]]) self.assertFalse("tags" in api.resource(result["public_id"])) self.assertFalse("tags" in api.resource(result2["public_id"]))
def test_tags(self): """should successfully upload file """ result = uploader.upload("tests/logo.png") result2 = uploader.upload("tests/logo.png") uploader.add_tag("tag1", [result["public_id"], result2["public_id"]]) uploader.add_tag("tag2", result["public_id"]) self.assertEqual( api.resource(result["public_id"])["tags"], ["tag1", "tag2"]) self.assertEqual(api.resource(result2["public_id"])["tags"], ["tag1"]) uploader.remove_tag("tag1", result["public_id"]) self.assertEqual(api.resource(result["public_id"])["tags"], ["tag2"]) uploader.replace_tag("tag3", result["public_id"]) self.assertEqual(api.resource(result["public_id"])["tags"], ["tag3"])
def test_tags(self): """should successfully upload file """ result = uploader.upload(TEST_IMAGE, tags=[UNIQUE_TAG]) result2 = uploader.upload(TEST_IMAGE, tags=[UNIQUE_TAG]) uploader.add_tag("tag1", [result["public_id"], result2["public_id"]]) uploader.add_tag("tag2", result["public_id"]) self.assertEqual(api.resource(result["public_id"])["tags"], ["tag1", "tag2", UNIQUE_TAG]) self.assertEqual(api.resource(result2["public_id"])["tags"], ["tag1", UNIQUE_TAG]) uploader.remove_tag("tag1", result["public_id"]) self.assertEqual(api.resource(result["public_id"])["tags"], ["tag2", UNIQUE_TAG]) uploader.replace_tag("tag3", result["public_id"]) self.assertEqual(api.resource(result["public_id"])["tags"], ["tag3"]) uploader.replace_tag(UNIQUE_TAG, result["public_id"])
def tag(tagname, public_id): add_tag(tagname, public_id) return 0