+ assert response.data == b"1"
+
+def test_notificationDestination(client):
+ test_data = get_testdata_dir() + 'pi2.json'
+ # Header for json payload
+ header = { "Content-Type" : "application/json" }
+
+ # === API: Update policy instance pi2 of type: 2 ==="
+ with open(test_data) as json_file:
+ payload = json.load(json_file)
+ response = client.put(SERVER_URL+"A1-P/v2/policytypes/STD_1/policies/pi2?notificationDestination=http://localhost:8086/statustest", headers=header, data=json.dumps(payload))
+ assert response.status_code == 200
+ result = json.loads(response.data)
+ assert compare(payload, result) == True
+
+def test_sendstatus(client):
+ # Create a new thread to run the Flask app in parallel on a different port so that we can call the callback.
+ proc = multiprocessing.Process(target=run_flask_app, args=())
+ proc.start()
+
+ test_data = get_testdata_dir() + 'pi2.json'
+ header = { "Content-Type" : "application/json" }
+
+ # Timeout can be removed with polling the endpoints if required
+ proc.join(timeout=10)
+
+ # === Send status for pi2===
+ with open(test_data) as json_file:
+ payload = json.load(json_file)
+ response = client.post(SERVER_URL+'sendstatus?policyid=pi2', headers=header, data=json.dumps(payload))
+
+ assert response.status_code == 204
+ result = response.data
+ assert result == b""
+
+ # Send status, negative test with missing parameter
+ response = client.post(SERVER_URL+'sendstatus', headers=header, data="")
+ assert response.status_code == 400
+
+ # Send status pi9, negative test for policy id not found
+ response = client.post(SERVER_URL+'sendstatus?policyid=pi9', headers=header, data="")
+ assert response.status_code == 404
+
+ proc.terminate()