__test_pencils.py 1.9 KB

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