def test_fetch_all_messages_ununpickable(self): create_hostgroup_event('bar') broken = {'time': datetime.now().isoformat(), 'data': '))'.encode()} add_msg_to_queue(broken) msgs = _fetch_all_messages() self.assertEqual(1, len(msgs))
def test_fetch_all_messages_ununpickable(self): create_hostgroup_event('bar') broken = {'time': datetime.now().isoformat(), 'data': '))'} add_msg_to_queue(broken) msgs = _fetch_all_messages() self.assertEquals(1, len(msgs))
def test_update_hints(self): modules = ['foo', 'bar', 'baz1', 'baz2', 'm1', 'm2'] hgs = ['hg0', 'hg1', 'hg2', 'hg3', 'hg4'] for module in modules: create_module_event(module) for hg in hgs: create_hostgroup_event(hg) hints = fetch_update_hints(self.lock) for m in modules: self.assertTrue(m in hints['modules']) for h in hgs: self.assertTrue(h in hints['hostgroups']) self.assertTrue('common' in hints) self.assertEquals(0, len(hints['common'])) create_module_event('m1') create_common_event('baz') hints = fetch_update_hints(self.lock) self.assertTrue('hostgroups' in hints) self.assertEquals(0, len(hints['hostgroups'])) self.assertTrue('baz' in hints['common']) self.assertEquals(1, len(hints['modules'])) self.assertTrue('m1' in hints['modules'])
def test_update_hints(self): modules = ['foo', 'bar', 'baz1', 'baz2', 'm1', 'm2'] hgs = ['hg0', 'hg1', 'hg2', 'hg3', 'hg4'] for module in modules: create_module_event(module) for hg in hgs: create_hostgroup_event(hg) hints = fetch_update_hints() for m in modules: self.assertTrue(m in hints['modules']) for h in hgs: self.assertTrue(h in hints['hostgroups']) self.assertTrue('common' in hints) self.assertEqual(0, len(hints['common'])) create_module_event('m1') create_common_event('baz') hints = fetch_update_hints() self.assertTrue('hostgroups' in hints) self.assertEqual(0, len(hints['hostgroups'])) self.assertTrue('baz' in hints['common']) self.assertEqual(1, len(hints['modules'])) self.assertTrue('m1' in hints['modules'])
def test_fetch_all_messages_noerrors(self): create_module_event('foo') create_hostgroup_event('bar') msgs = _fetch_all_messages() self.assertEquals(2, len(msgs))
def test_count_some_messages_queue_error(self, mock_queue): create_hostgroup_event('bar') create_module_event('foo') self.assertRaises(JensMessagingError, count_pending_hints)
def test_count_some_messages(self): create_hostgroup_event('bar') create_module_event('foo') count = count_pending_hints() self.assertEquals(2, count)
def test_fetch_all_messages_noerrors(self): create_module_event('foo') create_hostgroup_event('bar') msgs = _fetch_all_messages() self.assertEqual(2, len(msgs))
def test_count_some_messages_queue_error(self, mock_queue): create_hostgroup_event('bar') create_module_event('foo') self.assertRaises(JensMessagingError, count_pending_hints)
def test_count_some_messages(self): create_hostgroup_event('bar') create_module_event('foo') count = count_pending_hints() self.assertEqual(2, count)