示例#1
0
def test_get_by_label(fx_test_session: session.Session):
    req_json = {}
    with open(test_data_path / "list_all_1.json") as f:
        req_json = json.loads(f.read())
    responses.add(responses.GET,
                  "https://api.lifx.com/v1/lights/label:test_label",
                  json=req_json)
    _light = selector.Selector("label:test_label",
                               fx_test_session).get_lights()[0]
    assert isinstance(_light, model.Light)
    assert _light.id == "test_id"
示例#2
0
def test_get_all__length_one(fx_test_session: session.Session):
    req_json = {}
    with open(test_data_path / "list_all_1.json") as f:
        req_json = json.loads(f.read())
    responses.add(responses.GET,
                  "https://api.lifx.com/v1/lights/all",
                  json=req_json)
    lights = selector.Selector("all", fx_test_session).get_lights()
    assert len(lights) == 1
    assert isinstance(lights[0], model.Light)
    assert lights[0].id == "test_id"
示例#3
0
def test_get_all__empty(fx_test_session: session.Session):
    responses.add(responses.GET, "https://api.lifx.com/v1/lights/all", json={})
    lights = selector.Selector("all", fx_test_session).get_lights()
    assert len(lights) == 0
示例#4
0
def fx_test_selector(fx_test_session: session.Session) -> selector.Selector:
    req_json = {}
    with open(test_data_path / "list_all_1.json") as f:
        req_json = json.loads(f.read())
    responses.add(responses.GET, "https://api.lifx.com/v1/lights/all", json={})
    return selector.Selector("all", fx_test_session)