Exemplo n.º 1
0
 def test_canTurnVariablesIntoOrdinalsViaChangeFromNounToAdjective(
         self, ast):
     manager = mng_co.Domsagxo()
     manager.variables["indekso"] = 2
     manager.variables["ampoloj"] = [1, 2, 3]
     assert 2 == evaluate_and_return_state_variables(
         ast, "asignu indeksa de ampoloj al kato", manager)['kato']
Exemplo n.º 2
0
    def test_canInvokeRoutineWithoutArguments(self, ast):
        def mock_routine():
            pass

        smart_home = mng_co.Domsagxo()
        smart_home.method_dict["sxambalulu"] = mock_routine
        # should execute without exception
        evaluate_and_return_state_variables(ast, "sxambalulu", smart_home)
Exemplo n.º 3
0
 def test_routinesCanAccessAppliancesDefinedAfterThemselves(self, ast):
     initial_state = mgmt_cmp.Domsagxo()
     new_state = evaluate_and_return_state(
         ast, '''sxangxi signifas asignu kvardek al brilo de sxambalulo finu''', initial_state)
     new_state.addAppliance(
         appliance=atypes.Appliance(atypes.ApplianceTypes.LIGHT, "sxambalulo"))
     new_state.method_dict['sxangxu']()
     assert 40 == new_state.variables["sxambalulo"].properties["brilo"]
Exemplo n.º 4
0
 def test_canDefineWhileLoopThatEvaluatesFiveTimes(self, ast):
     manager = mng_co.Domsagxo()
     manager.variables["kato"] = 5
     new_state = \
         evaluate_and_return_state_variables(ast,
             "dum kato estas pli granda ol nul tiam "
             "asignu kato-1 al kato finu",
             manager)
     assert 0 == new_state["kato"]
Exemplo n.º 5
0
    def test_canInvokeRoutineWithArguments(self, ast):
        # noinspection PyUnusedLocal
        def mock_routine(arg):
            pass

        smart_home = mng_co.Domsagxo()
        smart_home.method_dict["sxambalulu"] = mock_routine
        # should execute without exception
        evaluate_and_return_state_variables(ast, "sxambalulu kvardek du",
                                            smart_home)
Exemplo n.º 6
0
 def initial_state(self):
     return mng_co.Domsagxo()
Exemplo n.º 7
0
 def smart_home(self):
     smart_home = mgmt_cmp.Domsagxo()
     light_bulb = atypes.Appliance(atypes.ApplianceTypes.LIGHT,
                                   "sxambalulo")
     smart_home.addAppliance(light_bulb)
     return smart_home
Exemplo n.º 8
0
 def smart_home(self, polling_interval):
     scheduler = mgmt_cmp.Horaro(polling_interval=polling_interval)
     return mgmt_cmp.Domsagxo(scheduler)
Exemplo n.º 9
0
 def smart_home(self):
     simulative_time = MockClock()
     scheduler = mgmt_cmp.Horaro(
         time_function=simulative_time.get_current_time,
         delay_function=simulative_time.increase_time)
     return mgmt_cmp.Domsagxo(scheduler)