Mercurial > sypikslang
comparison gamelib/tests/test_lab.py @ 49:373c57ab4140
Product -> Schematic.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Mon, 07 May 2012 21:24:23 +0200 |
parents | efc4f90cfd63 |
children | ef63532cac13 |
comparison
equal
deleted
inserted
replaced
48:a2980cc9a060 | 49:373c57ab4140 |
---|---|
1 from unittest import TestCase | 1 from unittest import TestCase |
2 | 2 |
3 from gamelib.lab import Lab | 3 from gamelib.lab import Lab |
4 from gamelib import research, products | 4 from gamelib import research, schematics |
5 | 5 |
6 | 6 |
7 LAB_DATA = { | 7 LAB_DATA = { |
8 'science': { | 8 'science': { |
9 'research.Robotics': 1, | 9 'research.Robotics': 1, |
23 self.assertEqual(3, len(research_areas)) | 23 self.assertEqual(3, len(research_areas)) |
24 for science in research_areas: | 24 for science in research_areas: |
25 all_sciences.add(type(science)) | 25 all_sciences.add(type(science)) |
26 self.assertTrue(len(all_sciences) > 3) | 26 self.assertTrue(len(all_sciences) > 3) |
27 | 27 |
28 def test_find_new_products(self): | 28 def test_find_new_schematics(self): |
29 lab = Lab(LAB_DATA) | 29 lab = Lab(LAB_DATA) |
30 new_products = lab.find_new_products() | 30 new_schematics = lab.find_new_schematics() |
31 self.assertTrue(products.TeslaTank in new_products) | 31 self.assertTrue(schematics.TeslaTank in new_schematics) |
32 self.assertTrue(products.DoomsdayVirus not in new_products) | 32 self.assertTrue(schematics.DoomsdayVirus not in new_schematics) |
33 | 33 |
34 def test_find_new_research(self): | 34 def test_find_new_research(self): |
35 lab = Lab(LAB_DATA) | 35 lab = Lab(LAB_DATA) |
36 new_research = lab.find_new_research() | 36 new_research = lab.find_new_research() |
37 self.assertTrue(research.Space in new_research) | 37 self.assertTrue(research.Space in new_research) |
39 | 39 |
40 def test_save_data(self): | 40 def test_save_data(self): |
41 # Check that we save what we loaded. | 41 # Check that we save what we loaded. |
42 lab = Lab(LAB_DATA) | 42 lab = Lab(LAB_DATA) |
43 self.assertEqual(LAB_DATA, lab.save_data()) | 43 self.assertEqual(LAB_DATA, lab.save_data()) |
44 # Add a product and check that it gets saved as well. | 44 # Add a schematic and check that it gets saved as well. |
45 lab._gain_science(products.LightningGun()) | 45 lab._gain_science(schematics.LightningGun()) |
46 new_science = dict( | 46 new_science = dict( |
47 LAB_DATA['science'].items() + [('product.LightningGun', 0)]) | 47 LAB_DATA['science'].items() + [('schematic.LightningGun', 0)]) |
48 self.assertEqual({'science': new_science}, lab.save_data()) | 48 self.assertEqual({'science': new_science}, lab.save_data()) |