test_pencils.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. '''
  2. Created on 12 dec. 2016
  3. @author: olinox
  4. '''
  5. import unittest
  6. from pypog import geometry, Grid, pencil
  7. class Test(unittest.TestCase):
  8. def test_base_pencil(self):
  9. for cell_shape in (geometry.HEX, geometry.SQUARE):
  10. self.assertRaises(TypeError, pencil.BasePencil, "invalid arg")
  11. grid = Grid.Grid(cell_shape, 30, 30)
  12. my_pencil = pencil.BasePencil(grid)
  13. # default origin and position
  14. self.assertEqual(my_pencil.origin, None)
  15. self.assertEqual(my_pencil.position, None)
  16. self.assertRaises(AttributeError, my_pencil.origin, (1,1))
  17. self.assertRaises(AttributeError, my_pencil.position, (1,1))
  18. # size
  19. self.assertRaises(TypeError, setattr, my_pencil, "size", "a")
  20. self.assertRaises(ValueError, setattr, my_pencil, "size", -1)
  21. self.assertEqual(my_pencil.size, 1)
  22. # selection, added, removed
  23. self.assertEqual(my_pencil.selection, [])
  24. self.assertEqual(my_pencil.added, [])
  25. self.assertEqual(my_pencil.removed, [])
  26. # pencil methods
  27. self.assertRaises(TypeError, my_pencil.start, "a")
  28. self.assertRaises(pencil.NotStartedException, my_pencil.update, 1,1)
  29. self.assertRaises(NotImplementedError, my_pencil._update)
  30. try:
  31. my_pencil.start(0,0)
  32. except NotImplementedError:
  33. pass
  34. self.assertRaises(TypeError, my_pencil.update, "a")
  35. self.assertEqual(my_pencil.origin, (0,0))
  36. def test_line_pencil(self):
  37. pass
  38. def test_free_pencil(self):
  39. pass
  40. def test_pot_pencil(self):
  41. pass
  42. def test_rect_pencil(self):
  43. pass
  44. def test_hrect_pencil(self):
  45. pass
  46. def test_boundary_pencil(self):
  47. pass
  48. if __name__ == "__main__":
  49. unittest.main()