Mercurial > sypikslang
comparison 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 |
comparison
equal
deleted
inserted
replaced
19:12085dfd9e69 | 20:718d1ec382f7 |
---|---|
3 from gamelib.lab import Lab | 3 from gamelib.lab import Lab |
4 from gamelib import research, products | 4 from gamelib import research, products |
5 | 5 |
6 | 6 |
7 class TestLab(TestCase): | 7 class TestLab(TestCase): |
8 def setUp(self): | 8 def test_new_lab(self): |
9 self.lab = Lab() | 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) | |
10 | 18 |
11 def test_find_new_products(self): | 19 def test_find_new_products(self): |
12 # Set up the appropriate research. | 20 lab = Lab({ |
13 if research.Tesla in self.lab.new_research: | 21 'science': { |
14 self.lab._gain_science(research.Tesla(1)) | 22 'research.Tesla': 3, |
15 self.lab._get_science(research.Tesla).points += 2 | 23 } |
16 # Check breakthrough options. | 24 }) |
17 new_products = self.lab.find_new_products(None) | 25 new_products = lab.find_new_products(None) |
18 self.assertTrue(products.TeslaTank in new_products) | 26 self.assertTrue(products.TeslaTank in new_products) |
19 self.assertTrue(products.DoomsdayVirus not in new_products) | 27 self.assertTrue(products.DoomsdayVirus not in new_products) |
20 | 28 |
21 def test_find_new_research(self): | 29 def test_find_new_research(self): |
22 # Set up the appropriate research. | 30 lab = Lab({ |
23 if research.Robotics in self.lab.new_research: | 31 'science': { |
24 self.lab._gain_science(research.Robotics(1)) | 32 'research.Robotics': 1, |
25 if research.Rocketry in self.lab.new_research: | 33 'research.Rocketry': 2, |
26 self.lab._gain_science(research.Rocketry(1)) | 34 } |
27 self.lab._get_science(research.Rocketry).points += 1 | 35 }) |
28 # Check breakthrough options. | 36 new_research = lab.find_new_research() |
29 new_research = self.lab.find_new_research() | |
30 self.assertTrue(research.Space in new_research) | 37 self.assertTrue(research.Space in new_research) |
31 self.assertTrue(research.ArtificialIntelligence not in new_research) | 38 self.assertTrue(research.ArtificialIntelligence not in new_research) |