示例#1
0
文件: test_value.py 项目: kervi/kervi
def test_set_value_events():
    spine = MockupSpine()
    number = NumberValue("Dynamic Number", value_id="dn", spine=spine)

    number.value = 10

    assert "valueChanged" in spine.events.keys()
    assert spine.events["valueChanged"]["args"][0]["value"] == 10
示例#2
0
文件: test_value.py 项目: kervi/kervi
def test_number_instantiation():
    spine = MockupSpine()
    number = NumberValue("Dynamic Number", value_id="dn", spine=spine)

    assert number.value_id == "dn"
    assert number.name == "Dynamic Number"
    assert number.value == 0
    assert number.is_input == True
示例#3
0
文件: test_value.py 项目: kervi/kervi
def test_set_value_events_delta():
    spine = MockupSpine()
    number = NumberValue("Dynamic Number", value_id="dn", spine=spine)
    number.delta = 10

    assert number.value == 0

    number.value = 5
    assert number.value == 0
    assert "valueChanged" not in spine.events.keys()

    spine.events = {}
    number.value = 10
    assert number.value == 10
    assert spine.events["valueChanged"]["args"][0]["value"] == 10

    spine.events = {}
    number.value = 7

    assert number.value == 10
    assert "valueChanged" not in spine.events.keys()

    spine.events = {}
    number.value = 0
    assert number.value == 0
    assert spine.events["valueChanged"]["args"][0]["value"] == 0
示例#4
0
文件: test_value.py 项目: kervi/kervi
def test_linking_in_to_out():
    spine = MockupSpine()
    number_out = NumberValue("Dynamic Number",
                             is_input=False,
                             value_id="dno",
                             spine=spine)
    number_in = NumberValue("Dynamic Number", value_id="dni", spine=spine)

    assert number_out.value == 0
    assert number_in.value == 0

    number_in.link_to(number_out)

    number_out.value = 10
    assert number_in.value == 10
示例#5
0
文件: test_value.py 项目: kervi/kervi
def test_linking_transformation():
    spine = MockupSpine()
    number_out = NumberValue("Dynamic Number",
                             is_input=False,
                             value_id="dn",
                             spine=spine)
    number_in = NumberValue("Dynamic Number", value_id="dn", spine=spine)

    assert number_out.value == 0
    assert number_in.value == 0

    number_out.link_to(number_in, lambda x: -2 * x)

    number_out.value = 10
    assert number_in.value == -20
示例#6
0
文件: gpio.py 项目: kervi/kervi
 def __init__(self, gpio_device, channel, is_input):
     NumberValue.__init__(self, str(channel), is_input=is_input)
     self._device = gpio_device
     self._channel = channel
     self.min = 0
     self.max = 100
示例#7
0
文件: test_value.py 项目: kervi/kervi
def test_number_set_value():
    spine = MockupSpine()
    number = NumberValue("Dynamic Number", value_id="dn", spine=spine)

    number.value = 10
    assert number.value == 10