From 70808672498af9d32e34d0f0db68f2e0e15cefa9 Mon Sep 17 00:00:00 2001 From: Viktor Stanchev Date: Sun, 20 Sep 2015 14:47:20 -0700 Subject: [PATCH] test color toggle --- tests/test_print.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/tests/test_print.py b/tests/test_print.py index 52c0bfb..52b9c5a 100755 --- a/tests/test_print.py +++ b/tests/test_print.py @@ -37,10 +37,32 @@ class TestPrint(unittest.TestCase): results = [{ 'magnet': 'dn=name', 'Name': 'name', + },{ + 'magnet': 'dn=name2', + 'Name': 'name2', }] printer.search_results(results, local=True) prettytable.assert_called_once_with(['LINK', 'NAME']) - mock.add_row.assert_has_calls([call([0, 'name'])]) + mock.add_row.assert_has_calls([call([0, 'name']), call([1, 'name2'])]) + + def test_print_results_local(self): + class MockTable: + add_row = MagicMock() + align = {} + mock = MockTable() + printer = Printer(True) + printer.print = MagicMock() + with patch('veryprettytable.VeryPrettyTable', return_value=mock) as prettytable: + results = [{ + 'magnet': 'dn=name', + 'Name': 'name', + },{ + 'magnet': 'dn=name2', + 'Name': 'name2', + }] + printer.search_results(results, local=True) + prettytable.assert_called_once_with(['LINK', 'NAME']) + mock.add_row.assert_has_calls([call([0, 'name']), call([1, 'name2'], fore_color='blue')]) def test_print_descriptions(self): printer = Printer(False)