def setUp(self): self.clicker = ClickerState()
class TestClass(unittest.TestCase): def setUp(self): self.clicker = ClickerState() def test_initialized(self): self.assertEqual(self.clicker.get_cookies(), 0.0) assert type(self.clicker.get_cookies()) == float self.assertEqual(self.clicker.get_cps(), 1.0) assert type(self.clicker.get_cps()) == float self.assertEqual(self.clicker.get_time(), 0.0) assert type(self.clicker.get_time()) == float self.assertEqual(self.clicker.get_history(), [(0.0, None, 0.0, 0.0)]) assert type(self.clicker.get_history()) == list def test_methods(self): self.assertEqual(self.clicker.time_until(5), 5) self.assertEqual(self.clicker.time_until(1000000), 1000000.0) self.assertEqual(self.clicker.time_until(0), 0.0) assert type(self.clicker.time_until(0.0)) == float assert type(self.clicker.time_until(0)) == float self.clicker.wait(0) self.assertEqual(self.clicker.get_time(), 0.0) assert type(self.clicker.get_time()) == float self.assertEqual(self.clicker.get_cookies(), 0.0) self.clicker.wait(5) self.assertEqual(self.clicker.get_time(), 5.0) self.assertEqual(self.clicker.get_cookies(), 5.0) self.clicker.wait(1000000) self.assertEqual(self.clicker.get_time(), 1000005.0) self.assertEqual(self.clicker.get_cookies(), 1000005.0) def test_shopping(self): self.assertEqual(self.clicker.get_history(), [(0.0, None, 0.0, 0.0)]) self.clicker.buy_item('Nuf', 1000.0, 101.0) # not enough resource to purchase it, nothing happened self.assertEqual(self.clicker.get_history(), [(0.0, None, 0.0, 0.0)]) time = self.clicker.time_until(1000.0) self.clicker.wait(time) self.clicker.buy_item('Nuf', 1000.0, 101.0) self.assertEqual(self.clicker.get_history(), [(0.0, None, 0.0, 0.0), (time, 'Nuf', 1000.0, 1000.0)])