def test_status_all_down(self): self.assertEqual(len(list(spool.status_all_down())), 0) spool.down('foo') self.assertEqual(list(spool.status_all_down()), [('foo', { 'service': 'foo', 'reason': '' })])
def test_status_all_down(self): self.assertEqual(len(list(spool.status_all_down())), 0) spool.down('foo') self.assertEqual( list(spool.status_all_down()), [('foo', None, {'service': 'foo', 'reason': '', 'expiration': None, 'creation': mock.ANY})] )
def test_basic(self): svcname = 'test_basic' self.assertEquals(True, spool.status(svcname)[0]) spool.down(svcname) self.assertEquals(False, spool.status(svcname)[0]) self.assertEquals(False, spool.is_up(svcname)[0]) spool.up(svcname) self.assertEquals(True, spool.status(svcname)[0])
def test_status_creation(self): now = 1000 svcname = 'test_status_creation' with mock.patch('time.time', return_value=now): spool.down(svcname) up, info_dict = spool.status(svcname) spool.up(svcname) self.assertEqual(info_dict['creation'], 1000)
def test_repeated_downs_with_creation_arg_changes_creation_time(self): first_creation = 1000 first_expiration = first_creation + 60 second_creation = first_creation + 10 second_expiration = second_creation + 60 spool.down('all', creation=first_creation, expiration=first_expiration) spool.down('all', creation=second_creation, expiration=second_expiration) with mock.patch('time.time', return_value=second_creation): _, info = spool.status('all') self.assertEquals(info['creation'], second_creation) self.assertEquals(info['expiration'], second_expiration)
def test_repeated_downs_leaves_original_creation_time(self): first_creation = 1000 first_expiration = first_creation + 60 second_creation = first_creation + 10 second_expiration = second_creation + 60 with mock.patch('time.time', return_value=first_creation): spool.down('all', expiration=first_expiration) with mock.patch('time.time', return_value=second_creation): spool.down('all', expiration=second_expiration) with mock.patch('time.time', return_value=second_creation): _, info = spool.status('all') self.assertEquals(info['creation'], first_creation) self.assertEquals(info['expiration'], second_expiration)
def test_status_expiration(self): svcname = 'test_status_expiration' now = 1000 future = now + 10 past = now - 10 with mock.patch('time.time', return_value=now): self.assertEquals(True, spool.status(svcname)[0]) # First, check with expiration in future; everything should behave normally. spool.down(svcname, expiration=future) self.assertEquals(False, spool.status(svcname)[0]) # Now, let's make sure we remove the spool file if its expiration is in the past. spool.down(svcname, expiration=past) self.assertEquals(True, os.path.exists(spool.spool_file_path(svcname, None))) self.assertEquals(True, spool.status(svcname)[0]) self.assertEquals(False, os.path.exists(spool.spool_file_path(svcname, None)))
def test_basic(self): svcname = 'test_basic' self.assertEquals(True, spool.status(svcname)[0]) self.assertEquals(True, spool.status(svcname, 1234)[0]) self.assertEquals(True, spool.status(svcname, 1234, '10.93.10.1')[0]) spool.down(svcname, port=1234) self.assertEquals(True, spool.status(svcname)[0]) self.assertEquals(False, spool.status(svcname, 1234)[0]) self.assertEquals(True, spool.status(svcname, 1234, '10.93.10.1')[0]) spool.down(svcname) self.assertEquals(False, spool.status(svcname)[0]) self.assertEquals(False, spool.is_up(svcname)[0]) self.assertEquals(False, spool.is_up(svcname, 1234, '10.93.10.1')[0]) spool.up(svcname, port=1234) self.assertEquals(True, spool.status(svcname, 1234)[0]) spool.up(svcname, port=1234, host='10.93.10.1') self.assertEquals(True, spool.status(svcname, 1234, '10.93.10.1')[0]) spool.up(svcname) self.assertEquals(True, spool.status(svcname)[0])
def test_all(self): svcname = 'test_all' self.assertEquals(True, spool.status(svcname)[0]) spool.down('all') self.assertEquals(True, spool.status(svcname)[0]) self.assertEquals(False, spool.is_up(svcname)[0])
def test_status_all_down(self): self.assertEqual(len(list(spool.status_all_down())), 0) spool.down('foo') self.assertEqual(list(spool.status_all_down()), [('foo', {'service': 'foo', 'reason': ''})])