aboutsummaryrefslogtreecommitdiffstats
path: root/app/test/fetch/db_fetch/test_fetch_host_network_agents.py
diff options
context:
space:
mode:
authorKoren Lev <korenlev@gmail.com>2017-07-27 15:04:07 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-07-27 15:04:07 +0000
commit162c03ef301396072c1934e7e7e0c40a841b4fe2 (patch)
tree7a2a2781949252436450ff5832962785061a774a /app/test/fetch/db_fetch/test_fetch_host_network_agents.py
parentb88c78e3cf2bef22aa2f1c4d0bf305e303bc15f0 (diff)
parent7e83d0876ddb84a45e130eeba28bc40ef53c074b (diff)
Merge "Calipso initial release for OPNFV"
Diffstat (limited to 'app/test/fetch/db_fetch/test_fetch_host_network_agents.py')
-rw-r--r--app/test/fetch/db_fetch/test_fetch_host_network_agents.py66
1 files changed, 66 insertions, 0 deletions
diff --git a/app/test/fetch/db_fetch/test_fetch_host_network_agents.py b/app/test/fetch/db_fetch/test_fetch_host_network_agents.py
new file mode 100644
index 0000000..fd68a56
--- /dev/null
+++ b/app/test/fetch/db_fetch/test_fetch_host_network_agents.py
@@ -0,0 +1,66 @@
+###############################################################################
+# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) #
+# and others #
+# #
+# All rights reserved. This program and the accompanying materials #
+# are made available under the terms of the Apache License, Version 2.0 #
+# which accompanies this distribution, and is available at #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+###############################################################################
+import copy
+
+from discover.fetchers.db.db_fetch_host_network_agents import DbFetchHostNetworkAgents
+from test.fetch.test_fetch import TestFetch
+from test.fetch.db_fetch.test_data.db_fetch_host_network_agents import *
+from unittest.mock import MagicMock
+
+
+class TestFetchHostNetworkAgents(TestFetch):
+
+ def setUp(self):
+ self.configure_environment()
+ self.fetcher = DbFetchHostNetworkAgents()
+
+ def check_get_result(self,
+ config,
+ network_agent_res,
+ expected_result,
+ err_msg):
+ self.fetcher.env_config = config
+ self.fetcher.get_objects_list_for_id =\
+ MagicMock(return_value=network_agent_res)
+ result = self.fetcher.get(NETWORK_AGENT_FOLDER_ID)
+ self.assertEqual(result, expected_result, err_msg)
+
+ def test_get(self):
+ test_cases = [
+ {
+ 'config': CONFIG_WITH_MECHANISM_DRIVERS,
+ 'network_agent_res': copy.deepcopy(NETWORK_AGENT),
+ 'expected_result':
+ NETWORK_AGENT_WITH_MECHANISM_DRIVERS_IN_CONFIG_RESULTS,
+ 'err_msg': "Can't get correct result when the " +
+ "mechanism drivers exists in the config"
+ },
+ {
+ 'config': CONFIG_WITHOUT_MECHANISM_DRIVERS,
+ 'network_agent_res': copy.deepcopy(NETWORK_AGENT),
+ 'expected_result':
+ NETWORK_AGENT_WITHOUT_MECHANISM_DRIVERS_IN_CONFIG_RESULTS,
+ 'err_msg': "Can't get correct result when the " +
+ "mechanism drivers doesn't exist in the config"
+ },
+ {
+ 'config': CONFIG_WITH_MECHANISM_DRIVERS,
+ 'network_agent_res': [],
+ 'expected_result': [],
+ 'err_msg': "Can't get [] when the network agent result " +
+ "is empty"
+ }
+ ]
+
+ for test_case in test_cases:
+ self.check_get_result(test_case['config'],
+ test_case['network_agent_res'],
+ test_case['expected_result'],
+ test_case['err_msg'])