summaryrefslogtreecommitdiffstats
path: root/conductor
diff options
context:
space:
mode:
authorDileep Ranganathan <dileep.ranganathan@intel.com>2018-03-05 02:14:46 -0800
committerDileep Ranganathan <dileep.ranganathan@intel.com>2018-03-05 02:14:46 -0800
commit19d220e1f87475ef762ba7f6fb39d4eb18ee4c20 (patch)
tree79387fe230da2f0013f23084f3c8548612dbda42 /conductor
parent37301dd6ce1fd71cfde394bef74e9645e808d804 (diff)
Fix Data module unit tests
New code checkin was breaking the tests. Modified the data module unit tests to fix the breakage. Change-Id: I30b566f771badc4799fdd9a5a946c8c058d2ea6a Issue-ID: OPTFRA-162 Signed-off-by: Dileep Ranganathan <dileep.ranganathan@intel.com>
Diffstat (limited to 'conductor')
-rw-r--r--conductor/conductor/tests/unit/data/constraints.json1
-rw-r--r--conductor/conductor/tests/unit/data/test_service.py16
2 files changed, 13 insertions, 4 deletions
diff --git a/conductor/conductor/tests/unit/data/constraints.json b/conductor/conductor/tests/unit/data/constraints.json
index f89cdaf..f7e9250 100644
--- a/conductor/conductor/tests/unit/data/constraints.json
+++ b/conductor/conductor/tests/unit/data/constraints.json
@@ -67,6 +67,7 @@
"key2": "value2",
"key3": "value3"
},
+ "request_type": "initial",
"properties": {
"evaluate": {
"network_roles": "",
diff --git a/conductor/conductor/tests/unit/data/test_service.py b/conductor/conductor/tests/unit/data/test_service.py
index b2c47be..e2fba3e 100644
--- a/conductor/conductor/tests/unit/data/test_service.py
+++ b/conductor/conductor/tests/unit/data/test_service.py
@@ -18,11 +18,13 @@
#
import json
import unittest
+import uuid
import conductor.data.service as service
import mock
import stevedore
import yaml
+from conductor.common.utils import conductor_logging_util as log_util
from conductor.data.plugins.inventory_provider import extensions as ip_ext
from conductor.data.plugins.service_controller import extensions as sc_ext
from conductor.data.service import DataEndpoint
@@ -32,6 +34,7 @@ from oslo_config import cfg
class TestDataEndpoint(unittest.TestCase):
def setUp(self):
+ cfg.CONF.set_override('keyspace', 'conductor')
ip_ext_manager = (
ip_ext.Manager(cfg.CONF, 'conductor.inventory_provider.plugin'))
sc_ext_manager = (
@@ -78,7 +81,6 @@ class TestDataEndpoint(unittest.TestCase):
self.assertEqual({'response': 'NYCNY55', 'error': False},
self.data_ep.get_candidate_zone(None, req_json))
-
@mock.patch.object(service.LOG, 'error')
@mock.patch.object(service.LOG, 'debug')
@mock.patch.object(stevedore.ExtensionManager, 'map_method')
@@ -132,22 +134,28 @@ class TestDataEndpoint(unittest.TestCase):
@mock.patch.object(service.LOG, 'error')
@mock.patch.object(service.LOG, 'debug')
@mock.patch.object(service.LOG, 'info')
+ @mock.patch.object(log_util, 'getTransactionId')
@mock.patch.object(stevedore.ExtensionManager, 'map_method')
- def test_reslove_demands(self, ext_mock, info_mock, debug_mock,
+ def test_reslove_demands(self, ext_mock, logutil_mock, info_mock, debug_mock,
error_mock):
req_json_file = './conductor/tests/unit/data/demands.json'
req_json = yaml.safe_load(open(req_json_file).read())
+ ctxt = {
+ 'plan_id': uuid.uuid4(),
+ 'keyspace': cfg.CONF.keyspace
+ }
+ logutil_mock.return_value = uuid.uuid4()
ext_mock.return_value = []
expected_response = {'response': {'resolved_demands': None},
'error': True}
self.assertEqual(expected_response,
- self.data_ep.resolve_demands(None, req_json))
+ self.data_ep.resolve_demands(ctxt, req_json))
return_value = req_json['demands']['vG']
ext_mock.return_value = [return_value]
expected_response = {'response': {'resolved_demands': return_value},
'error': False}
self.assertEqual(expected_response,
- self.data_ep.resolve_demands(None, req_json))
+ self.data_ep.resolve_demands(ctxt, req_json))
if __name__ == "__main__":