1919from mock import MagicMock , patch
2020import logging
2121
22- from cloudify . exceptions import RecoverableError , NonRecoverableError
23- from cloudify . mocks import MockCloudifyContext
22+ from cloudify_rest import tasks
23+
2424from cloudify .state import current_ctx
2525from cloudify .manager import DirtyTrackingDict
26+ from cloudify .mocks import MockNodeContext , MockCloudifyContext
27+ from cloudify .exceptions import RecoverableError , NonRecoverableError
2628
27- from cloudify_rest import tasks
29+
30+ class MockNodeCtx (MockNodeContext ):
31+
32+ def __init__ (self , * _ , ** __ ):
33+ super ().__init__ (* _ , ** __ )
34+
35+ @property
36+ def type_hierarchy (self ):
37+ return [self ._type , 'cloudify.nodes.Root' ]
38+
39+
40+ class MockC1oudifyContext (MockCloudifyContext ):
41+ def __init__ (self , * _ , ** kwargs ):
42+ super ().__init__ (* _ , ** kwargs )
43+ node_name = kwargs .get ('node_name' )
44+ properties = kwargs .get ('properties' )
45+ node_type = kwargs .get ('node_type' )
46+ self ._node = MockNodeCtx (node_name , properties , node_type )
2847
2948
3049class TestPlugin (unittest .TestCase ):
3150
3251 def test_execute_mock_sdk (self ):
33- _ctx = MockCloudifyContext ('node_name' ,
52+ _ctx = MockC1oudifyContext ('node_name' ,
3453 properties = {'hosts' : ['--fake.cake--' ,
3554 'test123.test' ],
3655 'port' : - 1 ,
@@ -88,7 +107,7 @@ def test_execute_mock_sdk(self):
88107 prerender = None , resource_callback = _ctx .get_resource )
89108
90109 def test_execute_bunch_http_no_exception (self ):
91- _ctx = MockCloudifyContext ('node_name' ,
110+ _ctx = MockC1oudifyContext ('node_name' ,
92111 properties = {'hosts' : ['--fake.cake--' ,
93112 'test123.test' ],
94113 'port' : - 1 ,
@@ -150,7 +169,7 @@ def _match_request_text(request):
150169 'owner0' : {'colour' : 'black' , 'name' : 'book' }})
151170
152171 def test_execute_http_no_exception (self ):
153- _ctx = MockCloudifyContext ('node_name' ,
172+ _ctx = MockC1oudifyContext ('node_name' ,
154173 properties = {'hosts' : ['--fake.cake--' ,
155174 'test123.test' ],
156175 'port' : - 1 ,
@@ -206,7 +225,7 @@ def _match_request_text(request):
206225 'owner0' : {'colour' : 'black' , 'name' : 'book' }})
207226
208227 def test_execute_https_port_reco (self ):
209- _ctx = MockCloudifyContext ('node_name' ,
228+ _ctx = MockC1oudifyContext ('node_name' ,
210229 properties = {'host' : 'test123.test' ,
211230 'port' : 12345 ,
212231 'ssl' : 'true' ,
@@ -229,7 +248,7 @@ def test_execute_https_port_reco(self):
229248 'defined as recoverable' in str (context .exception ))
230249
231250 def test_execute_overwrite_host_response_expecation (self ):
232- _ctx = MockCloudifyContext ('node_name' ,
251+ _ctx = MockC1oudifyContext ('node_name' ,
233252 properties = {'hosts' : ['test123.test' ],
234253 'port' : 12345 ,
235254 'ssl' : 'true' ,
@@ -260,7 +279,7 @@ def test_execute_overwrite_host_response_expecation(self):
260279 str (context .exception ))
261280
262281 def test_execute_nonrecoverable_response (self ):
263- _ctx = MockCloudifyContext ('node_name' ,
282+ _ctx = MockC1oudifyContext ('node_name' ,
264283 properties = {'hosts' : ['test123.test' ],
265284 'port' : 12345 ,
266285 'ssl' : 'true' ,
@@ -289,7 +308,7 @@ def test_execute_nonrecoverable_response(self):
289308 str (context .exception ))
290309
291310 def test_execute_http_xml (self ):
292- _ctx = MockCloudifyContext ('node_name' ,
311+ _ctx = MockC1oudifyContext ('node_name' ,
293312 properties = {'hosts' : ['test123.test' ],
294313 'port' : - 1 ,
295314 'ssl' : False ,
@@ -318,7 +337,7 @@ def test_execute_http_xml(self):
318337 'CPUID' : 'ABS:FFF222777' })
319338
320339 def test_execute_jinja_block_parse (self ):
321- _ctx = MockCloudifyContext ('node_name' ,
340+ _ctx = MockC1oudifyContext ('node_name' ,
322341 properties = {'hosts' : ['test123.test' ],
323342 'port' : - 1 ,
324343 'ssl' : False ,
0 commit comments