Exemple #1
0
def test_saving_switch_saves_id():
    l = LocationAvailability(LocationName='kitchen')
    id = 'myswitch'
    l.with_switch(HardwareId=id, Color='Red', Name='Test', Style='Circle')
    lm = LocationManager()
    lm.update_input_capabilities(l)
    loc = lm.get_location('kitchen')
    assert id in loc.input_capabilities.keys()
Exemple #2
0
def test_updating_existing_switch_does_not_add_new_switch():
    l = LocationAvailability(LocationName='kitchen')
    id = 'myswitch'
    l.with_switch(HardwareId=id, Color='Red', Name='Test', Style='Circle')
    assert id in l.input_capabilities.keys() and \
        l.input_capabilities[id]['style'] == 'Circle'

    l.with_switch(HardwareId=id, Color='Red', Name='Test', Style='Square')
    assert len(l.input_capabilities.keys()) == 1 and \
        l.input_capabilities[id]['style'] == 'Square'
Exemple #3
0
def test_verify_switch_with_press_returns_true():
    rpi_mock.GPIO.setmode.return_value = None
    rpi_mock.GPIO.setup.return_value = None
    rpi_mock.GPIO.input.return_value = False
    pm = PersonManager()
    p = Person(Name='calvin')
    p.require_physical_confirmation = True
    pm.update_window_set(p)
    l = LocationAvailability(LocationName='kitchen')
    id = 12
    l.with_switch(HardwareId=id, Color='Red', Name='Test', Style='Circle')
    lm = LocationManager()
    lm.update_input_capabilities(l)
    lv = LocationVerification(LocationName='kitchen', PersonName='calvin')

    done, count, timeout = lv.verify_person_at_location()
    print done, count, timeout
    assert done and count == 1 and timeout < 3
Exemple #4
0
def test_setting_local_button_style_sets_style():
    l = LocationAvailability(LocationName='kitchen')
    id = 'myswitch'
    l.with_switch(HardwareId=id, Color='Red', Name='Test', Style='Circle')
    assert l.input_capabilities[id]['style'] == 'Circle'
Exemple #5
0
def test_setting_local_button_sets_local_button():
    l = LocationAvailability(LocationName='kitchen')
    l.with_switch(Color='Red', Name='Test', Style='Circle')
    assert len(l.input_capabilities.keys()) == 1