Mercurial > sypikslang
annotate gamelib/tests/test_lab.py @ 152:5b58e2150a4f
Whoops, unused import.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Fri, 11 May 2012 20:07:44 +0200 |
parents | 372d886f9e70 |
children |
rev | line source |
---|---|
8 | 1 from unittest import TestCase |
2 | |
152 | 3 from gamelib.lab import Lab |
49 | 4 from gamelib import research, schematics |
8 | 5 |
6 | |
21 | 7 LAB_DATA = { |
8 'science': { | |
115 | 9 'research.Physics': 5, |
21 | 10 'research.Rocketry': 2, |
115 | 11 'research.Electrickery': 3, |
151
372d886f9e70
New suggest_research() method on Lab.
Jeremy Thurgood <firxen@gmail.com>
parents:
148
diff
changeset
|
12 'schematic.MachineGun': 1, |
21 | 13 }, |
14 } | |
15 | |
16 | |
8 | 17 class TestLab(TestCase): |
20 | 18 def test_new_lab(self): |
19 all_sciences = set() | |
20 for _ in range(10): | |
21 lab = Lab() | |
22 research_areas = [r for r in lab.science | |
23 if isinstance(r, research.ResearchArea)] | |
24 self.assertEqual(3, len(research_areas)) | |
25 for science in research_areas: | |
26 all_sciences.add(type(science)) | |
27 self.assertTrue(len(all_sciences) > 3) | |
14 | 28 |
49 | 29 def test_find_new_schematics(self): |
21 | 30 lab = Lab(LAB_DATA) |
49 | 31 new_schematics = lab.find_new_schematics() |
148 | 32 self.assertTrue(schematics.LightningGun in new_schematics) |
49 | 33 self.assertTrue(schematics.DoomsdayVirus not in new_schematics) |
8 | 34 |
35 def test_find_new_research(self): | |
21 | 36 lab = Lab(LAB_DATA) |
20 | 37 new_research = lab.find_new_research() |
115 | 38 self.assertTrue(research.Lasers in new_research) |
17
10d3db1f1e08
Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
14
diff
changeset
|
39 self.assertTrue(research.ArtificialIntelligence not in new_research) |
21 | 40 |
41 def test_save_data(self): | |
42 # Check that we save what we loaded. | |
43 lab = Lab(LAB_DATA) | |
44 self.assertEqual(LAB_DATA, lab.save_data()) | |
49 | 45 # Add a schematic and check that it gets saved as well. |
46 lab._gain_science(schematics.LightningGun()) | |
21 | 47 new_science = dict( |
49 | 48 LAB_DATA['science'].items() + [('schematic.LightningGun', 0)]) |
21 | 49 self.assertEqual({'science': new_science}, lab.save_data()) |
151
372d886f9e70
New suggest_research() method on Lab.
Jeremy Thurgood <firxen@gmail.com>
parents:
148
diff
changeset
|
50 |
372d886f9e70
New suggest_research() method on Lab.
Jeremy Thurgood <firxen@gmail.com>
parents:
148
diff
changeset
|
51 def test_science_graph(self): |
372d886f9e70
New suggest_research() method on Lab.
Jeremy Thurgood <firxen@gmail.com>
parents:
148
diff
changeset
|
52 lab = Lab(LAB_DATA) |
372d886f9e70
New suggest_research() method on Lab.
Jeremy Thurgood <firxen@gmail.com>
parents:
148
diff
changeset
|
53 self.assertEqual((True, [research.Electrickery, research.Physics]), |
372d886f9e70
New suggest_research() method on Lab.
Jeremy Thurgood <firxen@gmail.com>
parents:
148
diff
changeset
|
54 lab.suggest_research()) |