mirror of
https://github.com/Telecominfraproject/oopt-gnpy-api.git
synced 2025-11-02 19:07:48 +00:00
Compare commits
1 Commits
yamg-test
...
test-input
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
49005d8f2c |
@@ -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')
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -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