mirror of
https://github.com/Telecominfraproject/oopt-gnpy-api.git
synced 2025-11-01 18:37:53 +00:00
fix: input is now rfc 7951 compliant
Change-Id: I8ef1c7a7da382cfa51d24aff27065fd4a38d5a3a
This commit is contained in:
@@ -13,14 +13,14 @@ PATH_REQUEST_BASE_PATH = '/path-request'
|
|||||||
|
|
||||||
@app.route(API_VERSION + PATH_REQUEST_BASE_PATH, methods=['POST'])
|
@app.route(API_VERSION + PATH_REQUEST_BASE_PATH, methods=['POST'])
|
||||||
def path_request(path_request_service: PathRequestService):
|
def path_request(path_request_service: PathRequestService):
|
||||||
data = request.json
|
data = request.json["gnpy-api"]
|
||||||
service = data['gnpy-api:service']
|
service = data['service']
|
||||||
if 'gnpy-api:topology' in data:
|
if 'topology' in data:
|
||||||
topology = data['gnpy-api:topology']
|
topology = data['topology']
|
||||||
else:
|
else:
|
||||||
raise TopologyError('No topology found in request')
|
raise TopologyError('No topology found in request')
|
||||||
if 'gnpy-api:equipment' in data:
|
if 'equipment' in data:
|
||||||
equipment = data['gnpy-api:equipment']
|
equipment = data['equipment']
|
||||||
else:
|
else:
|
||||||
raise EquipmentError('No equipment found in request')
|
raise EquipmentError('No equipment found in request')
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"gnpy-api:service": {
|
"gnpy-api": {
|
||||||
|
"service": {
|
||||||
"path-request": [
|
"path-request": [
|
||||||
{
|
{
|
||||||
"request-id": "0",
|
"request-id": "0",
|
||||||
@@ -174,7 +175,7 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"gnpy-api:topology": {
|
"topology": {
|
||||||
"elements": [
|
"elements": [
|
||||||
{
|
{
|
||||||
"uid": "trx Alice",
|
"uid": "trx Alice",
|
||||||
@@ -1075,7 +1076,7 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"gnpy-api:equipment": {
|
"equipment": {
|
||||||
"Edfa": [
|
"Edfa": [
|
||||||
{
|
{
|
||||||
"type_variety": "high_detail_model_example",
|
"type_variety": "high_detail_model_example",
|
||||||
@@ -1575,4 +1576,5 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"gnpy-api:service": {
|
"gnpy-api": {
|
||||||
|
"service": {
|
||||||
"path-request": [
|
"path-request": [
|
||||||
{
|
{
|
||||||
"request-id": "0",
|
"request-id": "0",
|
||||||
@@ -174,7 +175,7 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"gnpy-api:topology": {
|
"topology": {
|
||||||
"elements": [
|
"elements": [
|
||||||
{
|
{
|
||||||
"uid": "trx Alice",
|
"uid": "trx Alice",
|
||||||
@@ -1075,7 +1076,7 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"gnpy-api:equipment": {
|
"equipment": {
|
||||||
"Edfa": [
|
"Edfa": [
|
||||||
{
|
{
|
||||||
"type_variety": "high_detail_model_example",
|
"type_variety": "high_detail_model_example",
|
||||||
@@ -1575,4 +1576,5 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"gnpy-api:service": {
|
"gnpy-api": {
|
||||||
|
"service": {
|
||||||
"path-request": [
|
"path-request": [
|
||||||
{
|
{
|
||||||
"request-id": "0",
|
"request-id": "0",
|
||||||
@@ -174,7 +175,7 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"gnpy-api:topology": {
|
"topology": {
|
||||||
"elements": [
|
"elements": [
|
||||||
{
|
{
|
||||||
"uid": "trx Alice",
|
"uid": "trx Alice",
|
||||||
@@ -1075,7 +1076,7 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"gnpy-api:equipment": {
|
"equipment": {
|
||||||
"Edfa": [
|
"Edfa": [
|
||||||
{
|
{
|
||||||
"type_variety": "high_detail_model_example",
|
"type_variety": "high_detail_model_example",
|
||||||
@@ -1575,4 +1576,5 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"gnpy-api:service": {
|
"gnpy-api": {
|
||||||
|
"service": {
|
||||||
"path-request": [
|
"path-request": [
|
||||||
{
|
{
|
||||||
"request-id": "0",
|
"request-id": "0",
|
||||||
@@ -174,7 +175,7 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"gnpy-api:topology": {
|
"topology": {
|
||||||
"elements": [
|
"elements": [
|
||||||
{
|
{
|
||||||
"uid": "trx AliceX",
|
"uid": "trx AliceX",
|
||||||
@@ -1075,7 +1076,7 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"gnpy-api:equipment": {
|
"equipment": {
|
||||||
"Edfa": [
|
"Edfa": [
|
||||||
{
|
{
|
||||||
"type_variety": "high_detail_model_example",
|
"type_variety": "high_detail_model_example",
|
||||||
@@ -1575,4 +1576,5 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -24,9 +24,10 @@ def read_json_file(path):
|
|||||||
def test_path_request_success():
|
def test_path_request_success():
|
||||||
input_data = read_json_file(TEST_REQ_DIR / "planning_demand_example.json")
|
input_data = read_json_file(TEST_REQ_DIR / "planning_demand_example.json")
|
||||||
expected_response = read_json_file(TEST_RES_DIR / "planning_demand_res.json")
|
expected_response = read_json_file(TEST_RES_DIR / "planning_demand_res.json")
|
||||||
topology = input_data["gnpy-api:topology"]
|
input_data = input_data["gnpy-api"]
|
||||||
equipment = input_data["gnpy-api:equipment"]
|
topology = input_data["topology"]
|
||||||
service = input_data["gnpy-api:service"]
|
equipment = input_data["equipment"]
|
||||||
|
service = input_data["service"]
|
||||||
|
|
||||||
result = PathRequestService.path_request(topology, equipment, service)
|
result = PathRequestService.path_request(topology, equipment, service)
|
||||||
assert result == expected_response
|
assert result == expected_response
|
||||||
@@ -34,9 +35,10 @@ def test_path_request_success():
|
|||||||
|
|
||||||
def test_path_request_invalid_equipment():
|
def test_path_request_invalid_equipment():
|
||||||
input_data = read_json_file(TEST_REQ_DIR / "planning_demand_wrong_eqpt.json")
|
input_data = read_json_file(TEST_REQ_DIR / "planning_demand_wrong_eqpt.json")
|
||||||
topology = input_data["gnpy-api:topology"]
|
input_data = input_data["gnpy-api"]
|
||||||
equipment = input_data["gnpy-api:equipment"]
|
topology = input_data["topology"]
|
||||||
service = input_data["gnpy-api:service"]
|
equipment = input_data["equipment"]
|
||||||
|
service = input_data["service"]
|
||||||
|
|
||||||
with pytest.raises(EquipmentError) as exc:
|
with pytest.raises(EquipmentError) as exc:
|
||||||
PathRequestService.path_request(topology, equipment, service)
|
PathRequestService.path_request(topology, equipment, service)
|
||||||
@@ -46,9 +48,10 @@ def test_path_request_invalid_equipment():
|
|||||||
|
|
||||||
def test_path_request_invalid_topology():
|
def test_path_request_invalid_topology():
|
||||||
input_data = read_json_file(TEST_REQ_DIR / "planning_demand_wrong_topology.json")
|
input_data = read_json_file(TEST_REQ_DIR / "planning_demand_wrong_topology.json")
|
||||||
topology = input_data["gnpy-api:topology"]
|
input_data = input_data["gnpy-api"]
|
||||||
equipment = input_data["gnpy-api:equipment"]
|
topology = input_data["topology"]
|
||||||
service = input_data["gnpy-api:service"]
|
equipment = input_data["equipment"]
|
||||||
|
service = input_data["service"]
|
||||||
|
|
||||||
with pytest.raises(TopologyError) as exc:
|
with pytest.raises(TopologyError) as exc:
|
||||||
PathRequestService.path_request(topology, equipment, service)
|
PathRequestService.path_request(topology, equipment, service)
|
||||||
|
|||||||
Reference in New Issue
Block a user