def test_dir_listing_empty(self, mock_find_channels): mock_find_channels.return_value = [] stream = io.StringIO() dir_listing(stream, '/all/my/logs') response = stream.getvalue() self.assertNotIn('<h2>Active channels</h2>', response) self.assertNotIn('<h2>Old channels</h2>', response) self.assertIn('<p>No channels found.</p>', response)
def test_dir_listing_old(self, mock_find_channels): mock_find_channels.return_value = [ self.make_channel(name='#cobwebs', age=datetime.timedelta(days=7.5)), ] stream = io.StringIO() dir_listing(stream, '/all/my/logs') response = stream.getvalue() self.assertNotIn('<h2>Active channels</h2>', response) self.assertNotIn('<h2>Old channels</h2>', response) self.assertIn('#cobwebs', response)
def test_dir_listing_old_an_new(self, mock_find_channels): mock_find_channels.return_value = [ self.make_channel(name='#cobwebs', age=datetime.timedelta(days=7.5)), self.make_channel(name='#rainbows', age=datetime.timedelta(minutes=5)), self.make_channel(name='#puppies', age=datetime.timedelta(days=6.5)), ] stream = io.StringIO() dir_listing(stream, '/all/my/logs') response = stream.getvalue() self.assertIn('<h2>Active channels</h2>', response) self.assertIn('#rainbows', response) self.assertIn('#puppies', response) self.assertIn('<h2>Old channels</h2>', response) self.assertIn('#cobwebs', response) self.assertTrue( response.index('Active channels') < response.index('#rainbows') < response.index('#puppies') < response.index('Old channels') < response.index('#cobwebs') )
def test_dir_listing_old_an_new(self, mock_find_channels): mock_find_channels.return_value = [ self.make_channel(name='#cobwebs', age=datetime.timedelta(days=7.5)), self.make_channel(name='#rainbows', age=datetime.timedelta(minutes=5)), self.make_channel(name='#puppies', age=datetime.timedelta(days=6.5)), ] stream = io.StringIO() dir_listing(stream, '/all/my/logs') response = stream.getvalue() self.assertIn('<h2>Active channels</h2>', response) self.assertIn('#rainbows', response) self.assertIn('#puppies', response) self.assertIn('<h2>Old channels</h2>', response) self.assertIn('#cobwebs', response) self.assertTrue( response.index('Active channels') < response.index('#rainbows') < response.index('#puppies') < response.index( 'Old channels') < response.index('#cobwebs'))