示例#1
0
    def test_quantity_type_events(self, dimension):

        unit_of_dimension = {
            'Length': 'm',
            'Temperature': '°C',
            'Pressure': 'hPa',
            'Speed': 'km/h',
            'Intensity': 'W/m²',
            'Angle': '°',
            'Dimensionless': '',
        }

        item_name = f'{dimension}_event_test'
        with OpenhabTmpItem(item_name, f'Number:{dimension}') as item, \
                EventWaiter(item_name, ValueUpdateEvent) as event_watier, \
                ItemWaiter(item) as item_waiter:

            for state in get_openhab_test_states('Number'):
                self.openhab.post_update(
                    item_name, f'{state} {unit_of_dimension[dimension]}')
                event_watier.wait_for_event(state)
                item_waiter.wait_for_state(state)

            all_events_ok = event_watier.events_ok
        return all_events_ok
示例#2
0
    def __init__(self):
        super().__init__()

        for name in ('oh_post_update', 'oh_send_command'):
            for k in get_openhab_test_types():
                if name == 'oh_send_command' and k == 'Contact':
                    continue
                self.add_test(f'{k}.{name}', self.test_func, k, name, get_openhab_test_states(k))
示例#3
0
    def __init__(self):
        super().__init__()

        self.add_test('Interface item exists', self.test_item_exists)
        self.add_test('Interface item create/remove',
                      self.test_item_create_delete)
        self.add_test('Interface group create/remove',
                      self.test_item_create_delete_group)
        self.add_test('Interface get item definition',
                      self.test_item_definition)

        # test the states
        for oh_type in get_openhab_test_types():
            self.add_test(f'post_update {oh_type}', self.test_post_update,
                          oh_type, get_openhab_test_states(oh_type))

        # test json post
        self.add_test(f'post_update (by_json)', self.test_umlaute)
        self.add_test(f'test_item_not_found', self.test_openhab_item_not_found)
        self.add_test(f'Interface Metadata', self.test_metadata)