Exemplo n.º 1
0
def test_wait_until_ready(monkeypatch):
    """
    Test that wait_until_ready polls until query_is_ready returns True
    """
    reply_mock = Mock(
        json=Mock(
            return_value={
                "status": "executing",
                "progress": {"eligible": 0, "queued": 0, "running": 0},
            }
        )
    )
    ready_mock = Mock(side_effect=[(False, reply_mock,), (True, reply_mock),])
    monkeypatch.setattr("flowclient.client.query_is_ready", ready_mock)
    connection_mock = Mock()
    connection_mock.post_json.return_value = Mock(
        status_code=202, headers={"Location": "DUMMY_LOCATION/DUMMY_ID"}
    )
    query = APIQuery(
        connection=connection_mock, parameters={"query_kind": "dummy_query"}
    )
    query.run()
    query.wait_until_ready()

    assert 2 == ready_mock.call_count
Exemplo n.º 2
0
def test_wait_until_ready_raises():
    """
    Test that 'wait_until_ready' raises an error if the query has not been set running.
    """
    query = APIQuery(connection=Mock(), parameters={"query_kind": "dummy_query"})
    with pytest.raises(FileNotFoundError):
        query.wait_until_ready()