diff --git a/README.md b/README.md index f439dc110e2af661bfbe358d6973649a6a6e2553..a066d0c6c2a1d244659738d23107259bc5b8614f 100644 --- a/README.md +++ b/README.md @@ -27,9 +27,10 @@ and - `scripts/maint/` scripts for **maint**aining sbws and doing administrative things like regenerating the website or updating the AUTHORS file. - `scripts/tools/` misc. scripts for users of sbws. -- `tests/testnets/` scripts and code for running mini Tor networks locally and - performing integration tests with them. -- `tests/` unit tests executed with `pytest` or `tox`. + performing tests with them. +- `tests/unit/` simple little tests that don't require Tor to be running +- `tests/integration/` more complex tests and/or tests that require Tor to be running +- `tests/testnets/` scripts and code for running mini Tor networks locally ## Boring things diff --git a/tests/integration/__touch__.py b/tests/integration/__init__.py similarity index 100% rename from tests/integration/__touch__.py rename to tests/integration/__init__.py diff --git a/tests/testnets/reproducible.tar b/tests/integration/net.tar similarity index 87% rename from tests/testnets/reproducible.tar rename to tests/integration/net.tar index 4f6be8893987e836dd925e19a85e7a091fd5567b..2d8f1b9ff60fcd125589da443a8792c72625950b 100644 Binary files a/tests/testnets/reproducible.tar and b/tests/integration/net.tar differ diff --git a/tests/integration/util/__init__.py b/tests/integration/util/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/integration/test_stem.py b/tests/integration/util/test_stem.py similarity index 71% rename from tests/integration/test_stem.py rename to tests/integration/util/test_stem.py index c36879df59c80cbf81375941d78ea25c55b4a2d9..1591d2d60abe82b3de60315e9e7e8e95e7bb4b75 100644 --- a/tests/integration/test_stem.py +++ b/tests/integration/util/test_stem.py @@ -2,7 +2,7 @@ import sbws.util.stem as stem_utils from stem.descriptor.router_status_entry import RouterStatusEntryV3 -def test_foo(persistent_launch_tor): +def test_launch_and_okay(persistent_launch_tor): cont = persistent_launch_tor assert stem_utils.is_controller_okay(cont) assert stem_utils.is_bootstrapped(cont) @@ -25,3 +25,15 @@ def test_get_relay_from_nick(persistent_launch_tor): assert isinstance(relay, RouterStatusEntryV3) assert relay.fingerprint == 'AA45C13025C037F056E734169891878ED0880231' assert relay.nickname == 'auth1' + + +def test_get_relay_from_bad_nick(persistent_launch_tor): + cont = persistent_launch_tor + relay = stem_utils.fp_or_nick_to_relay(cont, 'notarelaynick') + assert relay is None + + +def test_get_relay_from_bad_fp(persistent_launch_tor): + cont = persistent_launch_tor + relay = stem_utils.fp_or_nick_to_relay(cont, 'A'*40) + assert relay is None diff --git a/tox.ini b/tox.ini index 65495b0a67a912f15e698abc2bd8e0710d71b0a5..8d0b52e6fc9e231f1d18606dcf48af9b8756cd36 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] skip_missing_interpreters = True -envlist = clean, lint, py34, py35, py36, stats, integration +envlist = clean, lint, py34, py35, py36, integration, stats [travis] python = @@ -20,19 +20,15 @@ commands= ignore_errors = True deps = .[test] whitelist_externals = - rm tar - time bash - sleep -changedir = {toxinidir}/tests/testnets + time commands = - rm -vrf reproducible - tar vxf reproducible.tar - bash ./reproducible/start.sh - time bash -c "python3 ./reproducible/wait.py ./reproducible/{auth,relay,exit}*" - coverage run --rcfile={toxinidir}/.coveragerc --source=sbws -m pytest -s {toxinidir}/tests/integration -vv - bash ./reproducible/stop.sh + tar -C {envtmpdir} -vxf {toxinidir}/tests/integration/net.tar + bash {envtmpdir}/net/start.sh + time bash -c "python3 {envtmpdir}/net/wait.py {envtmpdir}/net/{auth,relay,exit}*" + coverage run -a --rcfile={toxinidir}/.coveragerc --source=sbws -m pytest -s {toxinidir}/tests/integration -vv + bash {envtmpdir}/net/stop.sh [testenv:lint] skip_install = True @@ -56,7 +52,7 @@ install_command = pip install --process-dependency-links {opts} {packages} deps = .[test] commands = - coverage run --rcfile={toxinidir}/.coveragerc --source=sbws -m pytest -s {toxinidir}/tests/unit -vv + coverage run -a --rcfile={toxinidir}/.coveragerc --source=sbws -m pytest -s {toxinidir}/tests/unit -vv passenv = TRAVIS TRAVIS_JOB_ID