Package libxyz :: Package ui :: Module tests

[hide private]
[frames] | no frames]

# Source Code for Module libxyz.ui.tests

      1  #-*- coding: utf8 -*
      2  #
      3  # Max E. Kuznecov ~syhpoon <mek@mek.uz.ua> 2008-2009
      4  #
      5  # This file is part of XYZCommander.
      6  # XYZCommander is free software: you can redistribute it and/or modify
      7  # it under the terms of the GNU Lesser Public License as published by
      8  # the Free Software Foundation, either version 3 of the License, or
      9  # (at your option) any later version.
     10  # XYZCommander is distributed in the hope that it will be useful,
     11  # but WITHOUT ANY WARRANTY; without even the implied warranty of
     12  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     13  # GNU Lesser Public License for more details.
     14  # You should have received a copy of the GNU Lesser Public License
     15  # along with XYZCommander. If not, see <http://www.gnu.org/licenses/>.
     16
     17  # UI tests
     18
     19  from nose.tools import raises
     20
     21  from libxyz.ui import colors
     22  from libxyz.exceptions import XYZValueError
     23
     24  import __builtin__
     25  import locale
     26
     27 -def setup():
     28      __builtin__._ = lambda x: x
     29      __builtin__.xyzenc = locale.getpreferredencoding()
     30
     31 -class TestColors(object):
     32      @raises(XYZValueError)
     33 -    def testForegroundColor1(self):
     34          """
     35          Raise error on wrong color
     36          """
     37
     38          colors.Foreground("AAA")
     39
     40      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     41
     42 -    def testForegroundColor2(self):
     43          """
     44          Check correct color
     45          """
     46
     47          assert colors.Foreground("BLACK")
     48          assert colors.Foreground("DARK_BLUE")
     49          assert colors.Foreground("LIGHT_RED")
     50          assert colors.Foreground("DEFAULT")
     51
     52          assert colors.Foreground("BLACK")
     53          assert colors.Foreground("BROWN")
     54          assert colors.Foreground("YELLOW")
     55          assert colors.Foreground("WHITE")
     56          assert colors.Foreground("DEFAULT")
     57
     58          assert colors.Foreground("DARK_BLUE")
     59          assert colors.Foreground("DARK_MAGENTA")
     60          assert colors.Foreground("DARK_CYAN")
     61          assert colors.Foreground("DARK_RED")
     62          assert colors.Foreground("DARK_GREEN")
     63          assert colors.Foreground("DARK_GRAY")
     64
     65          assert colors.Foreground("LIGHT_GRAY")
     66          assert colors.Foreground("LIGHT_RED")
     67          assert colors.Foreground("LIGHT_GREEN")
     68          assert colors.Foreground("LIGHT_BLUE")
     69          assert colors.Foreground("LIGHT_MAGENTA")
     70          assert colors.Foreground("LIGHT_CYAN")
     71
     72      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     73
     74      @raises(XYZValueError)
     75 -    def testBackgroundColor1(self):
     76          """
     77          Raise error on wrong color
     78          """
     79
     80          colors.Background("AAA")
     81
     82      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     83
     84 -    def testBackgroundColor2(self):
     85          """
     86          Check correct color
     87          """
     88
     89          assert colors.Background("BLACK")
     90          assert colors.Background("BROWN")
     91          assert colors.Background("DEFAULT")
     92
     93          assert colors.Background("DARK_RED")
     94          assert colors.Background("DARK_GREEN")
     95          assert colors.Background("DARK_BLUE")
     96          assert colors.Background("DARK_MAGENTA")
     97          assert colors.Background("DARK_CYAN")
     98
     99          assert colors.Background("LIGHT_GRAY")
    100
    101      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    102
    103      @raises(XYZValueError)
    104 -    def testAttributeColor1(self):
    105          """
    106          Raise error on wrong attribute
    107          """
    108
    109          colors.Attribute("AAA")
    110
    111      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    112
    113 -    def testAttributeColor2(self):
    114          """
    115          Check correct attribute
    116          """
    117
    118          assert colors.Attribute("BOLD")
    119          assert colors.Attribute("UNDERLINE")
    120          assert colors.Attribute("BLINK")
    121          assert colors.Attribute("STANDOUT")
    122
    123      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    124
    125      @raises(XYZValueError)
    126 -    def testHighForegroundColorIncorrect(self):
    127          colors.ForegroundHigh("WTF?")
    128
    129      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    130
    131      @raises(XYZValueError)
    132 -    def testHighBackgroundColorIncorrect(self):
    133          colors.ForegroundHigh("WTF?")
    134
    135      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    136
    137 -    def _testHighColorCorrect(self, cl):
    138          assert cl("#009")
    139          assert cl("#fcc")
    140          assert cl("g40")
    141          assert cl("g#cc")
    142          assert cl("h8")
    143
    144      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    145
    146 -    def testForegroundHighColorCorrect(self):
    147          self._testHighColorCorrect(colors.ForegroundHigh)
    148
    149      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    150
    151 -    def testBackgroundHighColorCorrect(self):
    152          self._testHighColorCorrect(colors.BackgroundHigh)
    153
    154  #++++++++++++++++++++++++++++++++++++++++++++++++
    155
    156 -class TestPalette(object):
    157      pass
    158