def test_uploader_update_metadata(self): """Should edit metadata of an existing resource""" resource = uploader.upload(TEST_IMAGE, tags=[UNIQUE_TAG]) result = uploader.update_metadata(METADATA_FIELDS, resource['public_id']) self.assertEqual(len(result['public_ids']), 1) self.assertIn(resource['public_id'], result['public_ids'])
def test_uploader_update_metadata_on_multiple_resources(self): """Should edit metadata of multiple existing resources""" resource1 = uploader.upload(TEST_IMAGE, tags=[UNIQUE_TAG]) resource2 = uploader.upload(TEST_IMAGE, tags=[UNIQUE_TAG]) result = uploader.update_metadata( METADATA_FIELDS, [resource1['public_id'], resource2['public_id']]) self.assertEqual(len(result['public_ids']), 2) self.assertIn(resource1['public_id'], result['public_ids']) self.assertIn(resource2['public_id'], result['public_ids'])
def test_update_metadata(self): metadata = {METADATA_FIELD_UNIQUE_EXTERNAL_ID: "test"} test_image = uploader.upload(TEST_IMAGE, metadata=metadata, tags=[UNIQUE_TAG]) public_ids = [test_image['public_id']] result = uploader.update_metadata(METADATA_FIELDS, public_ids) self.assertEqual(result, { "public_ids": public_ids, })