Пример #1
0
def check_time_index(input_index, expected_index=None):
    expected_index = expected_index or input_index

    n0 = get_notification('Room', 'Room0', 0, input_index[0])
    n1 = get_notification('Room', 'Room0', 1, input_index[1])
    n2 = get_notification('Room', 'Room0', 2, input_index[2])

    send_notifications([n0, n1, n2])
    time.sleep(1)

    # Query
    r = requests.get(query_1T1E1A(), params={'type': 'Room'})
    assert r.status_code == 200, r.text
    obtained = r.json()

    # Check Response
    expected = {
        'data': {
            'entityId': 'Room0',
            'attrName': 'temperature',
            'index': expected_index,
            'values': [0, 1, 2],
        }
    }
    assert_1T1E1A_response(obtained, expected)
def check_time_index(service, input_index, expected_index=None):
    expected_index = expected_index or input_index

    entity_type, entity_id = 'Room', 'Room0'
    n0 = get_notification(entity_type, entity_id, 0, input_index[0])
    n1 = get_notification(entity_type, entity_id, 1, input_index[1])
    n2 = get_notification(entity_type, entity_id, 2, input_index[2])

    send_notifications(service='', notifications=[n0, n1, n2])
    wait_for_insert([entity_type], None, 3)

    # Query
    r = requests.get(query_1T1E1A(), params={'type': 'Room'})
    assert r.status_code == 200, r.text
    obtained = r.json()

    # Check Response
    expected = {
        'entityId': 'Room0',
        'entityType': 'Room',
        'attrName': 'temperature',
        'index': expected_index,
        'values': [0, 1, 2]
    }
    assert_1T1E1A_response(obtained, expected)
    delete_entity_type('', 'Room')
def setup_entities():
    notification_data = [{'data': [e]} for e in [entity_1, entity_2]]
    for service in services:
        send_notifications(service, notification_data)
        wait_for_insert([entity_type], service, 2)

    yield {}

    for service in services:
        delete_entity_type(service, entity_type)
def insert_entities(service):
    notification_data = [{'data': mk_entities()}]
    send_notifications(service, notification_data)
    time.sleep(1)
Пример #5
0
def insert_entity(service, entity):
    notification_data = [{'data': [entity]}]
    send_notifications(service, notification_data)
    time.sleep(1)
def insert_entities(service):
    entities = mk_entities()
    notification_data = [{'data': entities}]
    send_notifications(service, notification_data)
    wait_for_insert([entity_type], service, len(entities))