class TestViewFunctions(unittest.TestCase): def setUp(self): # Create our controller self.controller = Controller() #create our view self.view = View(self.controller.get_model()) # Create an example machine self.machine1 = Machine(1, MachineType.TREADMILL, [1, 1, 1]) def testGetMachineType(self): # Add our example machine self.controller.add_machine(self.machine1) # self.view.print_machine_type(1) self.assertEqual(self.view.get_machine_type(self.machine1.id),self.machine1.type) def testDisplayStatus(self): # Add our example machine self.controller.add_machine(self.machine1) final_string = self.view.format_line(["ID", "Machine Type"]) + \ self.view.format_line([self.machine1.id, self.machine1.get_type()]) self.assertEqual(self.view.display_status(), final_string)
def main(): """ The main loop for the test :returns: None """ # Begin our function by declaring a controller and a view controller = Controller() # Create our view # view = View(controller.get_model()) view = GTKView(controller.get_model()) welcome(controller, view) return None
def setUp(self): # Create our controller self.controller = Controller() #create our view self.view = View(self.controller.get_model()) # Create an example machine self.machine1 = Machine(1, MachineType.TREADMILL, [1, 1, 1])
class TestBasicFunctions(unittest.TestCase): def setUp(self): # Create our controller self.controller = Controller() #create our view self.view = View(self.controller.get_model()) # Create an example machine self.machine1 = Machine(1, MachineType.TREADMILL, [1, 1, 1]) def testGetMachines(self): # Test on an empty set self.assertEqual(self.controller.get_machines(), dict()) # Manually add a machine to our machine dictionary self.controller.model.machines[1] = self.machine1 self.assertEqual(self.controller.get_machines(),{1: self.machine1}) # Manually add another machine machine2 = Machine(2, MachineType.TREADMILL, [2, 2, 2]) self.controller.model.machines[2] = machine2 self.assertEqual(self.controller.get_machines(), {1: self.machine1,2: machine2}) def testAddMachine(self): # Add our example machine self.controller.add_machine(self.machine1) self.assertEqual(self.controller.get_machines()[1], self.machine1) def testAddMachine_DuplicateMachine(self): # Add our first machine self.controller.add_machine(self.machine1) # Try to add the same machine, should fail self.assertRaises(Exception, self.controller.add_machine, self.machine1) def testGetMachine(self): pass