@@ -47,7 +47,7 @@ def test_missing_input_keys(self):
47
47
ConfigNode ('test3' , {'apiVersion' : '' })]
48
48
for exec_config in exec_configs :
49
49
with self .assertRaises (ConfigException ) as context :
50
- ExecProvider (exec_config )
50
+ ExecProvider (exec_config , None )
51
51
self .assertIn ('exec: malformed request. missing key' ,
52
52
context .exception .args [0 ])
53
53
@@ -57,7 +57,7 @@ def test_error_code_returned(self, mock):
57
57
instance .wait .return_value = 1
58
58
instance .communicate .return_value = ('' , '' )
59
59
with self .assertRaises (ConfigException ) as context :
60
- ep = ExecProvider (self .input_ok )
60
+ ep = ExecProvider (self .input_ok , None )
61
61
ep .run ()
62
62
self .assertIn ('exec: process returned %d' %
63
63
instance .wait .return_value , context .exception .args [0 ])
@@ -68,7 +68,7 @@ def test_nonjson_output_returned(self, mock):
68
68
instance .wait .return_value = 0
69
69
instance .communicate .return_value = ('' , '' )
70
70
with self .assertRaises (ConfigException ) as context :
71
- ep = ExecProvider (self .input_ok )
71
+ ep = ExecProvider (self .input_ok , None )
72
72
ep .run ()
73
73
self .assertIn ('exec: failed to decode process output' ,
74
74
context .exception .args [0 ])
@@ -102,7 +102,7 @@ def test_missing_output_keys(self, mock):
102
102
for output in outputs :
103
103
instance .communicate .return_value = (output , '' )
104
104
with self .assertRaises (ConfigException ) as context :
105
- ep = ExecProvider (self .input_ok )
105
+ ep = ExecProvider (self .input_ok , None )
106
106
ep .run ()
107
107
self .assertIn ('exec: malformed response. missing key' ,
108
108
context .exception .args [0 ])
@@ -123,7 +123,7 @@ def test_mismatched_api_version(self, mock):
123
123
""" % wrong_api_version
124
124
instance .communicate .return_value = (output , '' )
125
125
with self .assertRaises (ConfigException ) as context :
126
- ep = ExecProvider (self .input_ok )
126
+ ep = ExecProvider (self .input_ok , None )
127
127
ep .run ()
128
128
self .assertIn (
129
129
'exec: plugin api version %s does not match' %
@@ -135,11 +135,20 @@ def test_ok_01(self, mock):
135
135
instance = mock .return_value
136
136
instance .wait .return_value = 0
137
137
instance .communicate .return_value = (self .output_ok , '' )
138
- ep = ExecProvider (self .input_ok )
138
+ ep = ExecProvider (self .input_ok , None )
139
139
result = ep .run ()
140
140
self .assertTrue (isinstance (result , dict ))
141
141
self .assertTrue ('token' in result )
142
142
143
+ @mock .patch ('subprocess.Popen' )
144
+ def test_run_in_dir (self , mock ):
145
+ instance = mock .return_value
146
+ instance .wait .return_value = 0
147
+ instance .communicate .return_value = (self .output_ok , '' )
148
+ ep = ExecProvider (self .input_ok , '/some/directory' )
149
+ ep .run ()
150
+ self .assertEqual (mock .call_args .kwargs ['cwd' ], '/some/directory' )
151
+
143
152
144
153
if __name__ == '__main__' :
145
154
unittest .main ()
0 commit comments