shep

Multi-state key stores using bit masks for python3
git clone git://git.defalsify.org/shep.git
Info | Log | Files | Refs | LICENSE

test_report.py (1438B)


      1 # standard imports
      2 import unittest
      3 
      4 # local imports
      5 from shep import State
      6 from shep.error import (
      7         StateExists,
      8         StateInvalid,
      9         )
     10 
     11 
     12 class TestStateReport(unittest.TestCase):
     13         
     14     def setUp(self):
     15         self.states = State(4)
     16         self.states.add('foo') 
     17         self.states.add('bar') 
     18         self.states.add('baz') 
     19 
     20 
     21     def test_list_pure(self):
     22         for k in ['FOO', 'BAR', 'BAZ']:
     23             getattr(self.states, k)
     24 
     25 
     26     def test_list_alias(self):
     27         self.states.alias('xyzzy', self.states.FOO | self.states.BAZ)
     28         for k in ['FOO', 'BAR', 'BAZ', 'XYZZY']:
     29             getattr(self.states, k)
     30 
     31 
     32     def test_match(self):
     33         r = self.states.match(self.states.FOO)
     34         self.assertEqual(getattr(self.states, r[0]), 1)
     35 
     36 
     37     def test_match_alias(self):
     38         self.states.alias('xyzzy', self.states.FOO | self.states.BAZ)
     39         r = self.states.match(self.states.XYZZY)
     40         for k in ['FOO', 'BAZ']:
     41             self.assertIn(k, r[1])
     42         self.assertNotIn('BAR', r[1])
     43         self.assertEqual('XYZZY', r[0])
     44 
     45 
     46     def test_match_alias_pure(self):
     47         self.states.alias('xyzzy', self.states.FOO | self.states.BAZ)
     48         r = self.states.match(self.states.XYZZY, pure=True)
     49         for k in ['FOO', 'BAZ']:
     50             self.assertIn(k, r[1])
     51         self.assertNotIn('XYZZY', r[1])
     52         self.assertIsNone(r[0])
     53 
     54 
     55 if __name__ == '__main__':
     56     unittest.main()