parent
2c2ba47879
commit
c66dc29876
3 changed files with 40 additions and 21 deletions
@ -1,4 +1,32 @@ |
||||
import os |
||||
|
||||
import six |
||||
|
||||
import pytest |
||||
|
||||
import wolframalpha |
||||
|
||||
|
||||
if six.PY2: |
||||
collect_ignore = ['wolframalpha/pmxbot.py'] |
||||
collect_ignore = [ |
||||
'wolframalpha/pmxbot.py', |
||||
'wolframalpha/test_pmxbot.py', |
||||
] |
||||
|
||||
|
||||
@pytest.fixture(scope='session') |
||||
def API_key(): |
||||
""" |
||||
To run the tests fully, the environment must be configured |
||||
with a WOLFRAMALPHA_API_KEY environment variable. Otherwise, |
||||
skip them. |
||||
""" |
||||
try: |
||||
return os.environ['WOLFRAMALPHA_API_KEY'] |
||||
except KeyError: |
||||
pytest.skip("Need WOLFRAMALPHA_API_KEY in environment") |
||||
|
||||
|
||||
@pytest.fixture(scope='session') |
||||
def client(API_key): |
||||
return wolframalpha.Client(API_key) |
||||
|
@ -0,0 +1,11 @@ |
||||
import pmxbot |
||||
|
||||
import wolframalpha.pmxbot |
||||
|
||||
|
||||
def test_pmxbot_command(monkeypatch, API_key): |
||||
config = {'Wolfram|Alpha API key': API_key} |
||||
monkeypatch.setattr(pmxbot, 'config', config, raising=False) |
||||
query = "1kg in lbs" |
||||
res = wolframalpha.pmxbot.wa(None, None, None, None, rest=query) |
||||
assert res == '2.205 lb (pounds)' |
Loading…
Reference in new issue