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

Revision 324, 1.5 KB checked in by orlandov, 10 years ago (diff)

Ticket #93: Patch by or1andov. Use the name attribute for on mouse over text. fixes[s:trac, t:93]

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.actors import NonPlayerCharacter
20
21class MockLayer(object):
22    """Mock Layer Object"""
23    def getId(self):
24        return 1
25
26class TestNonPlayerCharacter(unittest.TestCase):
27    def setUp(self):
28        self.npc=NonPlayerCharacter(1, MockLayer(), 'Ronnie Dobbs')
29   
30    def tearDown(self):
31        self.npc = None
32
33    def testTrueAttr(self):
34        """Test NPC trueAttr functionality"""
35        self.assertEqual(self.npc.trueAttr('living'), True)
36        self.assertEqual(self.npc.trueAttr('charstats'), True)
37
38    def testRepr(self):
39        """Test NPC textual representation"""
40        self.assertEqual(repr(self.npc), "<Ronnie Dobbs:1>")
41
42    def testName(self):
43        """Test NPC name"""
44        self.assertEqual(self.npc.name, "Ronnie Dobbs")
45
46if __name__ == '__main__':
47    unittest.main()
48
Note: See TracBrowser for help on using the repository browser.