source: trunk/game/tests/test_crate.py @ 286

Revision 286, 1.9 KB checked in by b0rland_parpg, 10 years ago (diff)

Ticket #67: patch by b0rland

  • changed default Lockable state to unlocked
  • fixed Lockable constructor logic to correctly process locked/is_open combination
  • fixed typo in Container
  • fixed tests to accomodate the above changes
  • created tests for Openable, Lockable, Container
  • 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.containers import WoodenCrate
20
21class TestWoodenCrate(unittest.TestCase):
22    def setUp(self):
23        self.crate = WoodenCrate(ID='crate01')
24        self.crate2 = WoodenCrate(ID='crate02', locked=True)
25
26    def testCreation(self):
27        """ Test the WoodenCrate creation"""
28        self.assertEqual(self.crate.ID, 'crate01')
29        self.assertEqual(self.crate.name, 'Wooden Crate')
30        self.assertEqual(self.crate.text, 'A battered crate')
31        self.assertEqual(self.crate.gfx, 'crate')
32        self.assertEqual(self.crate.coords, (0.0, 0.0))
33        self.assertEqual(self.crate.map_id, None)
34        self.assertEqual(self.crate.blocking, True)
35        self.assertEqual(self.crate.is_open, True)
36        self.assertEqual(self.crate.locked, False)
37        self.assertEqual(self.crate.scripts, {})
38
39        self.assertEqual(self.crate2.ID, 'crate02')
40        self.assertEqual(self.crate2.locked, True)
41
42    # can't test containing functionality...there are no containable objects
43
44    def testLockable(self):
45        """ Test the WoodenCrate lockability"""
46        self.crate.lock()
47        self.assertEqual(self.crate.locked, True)
48        self.crate.unlock()
49        self.assertEqual(self.crate.locked, False)
Note: See TracBrowser for help on using the repository browser.