chore: fixing more tests

This commit is contained in:
Adam Miller 2025-03-27 17:12:17 -07:00
parent b5ee8a9ea7
commit e7e4225bf2
6 changed files with 81 additions and 39 deletions

View file

@ -18,6 +18,7 @@ limitations under the License.
"""
import importlib.metadata
import os
import subprocess
import doublethink
@ -26,6 +27,13 @@ import pytest
import brozzler.cli
@pytest.fixture(scope="module")
def rethinker(request):
db = request.param if hasattr(request, "param") else "ignoreme"
servers = os.environ.get("BROZZLER_RETHINKDB_SERVERS", "localhost")
return doublethink.Rethinker(db=db, servers=servers.split(","))
def console_scripts():
# We do a dict comprehension here because the select filters aren't
# available until Python 3.10's importlib.
@ -67,14 +75,18 @@ def test_run_command(capsys, cmd):
[cmd, "--version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
out, err = proc.communicate()
assert err == b""
# Remove lines from syntax warning in imported library
filtered_lines = [line for line in err.decode("utf-8").splitlines() if "reppy" not in line and
"re.compile" not in line]
assert filtered_lines == []
assert out == ("brozzler %s - %s\n" % (brozzler.__version__, cmd)).encode("ascii")
def test_rethinkdb_up():
@pytest.mark.parametrize("rethinker", ["rethinkdb"], indirect=True) # build-in db
def test_rethinkdb_up(rethinker):
"""Check that rethinkdb is up and running."""
# check that rethinkdb is listening and looks sane
rr = doublethink.Rethinker(db="rethinkdb") # built-in db
rr = rethinker
tbls = rr.table_list().run()
assert len(tbls) > 10