def test_can_render_matches(self): """ Test we render properly when using matches """ os.environ['TERM'] = 'dumb' app = Logria(None, False, False) # Fake window size: 10 x 100 app.height = 10 app.width = 100 # Set fake previous render app.last_row = app.height - 3 # simulate the last row we can render to app.current_end = 80 # Simulate the last message rendered # Set fake messages app.messages = [f'{x}|{x}' for x in range(20)] # Set fake filter app.func_handle = regex_generator.regex_test_generator(r'\d\|\d') process_matches(app) # Set positional booleans app.manually_controlled_line = False app.stick_to_top = True app.stick_to_bottom = False start, end = determine_position(app, app.matched_rows) self.assertEqual(start, -1) self.assertEqual(end, 6) app.stop()
def test_process_matches(self): """ Test that we correctly process matches """ os.environ['TERM'] = 'dumb' app = Logria(None, False, False) # Fake window size: 10 x 100 app.height = 10 app.width = 100 # Set fake previous render app.last_row = app.height - 3 # simulate the last row we can render to app.current_end = 80 # Simulate the last message rendered # Set fake messages app.messages = [str(x) for x in range(20)] # Set regex function, process app.func_handle = regex_generator.regex_test_generator(r'\d') process_matches(app) self.assertEqual(app.messages, [str(x) for x in range(20)])