@@ -47,7 +47,7 @@ def test_missing_input_keys(self):
4747 ConfigNode ('test3' , {'apiVersion' : '' })]
4848 for exec_config in exec_configs :
4949 with self .assertRaises (ConfigException ) as context :
50- ExecProvider (exec_config )
50+ ExecProvider (exec_config , None )
5151 self .assertIn ('exec: malformed request. missing key' ,
5252 context .exception .args [0 ])
5353
@@ -57,7 +57,7 @@ def test_error_code_returned(self, mock):
5757 instance .wait .return_value = 1
5858 instance .communicate .return_value = ('' , '' )
5959 with self .assertRaises (ConfigException ) as context :
60- ep = ExecProvider (self .input_ok )
60+ ep = ExecProvider (self .input_ok , None )
6161 ep .run ()
6262 self .assertIn ('exec: process returned %d' %
6363 instance .wait .return_value , context .exception .args [0 ])
@@ -68,7 +68,7 @@ def test_nonjson_output_returned(self, mock):
6868 instance .wait .return_value = 0
6969 instance .communicate .return_value = ('' , '' )
7070 with self .assertRaises (ConfigException ) as context :
71- ep = ExecProvider (self .input_ok )
71+ ep = ExecProvider (self .input_ok , None )
7272 ep .run ()
7373 self .assertIn ('exec: failed to decode process output' ,
7474 context .exception .args [0 ])
@@ -102,7 +102,7 @@ def test_missing_output_keys(self, mock):
102102 for output in outputs :
103103 instance .communicate .return_value = (output , '' )
104104 with self .assertRaises (ConfigException ) as context :
105- ep = ExecProvider (self .input_ok )
105+ ep = ExecProvider (self .input_ok , None )
106106 ep .run ()
107107 self .assertIn ('exec: malformed response. missing key' ,
108108 context .exception .args [0 ])
@@ -123,7 +123,7 @@ def test_mismatched_api_version(self, mock):
123123 """ % wrong_api_version
124124 instance .communicate .return_value = (output , '' )
125125 with self .assertRaises (ConfigException ) as context :
126- ep = ExecProvider (self .input_ok )
126+ ep = ExecProvider (self .input_ok , None )
127127 ep .run ()
128128 self .assertIn (
129129 'exec: plugin api version %s does not match' %
@@ -135,11 +135,20 @@ def test_ok_01(self, mock):
135135 instance = mock .return_value
136136 instance .wait .return_value = 0
137137 instance .communicate .return_value = (self .output_ok , '' )
138- ep = ExecProvider (self .input_ok )
138+ ep = ExecProvider (self .input_ok , None )
139139 result = ep .run ()
140140 self .assertTrue (isinstance (result , dict ))
141141 self .assertTrue ('token' in result )
142142
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+
143152
144153if __name__ == '__main__' :
145154 unittest .main ()
0 commit comments