diff --git a/conftest.py b/conftest.py index a149c46..7273ccd 100644 --- a/conftest.py +++ b/conftest.py @@ -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) diff --git a/wolframalpha/test_client.py b/wolframalpha/test_client.py index bd41a83..963fe63 100644 --- a/wolframalpha/test_client.py +++ b/wolframalpha/test_client.py @@ -2,8 +2,6 @@ from __future__ import unicode_literals -import os - import six import pytest @@ -11,24 +9,6 @@ import pytest import wolframalpha -@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) - - @pytest.fixture(scope='module') def temp_result(client): return client.query('30 deg C in deg F') diff --git a/wolframalpha/test_pmxbot.py b/wolframalpha/test_pmxbot.py new file mode 100644 index 0000000..760176c --- /dev/null +++ b/wolframalpha/test_pmxbot.py @@ -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)'