summaryrefslogtreecommitdiffstats
path: root/test/test_simple_route_opt.py
diff options
context:
space:
mode:
authorSithara Nambiar <sitharav.aredath@huawei.com>2020-04-20 21:39:33 +0530
committerSithara Nambiar <sitharav.aredath@huawei.com>2020-04-21 13:53:52 +0530
commit2ac2b0c1c177dfec588b9c3439a41340d555897b (patch)
tree43be48a427e21af985979d5f4f04a0f4c99cb0cf /test/test_simple_route_opt.py
parenta5d124e5fa47a7ff5a0717a1b2e160bb766169b7 (diff)
Route optimization -take 2
Issue-ID: OPTFRA-420 Signed-off-by: Sithara Nambiar <sitharav.aredath@huawei.com> Change-Id: I06624f5adee060ce220a82f2a05a17c0986ca904
Diffstat (limited to 'test/test_simple_route_opt.py')
-rw-r--r--test/test_simple_route_opt.py57
1 files changed, 57 insertions, 0 deletions
diff --git a/test/test_simple_route_opt.py b/test/test_simple_route_opt.py
new file mode 100644
index 0000000..3b4facc
--- /dev/null
+++ b/test/test_simple_route_opt.py
@@ -0,0 +1,57 @@
+from apps.route.optimizers.simple_route_opt import RouteOpt
+from osdf.utils.interfaces import json_from_file
+from unittest.mock import patch
+import osdf.config.loader as config_loader
+from osdf.utils.programming_utils import DotDict
+import unittest
+
+
+class TestSimpleRouteOptimization(unittest.TestCase):
+ @patch('apps.route.optimizers.simple_route_opt.requests.get')
+ @patch('apps.route.optimizers.simple_route_opt.pymzn.minizinc')
+ def test_process_nst_selection_solutions( self, mock_solve, mock_get):
+
+ main_dir = ""
+ response_data_file = main_dir + "test/simple_route_opt/AAI.json"
+ mock_get.return_value.json.return_value = json_from_file(response_data_file)
+ mock_get.return_value.status_code = 200
+ mock_solve.return_value = [{'x': [1, 1, 1]}]
+ self.config_spec = {
+ "deployment": "test/functest/simulators/simulated-config/osdf_config.yaml",
+ "core": "test/functest/simulators/simulated-config/common_config.yaml"
+ }
+ self.osdf_config = DotDict(config_loader.all_configs(**self.config_spec))
+ parameter_data_file = main_dir + "test/simple_route_opt/routeOpt.json"
+ request_json = json_from_file(parameter_data_file)
+ mock_response = {
+ "requestId": "yyy-yyy-yyyy",
+ "requestStatus": "accepted",
+ "solutions": [
+ {
+ "end_node": "10.10.10.10",
+ "link": "link-id-1",
+ "start_node": "20.20.20.20"
+ },
+ {
+ "end_node": "11.11.11.11",
+ "link": "link-id-2",
+ "start_node": "22.22.22.22"
+ },
+ {
+ "end_node": "20.20.20.20",
+ "link": "link-id-3",
+ "start_node": "11.11.11.11"
+ }
+ ],
+ "statusMessage": " ",
+ "transactionId": "xxx-xxx-xxxx"
+ }
+ routopt = RouteOpt()
+ actual_response = routopt.get_route(request_json,self.osdf_config)
+ self.assertEqual(mock_response, actual_response)
+
+
+
+if __name__ == '__main__':
+ unittest.main()
+