Mercurial > sypikslang
annotate gamelib/tests/test_lab.py @ 20:718d1ec382f7
Deserialise lab data.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Sun, 06 May 2012 18:12:51 +0200 |
parents | 10d3db1f1e08 |
children | bdc6bfc34ef2 |
rev | line source |
---|---|
8 | 1 from unittest import TestCase |
2 | |
3 from gamelib.lab import Lab | |
14 | 4 from gamelib import research, products |
8 | 5 |
6 | |
7 class TestLab(TestCase): | |
20 | 8 def test_new_lab(self): |
9 all_sciences = set() | |
10 for _ in range(10): | |
11 lab = Lab() | |
12 research_areas = [r for r in lab.science | |
13 if isinstance(r, research.ResearchArea)] | |
14 self.assertEqual(3, len(research_areas)) | |
15 for science in research_areas: | |
16 all_sciences.add(type(science)) | |
17 self.assertTrue(len(all_sciences) > 3) | |
14 | 18 |
8 | 19 def test_find_new_products(self): |
20 | 20 lab = Lab({ |
21 'science': { | |
22 'research.Tesla': 3, | |
23 } | |
24 }) | |
25 new_products = lab.find_new_products(None) | |
17
10d3db1f1e08
Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
14
diff
changeset
|
26 self.assertTrue(products.TeslaTank in new_products) |
14 | 27 self.assertTrue(products.DoomsdayVirus not in new_products) |
8 | 28 |
29 def test_find_new_research(self): | |
20 | 30 lab = Lab({ |
31 'science': { | |
32 'research.Robotics': 1, | |
33 'research.Rocketry': 2, | |
34 } | |
35 }) | |
36 new_research = lab.find_new_research() | |
17
10d3db1f1e08
Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
14
diff
changeset
|
37 self.assertTrue(research.Space in new_research) |
10d3db1f1e08
Set up initial research and rework breakthroughs.
Jeremy Thurgood <firxen@gmail.com>
parents:
14
diff
changeset
|
38 self.assertTrue(research.ArtificialIntelligence not in new_research) |