+ # delete a non existent instance
+ res = client.delete(ADM_CTRL_INSTANCE + "DARKNESS")
+ assert res.status_code == 404
+
+ # get a non existent instance
+ a1rmr.replace_rcv_func(_fake_dequeue)
+ res = client.get(ADM_CTRL_INSTANCE + "DARKNESS")
+ assert res.status_code == 404
+
+ # delete the type (as cleanup)
+ res = client.delete(ADM_CTRL_TYPE)
+ assert res.status_code == 204
+
+ # test 503 handlers
+
+ def monkey_set(ns, key, value):
+ # set a key override function that throws sdl errors on certain keys
+ if key == "a1.policy_type.111":
+ raise RejectedByBackend()
+ if key == "a1.policy_type.112":
+ raise NotConnected()
+ if key == "a1.policy_type.113":
+ raise BackendError()
+
+ monkeypatch.setattr("a1.data.SDL.set", monkey_set)
+
+ def create_alt_id(json, id):
+ """
+ Overwrites the json's policy type ID, attempts create and tests for 503
+ """
+ json['policy_type_id'] = id
+ url = "/a1-p/policytypes/{0}".format(id)
+ res = client.put(url, json=json)
+ assert res.status_code == 503
+
+ create_alt_id(adm_type_good, 111)
+ create_alt_id(adm_type_good, 112)
+ create_alt_id(adm_type_good, 113)
+
+
+def test_illegal_types(client, adm_type_good):
+ """
+ Test illegal types
+ """
+ # below valid range
+ res = client.put("/a1-p/policytypes/0", json=adm_type_good)
+ assert res.status_code == 400
+ # ID mismatch
+ res = client.put("/a1-p/policytypes/1", json=adm_type_good)
+ assert res.status_code == 400
+ # above valid range
+ res = client.put("/a1-p/policytypes/2147483648", json=adm_type_good)
+ assert res.status_code == 400
+