# -*- coding: utf-8 -*-
"""
consolor

Copyright (c) 2013, Friedrich Paetzke (f.paetzke@gmail.com)
All rights reserved.

"""
import unittest

import consolor


class TestConsolor(unittest.TestCase):

    def test_print_bold(self):
        result = consolor.get_line('123 bold', bold=True)
        expected = '\x1b[1m123 bold\x1b[0m'
        self.assertEqual(result, expected)

    def test_print_underline(self):
        result = consolor.get_line('123 underline', underline=True)
        expected = '\x1b[4m123 underline\x1b[0m'
        self.assertEqual(result, expected)

    def test_get_bgcolor(self):
        result = consolor.get_line('123 green bg', bgcolor=consolor.BgColor.Green)
        expected = '\x1b[42;1m123 green bg\x1b[0m'
        self.assertEqual(result, expected)

    def test_get_color(self):
        result = consolor.get_line('123 light green', color=consolor.Color.LightGreen)
        expected = '\x1b[1;32m123 light green\x1b[0m'
        self.assertEqual(result, expected)

    def test_update_line(self):
        for i in reversed(range(101)):
            line = consolor.get_line('123%d' % i, update_line=True)
            expected = '\x1b[2K\r%s%d\x1b[0m' % ('123', i)
            self.assertEqual(line, expected)

@@ -121,40 +121,245 @@
 %22%22%22%0A
-import unittest%0A%0Aimport consolor
+from __future__ import print_function%0Aimport unittest%0A%0Aimport consolor%0A%0Atry:%0A    from unittest.mock import call, patch%0Aexcept ImportError:%0A    from mock import call, patch%0A%0A%0Adef mockable_print(*args, **kwargs):%0A    print(*args, **kwargs)
 %0A%0A%0Ac
@@ -1427,20 +1427,2308 @@
 ual(line, expected)%0A
+%0A    def test_print_color(self):%0A        with patch('tests.test_consolor.mockable_print') as mocked_print:%0A            mockable_print(consolor.Color.Red, 'Red')%0A            mockable_print('Red two')%0A            mockable_print(consolor.Color.Reset, end='')%0A            mockable_print('Not Red')%0A%0A            mocked_print.assert_has_calls(%5Bcall('%5Cx1b%5B0;31m', 'Red'),%0A                                           call('Red two'),%0A                                           call('%5Cx1b%5B0m', end=''),%0A                                           call('Not Red')%5D)%0A%0A    def test_print_concat_color(self):%0A        with patch('tests.test_consolor.mockable_print') as mocked_print:%0A            mockable_print(consolor.Color.Red, 'Red')%0A            mockable_print('Red two')%0A            mockable_print(consolor.Color.Blue, 'Blue')%0A            mockable_print(consolor.Color.Reset, end='')%0A            mockable_print('Not Blue')%0A%0A            mocked_print.assert_has_calls(%5Bcall('%5Cx1b%5B0;31m', 'Red'),%0A                                           call('Red two'),%0A                                           call('%5Cx1b%5B0;34m', 'Blue'),%0A                                           call('%5Cx1b%5B0m', end=''),%0A                                           call('Not Blue')%5D)%0A%0A    def test_print_bgcolor(self):%0A        with patch('tests.test_consolor.mockable_print') as mocked_print:%0A            mockable_print(consolor.BgColor.Red, 'Red')%0A            mockable_print('Red two', consolor.BgColor.Reset)%0A            mockable_print('None')%0A%0A            mocked_print.assert_has_calls(%5Bcall('%5Cx1b%5B41;1m', 'Red'),%0A                                           call('Red two', '%5Cx1b%5B0m'),%0A                                           call('None')%5D)%0A%0A    def test_print_concat_bgcolor(self):%0A        with patch('tests.test_consolor.mockable_print') as mocked_print:%0A            mockable_print(consolor.BgColor.Red, 'Red')%0A            mockable_print('Red two')%0A            mockable_print(consolor.BgColor.Cyan, 'None')%0A            mockable_print(consolor.BgColor.Reset)%0A%0A            mocked_print.assert_has_calls(%5Bcall('%5Cx1b%5B41;1m', 'Red'),%0A                                           call('Red two'),%0A                                           call('%5Cx1b%5B46;1m', 'None'),%0A                                           call('%5Cx1b%5B0m')%5D)%0A

Add tests for using coloring in builtin print().