114
117
def test_make_http_check(self):
115
118
result = make_http_check('http://localhost/')
116
self.assertThat(result,
117
MultiCheckMatcher(strategy=sequential_strategy,
119
FunctionCheckMatcher('tcp:localhost:80', 'localhost:80'),
120
FunctionCheckMatcher('http:http://localhost/', 'GET http://localhost/')
119
self.assertIsInstance(result, PrefixCheckWrapper)
120
self.assertEqual(result.prefix, 'http:http://localhost/:')
121
wrapped = result.wrapped
122
self.assertIsInstance(wrapped, MultiCheck)
123
self.assertIs(wrapped.strategy, sequential_strategy)
124
self.assertEqual(len(wrapped.subchecks), 2)
125
self.assertThat(wrapped.subchecks[0],
126
FunctionCheckMatcher('tcp:localhost:80', 'localhost:80'))
127
self.assertThat(wrapped.subchecks[1],
128
FunctionCheckMatcher('', 'GET http://localhost/'))
124
130
def test_make_http_check_https(self):
125
131
result = make_http_check('https://localhost/')
126
self.assertThat(result,
127
MultiCheckMatcher(strategy=sequential_strategy,
129
FunctionCheckMatcher('tcp:localhost:443', 'localhost:443'),
130
FunctionCheckMatcher('http:https://localhost/', 'GET https://localhost/')
132
self.assertIsInstance(result, PrefixCheckWrapper)
133
self.assertEqual(result.prefix, 'http:https://localhost/:')
134
wrapped = result.wrapped
135
self.assertIsInstance(wrapped, MultiCheck)
136
self.assertIs(wrapped.strategy, sequential_strategy)
137
self.assertEqual(len(wrapped.subchecks), 2)
138
self.assertThat(wrapped.subchecks[0],
139
FunctionCheckMatcher('tcp:localhost:443', 'localhost:443'))
140
self.assertThat(wrapped.subchecks[1],
141
FunctionCheckMatcher('', 'GET https://localhost/'))
134
143
def test_make_amqp_check(self):
135
144
result = make_amqp_check('localhost', 8080, 'foo',
264
273
self.assertThat(result,
265
274
MultiCheckMatcher(strategy=parallel_strategy,
266
275
subchecks=[FunctionCheckMatcher('tcp:localhost:8080', 'localhost:8080')]))
277
def test_ordered_output(self):
279
'SKIPPED: xyz3:localhost:666\n',
280
'bar2:localhost:8080 FAILED: error\n',
281
'SKIPPED: foo2:localhost:8080\n',
282
'baz2:localhost:42 OK\n',
283
'SKIPPED: bar2:localhost:8080\n',
284
'xyz2:localhost:666 FAILED: error\n',
285
'xyz1:localhost:666 OK\n',
286
'foo1:localhost:8080 FAILED: error\n',
287
'baz1:localhost:42 OK\n',
290
'bar2:localhost:8080 FAILED: error\n'
291
'foo1:localhost:8080 FAILED: error\n'
292
'xyz2:localhost:666 FAILED: error\n'
293
'baz1:localhost:42 OK\n'
294
'baz2:localhost:42 OK\n'
295
'xyz1:localhost:666 OK\n'
296
'SKIPPED: bar2:localhost:8080\n'
297
'SKIPPED: foo2:localhost:8080\n'
298
'SKIPPED: xyz3:localhost:666\n'
301
output = OrderedOutput(StringIO())
302
map(output.write, lines)
304
self.assertEqual(expected, output.output.getvalue())
306
output = OrderedOutput(StringIO())
307
random.shuffle(lines)
308
map(output.write, lines)
310
self.assertEqual(expected, output.output.getvalue())