class LampController: def __init__(self): self.lamp = Lamp() def set_on(self): # Change lamp status to ON self.lamp.set_on() def get_status(self): # Returns True if lamp is ON return self.lamp.is_on()
class LampController: def __init__(self): self.lamp = Lamp() def turn_on(self): self.lamp.turn_on() def turn_off(self): pass def is_on(self): return self.lamp.state
class LampController: def __init__(self): self.lamp = Lamp() def turn_on(self): self.lamp.set_on() def turn_off(self): self.lamp.set_off() def is_on(self): return self.lamp.get_state()
def test_set_off(self): lamp = {'ID' : 1, 'lamp' : Lamp()} self.lamps.add_lamp(lamp) self.lamps.set_off() self.assertFalse(self.lamps.is_on())
def test_remove_lamp(self): lista = [] lamp = {'ID' : 1, 'lamp' : Lamp()} self.lamps.add_lamp(lamp) self.lamps.remove_lamp(lamp) self.assertEqual(lista, self.lamps.get_list())
def create_lamp(self, id): lamp = Lamp() dic = {'ID': id, 'lamp': lamp} self.lamps.append(dic)
def __init__(self): self.lamp = Lamp()
def create_simple_lamp(self, lamp_id): self.all_lamps.append(Lamp(lamp_id), lamp_id)