Ejemplo n.º 1
0
def test_get(orion, clean_mongo, entity):
    r = orion.insert(entity)
    assert r.ok

    r = orion.get('entities')
    loaded_entities = json.loads(r.text)
    assert len(loaded_entities) == 1

    assert loaded_entities[0] == entity
Ejemplo n.º 2
0
def test_delete(orion, clean_mongo, entity):
    r = orion.insert(entity)
    assert r.ok

    r = orion.delete(entity['id'])
    print(r.ok)
    print(r.text)

    r = orion.get('entities')
    loaded_entities = json.loads(r.text)
    assert len(loaded_entities) == 0
Ejemplo n.º 3
0
def test_subscribe_v1(orion, clean_mongo):
    notify_url = "http://somewhere/notify"
    subscription = create_simple_subscription_v1(notify_url)
    r = orion.subscribe_v1(subscription)
    assert r.ok
    assert r.status_code == 200

    r = orion.get('subscriptions')
    assert r.ok
    assert r.status_code == 200

    subs = json.loads(r.text)
    assert len(subs) == 1
Ejemplo n.º 4
0
def test_update(orion, clean_mongo, entity):
    r = orion.insert(entity)
    assert r.ok

    v = 10 + 30 * random()
    attrs = {'temperature': {'value': v, 'type': 'Float'}}
    r = orion.update(entity['id'], attrs)
    assert r.ok

    r = orion.get('entities')
    assert r.ok

    loaded_entities = json.loads(r.text)
    loaded_v = loaded_entities[0]['temperature']['value']
    assert loaded_v == pytest.approx(v)