def test12a_transformations_cursor(self, mocker): """ should allow listing transformations with cursor """ mocker.return_value = MOCK_RESPONSE api.transformation(API_TEST_TRANS_SCALE100, next_cursor='2412515', max_results=10) params = mocker.call_args[0][2] self.assertEqual(params['next_cursor'], '2412515') self.assertEqual(params['max_results'], 10)
def test13_transformation_metadata(self): """ should allow getting transformation metadata """ transformation = api.transformation("c_scale,w_100") self.assertNotEqual(transformation, None) self.assertEqual(transformation["info"], [{"crop": "scale", "width": 100}]) transformation = api.transformation({"crop": "scale", "width": 100}) self.assertNotEqual(transformation, None) self.assertEqual(transformation["info"], [{"crop": "scale", "width": 100}])
def test13_transformation_metadata(self): """ should allow getting transformation metadata """ transformation = api.transformation(API_TEST_TRANS_SCALE100_STR) self.assertNotEqual(transformation, None) self.assertEqual(transformation["info"], [API_TEST_TRANS_SCALE100]) transformation = api.transformation(API_TEST_TRANS_SCALE100) self.assertNotEqual(transformation, None) self.assertEqual(transformation["info"], [API_TEST_TRANS_SCALE100])
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)
def test14_transformation_update(self): """ should allow updating transformation allowed_for_strict """ api.update_transformation("c_scale,w_100", allowed_for_strict=True) transformation = api.transformation("c_scale,w_100") self.assertNotEqual(transformation, None) self.assertEqual(transformation["allowed_for_strict"], True) api.update_transformation("c_scale,w_100", allowed_for_strict=False) transformation = api.transformation("c_scale,w_100") self.assertNotEqual(transformation, None) self.assertEqual(transformation["allowed_for_strict"], False)
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"))
def test15_transformation_create(self): """ should allow creating named transformation """ api.create_transformation("api_test_transformation", {"crop": "scale", "width": 102}) transformation = api.transformation("api_test_transformation") self.assertNotEqual(transformation, None) self.assertEqual(transformation["allowed_for_strict"], True) self.assertEqual(transformation["info"], [{"crop": "scale", "width": 102}]) self.assertEqual(transformation["used"], False)
def test15a_transformation_unsafe_update(self): """ should allow unsafe update of named transformation """ api.create_transformation(API_TEST_TRANS3, {"crop": "scale", "width": 102}) api.update_transformation(API_TEST_TRANS3, unsafe_update={"crop": "scale", "width": 103}) transformation = api.transformation(API_TEST_TRANS3) self.assertNotEqual(transformation, None) self.assertEqual(transformation["info"], [{"crop": "scale", "width": 103}]) self.assertEqual(transformation["used"], False)
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)
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"))
def test12a_transformations_cursor(self, mocker): """ should allow listing transformations with cursor """ mocker.return_value = MOCK_RESPONSE api.transformation(API_TEST_TRANS_SCALE100, next_cursor=NEXT_CURSOR, max_results=10) self.assertEqual(get_param(mocker, 'next_cursor'), NEXT_CURSOR) self.assertEqual(get_param(mocker, 'max_results'), 10)
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"))