mirror of
https://github.com/Telecominfraproject/oopt-gnpy-api.git
synced 2025-10-30 09:32:32 +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'])
|
||||
def path_request(path_request_service: PathRequestService):
|
||||
data = request.json
|
||||
service = data['gnpy-api:service']
|
||||
if 'gnpy-api:topology' in data:
|
||||
topology = data['gnpy-api:topology']
|
||||
data = request.json["gnpy-api"]
|
||||
service = data['service']
|
||||
if 'topology' in data:
|
||||
topology = data['topology']
|
||||
else:
|
||||
raise TopologyError('No topology found in request')
|
||||
if 'gnpy-api:equipment' in data:
|
||||
equipment = data['gnpy-api:equipment']
|
||||
if 'equipment' in data:
|
||||
equipment = data['equipment']
|
||||
else:
|
||||
raise EquipmentError('No equipment found in request')
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"gnpy-api:service": {
|
||||
"gnpy-api": {
|
||||
"service": {
|
||||
"path-request": [
|
||||
{
|
||||
"request-id": "0",
|
||||
@@ -174,7 +175,7 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"gnpy-api:topology": {
|
||||
"topology": {
|
||||
"elements": [
|
||||
{
|
||||
"uid": "trx Alice",
|
||||
@@ -1075,7 +1076,7 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"gnpy-api:equipment": {
|
||||
"equipment": {
|
||||
"Edfa": [
|
||||
{
|
||||
"type_variety": "high_detail_model_example",
|
||||
@@ -1575,4 +1576,5 @@
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"gnpy-api:service": {
|
||||
"gnpy-api": {
|
||||
"service": {
|
||||
"path-request": [
|
||||
{
|
||||
"request-id": "0",
|
||||
@@ -174,7 +175,7 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"gnpy-api:topology": {
|
||||
"topology": {
|
||||
"elements": [
|
||||
{
|
||||
"uid": "trx Alice",
|
||||
@@ -1075,7 +1076,7 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"gnpy-api:equipment": {
|
||||
"equipment": {
|
||||
"Edfa": [
|
||||
{
|
||||
"type_variety": "high_detail_model_example",
|
||||
@@ -1575,4 +1576,5 @@
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"gnpy-api:service": {
|
||||
"gnpy-api": {
|
||||
"service": {
|
||||
"path-request": [
|
||||
{
|
||||
"request-id": "0",
|
||||
@@ -174,7 +175,7 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"gnpy-api:topology": {
|
||||
"topology": {
|
||||
"elements": [
|
||||
{
|
||||
"uid": "trx Alice",
|
||||
@@ -1075,7 +1076,7 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"gnpy-api:equipment": {
|
||||
"equipment": {
|
||||
"Edfa": [
|
||||
{
|
||||
"type_variety": "high_detail_model_example",
|
||||
@@ -1575,4 +1576,5 @@
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"gnpy-api:service": {
|
||||
"gnpy-api": {
|
||||
"service": {
|
||||
"path-request": [
|
||||
{
|
||||
"request-id": "0",
|
||||
@@ -174,7 +175,7 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"gnpy-api:topology": {
|
||||
"topology": {
|
||||
"elements": [
|
||||
{
|
||||
"uid": "trx AliceX",
|
||||
@@ -1075,7 +1076,7 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"gnpy-api:equipment": {
|
||||
"equipment": {
|
||||
"Edfa": [
|
||||
{
|
||||
"type_variety": "high_detail_model_example",
|
||||
@@ -1575,4 +1576,5 @@
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,9 +24,10 @@ def read_json_file(path):
|
||||
def test_path_request_success():
|
||||
input_data = read_json_file(TEST_REQ_DIR / "planning_demand_example.json")
|
||||
expected_response = read_json_file(TEST_RES_DIR / "planning_demand_res.json")
|
||||
topology = input_data["gnpy-api:topology"]
|
||||
equipment = input_data["gnpy-api:equipment"]
|
||||
service = input_data["gnpy-api:service"]
|
||||
input_data = input_data["gnpy-api"]
|
||||
topology = input_data["topology"]
|
||||
equipment = input_data["equipment"]
|
||||
service = input_data["service"]
|
||||
|
||||
result = PathRequestService.path_request(topology, equipment, service)
|
||||
assert result == expected_response
|
||||
@@ -34,9 +35,10 @@ def test_path_request_success():
|
||||
|
||||
def test_path_request_invalid_equipment():
|
||||
input_data = read_json_file(TEST_REQ_DIR / "planning_demand_wrong_eqpt.json")
|
||||
topology = input_data["gnpy-api:topology"]
|
||||
equipment = input_data["gnpy-api:equipment"]
|
||||
service = input_data["gnpy-api:service"]
|
||||
input_data = input_data["gnpy-api"]
|
||||
topology = input_data["topology"]
|
||||
equipment = input_data["equipment"]
|
||||
service = input_data["service"]
|
||||
|
||||
with pytest.raises(EquipmentError) as exc:
|
||||
PathRequestService.path_request(topology, equipment, service)
|
||||
@@ -46,9 +48,10 @@ def test_path_request_invalid_equipment():
|
||||
|
||||
def test_path_request_invalid_topology():
|
||||
input_data = read_json_file(TEST_REQ_DIR / "planning_demand_wrong_topology.json")
|
||||
topology = input_data["gnpy-api:topology"]
|
||||
equipment = input_data["gnpy-api:equipment"]
|
||||
service = input_data["gnpy-api:service"]
|
||||
input_data = input_data["gnpy-api"]
|
||||
topology = input_data["topology"]
|
||||
equipment = input_data["equipment"]
|
||||
service = input_data["service"]
|
||||
|
||||
with pytest.raises(TopologyError) as exc:
|
||||
PathRequestService.path_request(topology, equipment, service)
|
||||
|
||||
Reference in New Issue
Block a user