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

Revision 276, 1.2 KB checked in by orlandov, 10 years ago (diff)

Ticket #67: Refactor unit tests into runnable shape

  • Move tests to their own top level directory
  • Fix unit test failures
  • Add base/composed classes to test suite
  • Run like "nosetests ./run_python.py" OR "./run_python.py"
  • Property svn:eol-style set to native
Line 
1#!/usr/bin/python
2
3import unittest
4from scripts.objects.containers import WoodenCrate
5
6class WoodenCrateTest(unittest.TestCase):
7    def setUp(self):
8        self.crate = WoodenCrate(ID='crate01')
9        self.crate2 = WoodenCrate(ID='crate02', locked=False)
10
11    def test_creation(self):
12        self.assertEqual(self.crate.ID, 'crate01')
13        self.assertEqual(self.crate.name, 'Wooden Crate')
14        self.assertEqual(self.crate.text, 'A battered crate')
15        self.assertEqual(self.crate.gfx, 'crate')
16        self.assertEqual(self.crate.coords, (0.0, 0.0))
17        self.assertEqual(self.crate.map_id, None)
18        self.assertEqual(self.crate.blocking, True)
19        self.assertEqual(self.crate.is_open, True)
20        self.assertEqual(self.crate.locked, True)
21        self.assertEqual(self.crate.scripts, {})
22
23        self.assertEqual(self.crate2.ID, 'crate02')
24        self.assertEqual(self.crate2.locked, False)
25
26    # can't test containing functionality...there are no containable objects
27
28    def test_lockable(self):
29        self.crate2.lock()
30        self.assertEqual(self.crate2.locked, True)
31        self.crate2.unlock()
32        self.assertEqual(self.crate2.locked, False)
Note: See TracBrowser for help on using the repository browser.