示例#1
0
 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'])
示例#2
0
 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'])
示例#3
0
 def test_fetch_all_messages_noerrors(self):
     create_module_event('foo')
     create_hostgroup_event('bar')
     msgs = _fetch_all_messages()
     self.assertEquals(2, len(msgs))
示例#4
0
 def test_update_hints_no_dups(self):
     create_module_event('foo')
     create_module_event('foo')
     hints = fetch_update_hints(self.lock)
     self.assertEquals(1, len(hints['modules']))
示例#5
0
 def test_count_some_messages_queue_error(self, mock_queue):
     create_hostgroup_event('bar')
     create_module_event('foo')
     self.assertRaises(JensMessagingError, count_pending_hints)
示例#6
0
 def test_count_some_messages(self):
     create_hostgroup_event('bar')
     create_module_event('foo')
     count = count_pending_hints()
     self.assertEquals(2, count)
示例#7
0
 def test_fetch_all_messages_ioerror_when_dequeuing(self, mock_queue):
     create_module_event('foo')
     msgs = _fetch_all_messages()
     self.assertLogErrors()
     mock_queue.assert_called_once()
     self.assertEquals(0, len(msgs))
示例#8
0
 def test_fetch_all_messages_locked_item(self, mock_queue):
     create_module_event('foo')
     msgs = _fetch_all_messages()
     self.assertEquals(0, len(msgs))
     mock_queue.assert_called_once()
示例#9
0
 def test_fetch_all_messages_noerrors(self):
     create_module_event('foo')
     create_hostgroup_event('bar')
     msgs = _fetch_all_messages()
     self.assertEqual(2, len(msgs))
示例#10
0
 def test_update_hints_no_dups(self):
     create_module_event('foo')
     create_module_event('foo')
     hints = fetch_update_hints()
     self.assertEqual(1, len(hints['modules']))
示例#11
0
 def test_count_some_messages_queue_error(self, mock_queue):
     create_hostgroup_event('bar')
     create_module_event('foo')
     self.assertRaises(JensMessagingError, count_pending_hints)
示例#12
0
 def test_count_some_messages(self):
     create_hostgroup_event('bar')
     create_module_event('foo')
     count = count_pending_hints()
     self.assertEqual(2, count)
示例#13
0
 def test_fetch_all_messages_ioerror_when_dequeuing(self, mock_queue):
     create_module_event('foo')
     msgs = _fetch_all_messages()
     self.assertLogErrors()
     mock_queue.assert_called_once()
     self.assertEqual(0, len(msgs))
示例#14
0
 def test_fetch_all_messages_locked_item(self, mock_queue):
     create_module_event('foo')
     msgs = _fetch_all_messages()
     self.assertEqual(0, len(msgs))
     mock_queue.assert_called_once()
示例#15
0
 def test_update_hints_no_dups(self):
     create_module_event(self.settings, 'foo')
     create_module_event(self.settings, 'foo')
     hints = fetch_update_hints(self.settings, self.lock)
     self.assertEquals(1, len(hints['modules']))