|
|
|
@ -22,8 +22,11 @@ def API_key(): |
|
|
|
|
pytest.skip("Need WOLFRAMALPHA_API_KEY in environment") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_basic(API_key): |
|
|
|
|
client = wolframalpha.Client(API_key) |
|
|
|
|
@pytest.fixture |
|
|
|
|
def client(API_key): |
|
|
|
|
return wolframalpha.Client(API_key) |
|
|
|
|
|
|
|
|
|
def test_basic(client): |
|
|
|
|
res = client.query('30 deg C in deg F') |
|
|
|
|
assert len(res.pods) > 0 |
|
|
|
|
result, = res.results |
|
|
|
@ -31,6 +34,14 @@ def test_basic(API_key): |
|
|
|
|
assert result.texts == ['86 °F (degrees Fahrenheit)'] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_results_iterator(client): |
|
|
|
|
""" |
|
|
|
|
A Result.results should be an iterator. |
|
|
|
|
""" |
|
|
|
|
res = client.query('30 deg C in deg F') |
|
|
|
|
next(res.results) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_invalid_app_id(): |
|
|
|
|
client = wolframalpha.Client('abcdefg') |
|
|
|
|
with pytest.raises(Exception): |
|
|
|
|