~bloodearnest/conn-check/1.5.1

« back to all changes in this revision

Viewing changes to tests.py

  • Committer: Tarmac
  • Author(s): Wes Mason
  • Date: 2014-10-29 16:20:19 UTC
  • mfrom: (79.1.10 mongodb)
  • Revision ID: tarmac-20141029162019-g2wcrsq3s5gk32g6
[r=james-w] Add a MongoDB check type

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
    make_amqp_check,
17
17
    make_http_check,
18
18
    make_memcache_check,
 
19
    make_mongodb_check,
19
20
    make_postgres_check,
20
21
    make_redis_check,
21
22
    make_tls_check,
211
212
                FunctionCheckMatcher('tcp:localhost:8080', 'localhost:8080'))
212
213
        self.assertThat(wrapped.subchecks[1], FunctionCheckMatcher('connect', None))
213
214
 
 
215
    def test_make_mongodb_check(self):
 
216
        result = make_mongodb_check('localhost', 8080)
 
217
        self.assertIsInstance(result, PrefixCheckWrapper)
 
218
        self.assertEqual(result.prefix, 'mongodb:localhost:8080:')
 
219
        wrapped = result.wrapped
 
220
        self.assertIsInstance(wrapped, MultiCheck)
 
221
        self.assertIs(wrapped.strategy, sequential_strategy)
 
222
        self.assertEqual(len(wrapped.subchecks), 2)
 
223
        self.assertThat(wrapped.subchecks[0],
 
224
                FunctionCheckMatcher('tcp:localhost:8080', 'localhost:8080'))
 
225
        self.assertThat(wrapped.subchecks[1], FunctionCheckMatcher('connect', None))
 
226
 
 
227
    def test_make_mongodb_check_with_username(self):
 
228
        result = make_mongodb_check('localhost', 8080, 'foo')
 
229
        self.assertIsInstance(result, PrefixCheckWrapper)
 
230
        self.assertEqual(result.prefix, 'mongodb:localhost:8080:')
 
231
        wrapped = result.wrapped
 
232
        self.assertIsInstance(wrapped, MultiCheck)
 
233
        self.assertIs(wrapped.strategy, sequential_strategy)
 
234
        self.assertEqual(len(wrapped.subchecks), 2)
 
235
        self.assertThat(wrapped.subchecks[0],
 
236
                FunctionCheckMatcher('tcp:localhost:8080', 'localhost:8080'))
 
237
        self.assertThat(wrapped.subchecks[1],
 
238
                FunctionCheckMatcher('connect with auth', None))
 
239
 
214
240
    def test_check_from_description_unknown_type(self):
215
241
        e = self.assertRaises(AssertionError,
216
242
                              check_from_description, {'type': 'foo'})