source: trunk/game/tests/test_game_object.py @ 388

Revision 317, 1.9 KB checked in by barra_parpg, 10 years ago (diff)

Patch by sirren & mvbarracuda:

  • New player character animations
  • Changed PC object id to player for consistency reasons (agentxmlgen.py uses the folder name for the object id)
  • Renamed parpg-editor >> parpg_editor (use underscores as space characters!)
  • SVL eol-style >> native fixes
  • Property svn:eol-style set to native
Line 
1#!/usr/bin/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
18import unittest
19from scripts.objects.base import GameObject
20
21class 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
55if __name__ == '__main__':
56    unittest.main()
57
Note: See TracBrowser for help on using the repository browser.