Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: recipe_engine/unittests/stream_test.py

Issue 2792333003: Assert validity of stream parameters. (Closed)
Patch Set: fix spelling Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « recipe_engine/stream.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2015 The LUCI Authors. All rights reserved. 2 # Copyright 2015 The LUCI Authors. All rights reserved.
3 # Use of this source code is governed under the Apache License, Version 2.0 3 # Use of this source code is governed under the Apache License, Version 2.0
4 # that can be found in the LICENSE file. 4 # that can be found in the LICENSE file.
5 5
6 import cStringIO 6 import cStringIO
7 import unittest 7 import unittest
8 8
9 import test_env 9 import test_env
10 10
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 with self.assertRaises(AssertionError): 154 with self.assertRaises(AssertionError):
155 foo.set_step_status('SINGLE') 155 foo.set_step_status('SINGLE')
156 156
157 def test_buildbot_status_constraint(self): 157 def test_buildbot_status_constraint(self):
158 with stream.StreamEngineInvariants() as engine: 158 with stream.StreamEngineInvariants() as engine:
159 foo = engine.make_step_stream('foo') 159 foo = engine.make_step_stream('foo')
160 foo.set_step_status('FAILURE') 160 foo.set_step_status('FAILURE')
161 with self.assertRaises(AssertionError): 161 with self.assertRaises(AssertionError):
162 foo.set_step_status('SUCCESS') 162 foo.set_step_status('SUCCESS')
163 163
164 def test_content_assertions(self):
165 with stream.StreamEngineInvariants() as engine:
166 with self.assertRaises(ValueError):
167 engine.make_step_stream('foo\nbar')
168
169 # Test StepStream.
170 s = engine.make_step_stream('foo')
171 with self.assertRaises(ValueError):
172 s.new_log_stream('foo\nbar')
173 ls = s.new_log_stream('foo')
174
175 with self.assertRaises(ValueError):
176 s.add_step_text('foo\nbar')
177 s.add_step_text('foo')
178
179 with self.assertRaises(ValueError):
180 s.add_step_summary_text('foo\nbar')
181 s.add_step_summary_text('foo')
182
183 with self.assertRaises(ValueError):
184 s.add_step_link('foo\nbar', 'baz')
185 with self.assertRaises(ValueError):
186 s.add_step_link('foo', 'bar\nbaz')
187 s.add_step_link('foo', 'bar')
188
189 with self.assertRaises(ValueError):
190 s.set_build_property('foo\nbar', 'true')
191 with self.assertRaises(ValueError):
192 s.set_build_property('foo', 'true\n')
193 with self.assertRaises(ValueError):
194 s.set_build_property('foo', 'NOT JSON')
195 s.set_build_property('foo', '"Is JSON"')
196
197 with self.assertRaises(ValueError):
198 s.trigger('true\n')
199 with self.assertRaises(ValueError):
200 s.trigger('NOT JSON')
201 s.trigger('"Is JSON"')
202
203 ls.close()
204 s.close()
205
206
164 if __name__ == '__main__': 207 if __name__ == '__main__':
165 unittest.main() 208 unittest.main()
OLDNEW
« no previous file with comments | « recipe_engine/stream.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698