+
+ # Get counter: data_delivery
+ response=client.get(SERVER_URL+'counter/datadelivery')
+ assert response.status_code == 200
+ assert response.data == b"0"
+
+ # Send data to data-delivery with empty payload
+ json_payload={}
+ response=client.post(SERVER_URL+'data-delivery', headers=header, data=json.dumps(json_payload))
+ assert response.status_code == 400
+
+ # Send invalid data to data-delivery
+ json_payload={
+ "job":"200",
+ "payload":"payload"
+ }
+ response=client.post(SERVER_URL+'data-delivery', headers=header, data=json.dumps(json_payload))
+ assert response.status_code == 404
+
+ # Send data to data-delivery with valid job
+ json_payload={
+ "job":"100",
+ "payload":"payload"
+ }
+ response=client.post(SERVER_URL+'data-delivery', headers=header, data=json.dumps(json_payload))
+ assert response.status_code == 200
+
+ # Send data to data-delivery with valid job
+ json_payload={
+ "job":"101",
+ "payload":"another payload"
+ }
+ response=client.post(SERVER_URL+'data-delivery', headers=header, data=json.dumps(json_payload))
+ assert response.status_code == 200
+
+ # Get counter: data_delivery
+ response=client.get(SERVER_URL+'counter/datadelivery')
+ assert response.status_code == 200
+ assert response.data == b"2"
+
+
+def test_notificationDestination(client):
+ testdata=get_testdata_dir()
+ # Header for json payload
+ header = {
+ "Content-Type" : "application/json"
+ }
+
+ # === API: Update policy instance pi2 of type: 2 ==="
+ with open(testdata+'pi2.json') as json_file:
+ policytype_2 = json.load(json_file)
+ response = client.put(SERVER_URL+"a1-p/policytypes/2/policies/pi2?notificationDestination=http://localhost:8085/statustest", headers=header, data=json.dumps(policytype_2))
+ assert response.status_code == 202
+ result = response.data
+ assert result == b""
+
+# def test_sendstatus(client):
+# testdata=get_testdata_dir()
+# # Header for json payload
+# header = {
+# "Content-Type" : "application/json"
+# }
+
+# # === Send status for pi2==="
+# with open(testdata+'pi2.json') as json_file:
+# policytype_2 = json.load(json_file)
+# response = client.post(SERVER_URL+'sendstatus?policyid=pi2', headers=header, data=json.dumps(policytype_2))
+# assert response.status_code == 201
+# result = response.data
+# assert result == b"OK"
+
+
+# def test_multithreaded(client):
+# # Create a new thread to run the Flask app
+# app_thread = threading.Thread(target=run_flask_app)
+# app_thread.start()
+
+# # Perform your tests here
+# testdata=get_testdata_dir()
+# # Header for json payload
+# header = {
+# "Content-Type" : "application/json"
+# }
+
+# # === Send status for pi2==="
+# with open(testdata+'pi2.json') as json_file:
+# policytype_2 = json.load(json_file)
+# response = client.post(SERVER_URL+'sendstatus?policyid=pi2', headers=header, data=json.dumps(policytype_2))
+# assert response.status_code == 201
+# result = response.data
+# assert result == b"OK"
+
+# # Wait for the Flask app thread to finish
+# app_thread.join()