@@ -99,13 +99,19 @@ def test_connector_validation(AppSettings):
9999 assert 'Not yet implemented' in result .stdout
100100
101101
102- def test_connector_run (AppSettings , main ):
102+ def test_connector_run (AppSettings , main , caplog ):
103103 connector = Connector (settings = AppSettings )
104104 connector .job (main )
105- result = runner .invoke (connector .app , ['run' , '-j' , '{"is_bool": true}' ])
106- assert result .exit_code == 0
107- assert 'hello world' in result .stdout
108- assert 'Did not initiate a callback!' in result .stdout
105+ with caplog .at_level (logging .INFO ):
106+ result = runner .invoke (connector .app , ['run' , '-j' , '{"is_bool": true}' ])
107+ assert result .exit_code == 0
108+ assert 'hello world' in result .stdout
109+ assert 'This is a debug test' not in caplog .text
110+ assert 'This is an info test' in caplog .text
111+ assert 'This is an error test' in caplog .text
112+ assert 'Job response format is invalid' in caplog .text
113+ assert 'Did not initiate a callback!' in caplog .text
114+ assert 'callback={' in result .stdout
109115
110116
111117def test_connector_run_config_fail (AppSettings , main ):
@@ -115,39 +121,42 @@ def test_connector_run_config_fail(AppSettings, main):
115121 assert result .exit_code == 2
116122
117123
118- def test_connector_run_fail (AppSettings ):
124+ def test_connector_run_fail (AppSettings , caplog ):
119125 connector = Connector (settings = AppSettings )
120126
121127 @connector .job
122128 def failmain (config : dict , since : None = None ):
123129 raise Exception ('I have failed' )
124130
125- result = runner .invoke (connector .app , ['run' , '-j' , '{"is_bool": true}' ])
126- assert result .exit_code == 1
127- assert 'I have failed' in result .stdout
131+ with caplog .at_level (logging .INFO ):
132+ result = runner .invoke (connector .app , ['run' , '-j' , '{"is_bool": true}' ])
133+ assert result .exit_code == 1
134+ assert 'I have failed' in caplog .text
128135
129136
130137@responses .activate
131- def test_connector_callback (AppSettings , main ):
138+ def test_connector_callback (AppSettings , main , caplog ):
132139 responses .post (
133140 'http://callback-url.local/callback' ,
134141 match = [matchers .header_matcher ({'X-Job-ID' : 'abcdef' })],
135142 )
136143 connector = Connector (settings = AppSettings )
137144 connector .job (main )
138- result = runner .invoke (
139- connector .app ,
140- [
141- 'run' ,
142- '-j' ,
143- '{"is_bool": true}' ,
144- '-J' ,
145- 'abcdef' ,
146- '-c' ,
147- 'http://callback-url.local/callback' ,
148- ],
149- )
150- assert result .exit_code == 0
151- assert 'Called back' in result .stdout
152- assert "callback_url='http://callback-url.local/callback'" in result .stdout
153- assert "job_id='abcdef'" in result .stdout
145+
146+ with caplog .at_level (logging .INFO ):
147+ result = runner .invoke (
148+ connector .app ,
149+ [
150+ 'run' ,
151+ '-j' ,
152+ '{"is_bool": true}' ,
153+ '-J' ,
154+ 'abcdef' ,
155+ '-c' ,
156+ 'http://callback-url.local/callback' ,
157+ ],
158+ )
159+ assert result .exit_code == 0
160+ assert 'Called back' in caplog .text
161+ assert "callback_url='http://callback-url.local/callback'" in caplog .text
162+ assert "job_id='abcdef'" in caplog .text
0 commit comments