comparison tests/test_game_object.py @ 0:1fd2201f5c36

Initial commit of parpg-core.
author M. George Hansen <technopolitica@gmail.com>
date Sat, 14 May 2011 01:12:35 -0700
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:1fd2201f5c36
1 #!/usr/bin/env python
2
3 # This file is part of PARPG.
4
5 # PARPG is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9
10 # PARPG 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 General Public License for more details.
14
15 # You should have received a copy of the GNU General Public License
16 # along with PARPG. If not, see <http://www.gnu.org/licenses/>.
17
18 import unittest
19 from parpg.objects.base import GameObject
20
21 class TestGameObject(unittest.TestCase):
22 def setUp(self):
23 self.game_object=GameObject (1, {'map':'img/test.png'},
24 1, 1, None, True, 'Test object', 'Description')
25
26
27 def tearDown(self):
28 self.game_object = None
29
30 def testCoords(self):
31 """ Test GameObject coordinates manipulation"""
32
33 self.assertEqual(self.game_object.coords, (1, 1))
34 self.assertEqual(self.game_object.X, 1)
35 self.assertEqual(self.game_object.Y, 1)
36 self.game_object.coords = (2,2)
37 self.assertEqual(self.game_object.X, 2.0)
38 self.assertEqual(self.game_object.Y, 2.0)
39
40 def testTrueAttr(self):
41 """ Test GameObject trueAttr functionality"""
42
43 self.game_object.is_test=True
44 self.game_object.is_test2=False
45 self.assertEqual(self.game_object.trueAttr('test'),True)
46 self.assertEqual(self.game_object.trueAttr('test2'),False)
47 self.assertEqual(self.game_object.trueAttr('test3'),False)
48
49 def testRepr(self):
50 """ Test GameObject textual representation"""
51
52 self.assertEqual(repr(self.game_object), "<Test object:1>")
53
54
55 if __name__ == '__main__':
56 unittest.main()
57