def test_force(): """ lib/armedswitch.py: test force() """ s = ArmedCheckSwitch() assert s.is_switched() == False assert s.switch() == True assert s.is_armed() == False assert s.switch() == False assert s.is_switched() == True s.force(False) assert s.is_switched() == False
def test_arm(): """ armedcheckswitch.py: Test arm() """ s = ArmedCheckSwitch() assert s.is_armed() == True assert s.switch() == True assert s.is_armed() == False s.arm() assert s.is_armed() == True
def test_switch(): """ armedcheckswitch.py: Test switch() """ s = ArmedCheckSwitch(on_check=is_equal_to_one, off_check=is_equal_to_two) assert s.is_switched() == False assert s.switch(4) == False assert s.is_switched() == False assert s.switch(1) == True assert s.is_switched() == True # Should need to re-arm before switching again assert s.switch(2) == False assert s.is_switched() == True s.arm() assert s.switch(2) == True assert s.is_switched() == False