mirror of
				https://github.com/Telecominfraproject/oopt-gnpy-api.git
				synced 2025-11-04 11:57:50 +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'])
 | 
			
		||||
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",
 | 
			
		||||
@@ -1576,3 +1577,4 @@
 | 
			
		||||
      ]
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -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",
 | 
			
		||||
@@ -1576,3 +1577,4 @@
 | 
			
		||||
      ]
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -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",
 | 
			
		||||
@@ -1576,3 +1577,4 @@
 | 
			
		||||
      ]
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -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",
 | 
			
		||||
@@ -1576,3 +1577,4 @@
 | 
			
		||||
      ]
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -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