Exemplo n.º 1
0
    def test_check_messages(self):
        m = StatusMessageMatcher()

        assert m.check_messages('ready', ['ready'])
        assert m.check_messages('ready', ['ready', 'ready'])
        assert not m.check_messages('ready', ['ready', 'ok'])
        assert not m.check_messages('ready', [])
Exemplo n.º 2
0
 def test_check_message(self):
     m = StatusMessageMatcher()
     r = re.compile
     self.assertEqual(0, m.check_message('bar', 'foo'))
     self.assertEqual(3, m.check_message('foo', 'foo'))
     self.assertEqual(3, m.check_message(r('foo'), 'foo'))
     self.assertEqual(3, m.check_message(r('foo'), 'foobar'))
     self.assertEqual(3, m.check_message(r('f..'), 'foo'))
     self.assertEqual(0, m.check_message(r('b..'), 'foo'))
Exemplo n.º 3
0
    def test_check_set(self):
        m = StatusMessageMatcher()

        assert m.check_set({'ready'}, ['ready'])
        assert m.check_set({'ready'}, ['ready', 'ok'])
        assert m.check_set({'ready', 'ok'}, ['ready', 'ok'])
        assert not m.check_set({'ready', 'ok'}, ['ready', 'ready'])
        assert not m.check_set({'ok'}, ['ready', 'ready'])
        assert not m.check_set({'ready'}, [])
Exemplo n.º 4
0
    def test_check_list(self):
        m = StatusMessageMatcher()
        r = re.compile

        assert m.check_list(['ready'], ['ready'])
        assert not m.check_list(['ready', 'ready'], ['ready'])  # too few
        assert not m.check_list(['ready'], ['ready', 'ready'])  # too many
        assert m.check_list(['ready', 'ready', 'ok'], ['ready', 'ok', 'ready'])
        assert not m.check_list(['ready', 'ready', 'ok'],
                                ['ready', 'ok', 'ok'])
        assert m.check_list([r('ready(ish)?')], ['ready'])
        assert m.check_list([r('ready(ish)?')], ['readyish'])
        assert m.check_list([r('ready(ish)?'), 'ready'],
                            ['ready', 'readyish'])  # ambiguous-ish
        assert m.check_list([r('ready(ish)?'), 'ready'],
                            ['readyish', 'ready'])  # ambiguous-ish
Exemplo n.º 5
0
    def test_check(self):
        m = StatusMessageMatcher()
        m.check_messages = Mock()
        m.check_set = Mock()
        m.check_list = Mock()

        m.check('ready', ['ready'])
        m.check(re.compile('ready'), ['ready'])
        self.assertEqual(m.check_messages.call_count, 2)

        m.check({'ready'}, ['ready'])
        self.assertEqual(m.check_set.call_count, 1)

        m.check(['ready'], ['ready'])
        m.check(('ready', ), ['ready'])
        self.assertEqual(m.check_list.call_count, 2)