def test_basic(self): from rezoirclogs.views import logfile context = DummyIterable([DummyObject() for i in range(3)]) request = self._get_request() result = logfile(context, request) self.assertEqual(result['context'], context) self.assertListEqual(result['lines'], context.value)
def test_range(self): from rezoirclogs.views import logfile context = DummyIterable([DummyObject() for i in range(10)]) request = self._get_request() request.GET['range'] = '2-5' result = logfile(context, request) for i in xrange(2, 5): self.assertEqual(result['lines'][i].highlighted, True)
def test_select(self): from rezoirclogs.views import logfile context = DummyIterable([DummyObject() for i in range(10)]) for d in context: d.time = 'notNone' request = self._get_request() request.GET.add('select', '2') result = logfile(context, request) self.assertEqual(result['lines'][5].anchorlink, 'http://example.com/?range=2-6#2')
def test_range_buggy_get(self): from rezoirclogs.views import logfile context = DummyIterable([DummyObject() for i in range(10)]) request = self._get_request() request.GET.add('range', '10-15') request.GET.add('range', 'tagada') request.GET.add('range', '10-12-12') result = logfile(context, request) for obj in result['lines']: self.assertFalse(hasattr(obj, 'highlighted'))
def test_anchor_link(self): from rezoirclogs.views import logfile line = DummyObject() line.time = 'outatime' context = DummyIterable([line]) request = self._get_request() result = logfile(context, request) resulting_line = result['lines'][0] self.assertEqual(resulting_line.anchor, '0') self.assertEqual(resulting_line.anchorlink, 'http://example.com/?select=0#0')