-#
-#
-# def test_xapp_put_bad(client, monkeypatch):
-# """Test policy put fails"""
-# _test_put_patch(monkeypatch)
-# # return from policy handler has a status indicating FAIL
-# monkeypatch.setattr(
-# "a1.a1rmr.dequeue_all_waiting_messages", _fake_dequeue(monkeypatch, msg_payload={"status": "FAIL", "foo": "bar"})
-# )
-# res = client.put("/a1-p/policies/admission_control_policy", json=testing_helpers.good_payload())
-# assert res.status_code == 502
-# assert res.json["reason"] == "BAD STATUS"
-# assert res.json["return_payload"] == {"status": "FAIL", "foo": "bar"}
-#
-# # return from policy handler has no status field
-# monkeypatch.setattr("a1.a1rmr.dequeue_all_waiting_messages", _fake_dequeue(monkeypatch, msg_payload={"foo": "bar"}))
-# res = client.put("/a1-p/policies/admission_control_policy", json=testing_helpers.good_payload())
-# assert res.status_code == 502
-# assert res.json["reason"] == "NO STATUS"
-# assert res.json["return_payload"] == {"foo": "bar"}
-#
-# # return from policy handler not a json
-# monkeypatch.setattr(
-# "a1.a1rmr.dequeue_all_waiting_messages", _fake_dequeue(monkeypatch, msg_payload="booger", jsonb=False)
-# )
-# res = client.put("/a1-p/policies/admission_control_policy", json=testing_helpers.good_payload())
-# assert res.status_code == 502
-# assert res.json["reason"] == "NOT JSON"
-# assert res.json["return_payload"] == "booger"
-#
-# # bad type
-# monkeypatch.setattr("a1.a1rmr.dequeue_all_waiting_messages", _fake_dequeue(monkeypatch, msg_type=666))
-# res = client.put("/a1-p/policies/admission_control_policy", json=testing_helpers.good_payload())
-# assert res.status_code == 504
-# assert res.data == b"\"A1 was expecting an ACK back but it didn't receive one or didn't recieve the expected ACK\"\n"
-#
-# # bad state
-# monkeypatch.setattr("a1.a1rmr.dequeue_all_waiting_messages", _fake_dequeue(monkeypatch, msg_state=666))
-# res = client.put("/a1-p/policies/admission_control_policy", json=testing_helpers.good_payload())
-# assert res.status_code == 504
-# assert res.data == b"\"A1 was expecting an ACK back but it didn't receive one or didn't recieve the expected ACK\"\n"
-#
-#
-def test_bad_requests(client, monkeypatch):
+ for _ in range(seconds_to_try):
+ # idea here is that we have to wait for the seperate thread to process the event
+ res = client.get(ADM_CTRL_INSTANCE_STATUS)
+ assert res.status_code == 200
+ assert res.json["has_been_deleted"] == expected_deleted
+ try:
+ assert res.json["instance_status"] == expected_status
+ return
+ except AssertionError:
+ time.sleep(1)
+ assert res.json["instance_status"] == expected_status
+
+
+# Module level Hack
+
+
+def setup_module():
+ """module level setup"""
+
+ data.SDL = MockSDLWrapper() # patch SDL
+
+ def noop():
+ pass
+
+ # launch the thread with a fake init func and a patched rcv func; we will "repatch" later
+ a1rmr.start_rmr_thread(init_func_override=noop, rcv_func_override=_fake_dequeue_none)
+
+
+# Actual Tests
+
+
+def test_workflow(client, monkeypatch, adm_type_good, adm_instance_good):
+ """
+ test a full A1 workflow