Skip to content

Commit 653d746

Browse files
author
Lucas Haupt
committed
Add docstrings to new tests.
1 parent d6bb03d commit 653d746

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

tests/test_monitor_handler.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
# helper function
1717
def reset_db(db_context: psycopg.Connection | sqlite3.Connection):
18+
"""Empty all tables inside the database to provide a clean slate for the next test."""
1819
# cleanup_cursor.execute("DROP DATABASE postgres")
1920
# cleanup_cursor.execute("CREATE DATABASE postgres")
2021
cleanup_cursor = db_context.cursor()
@@ -34,6 +35,7 @@ def reset_db(db_context: psycopg.Connection | sqlite3.Connection):
3435

3536
@pytest.fixture()
3637
def connected_PostgresDBHandler():
38+
"""Provide a DBHandler connected to a Postgres database."""
3739
os.environ["PYTEST_MONITOR_DB_NAME"] = "postgres"
3840
os.environ["PYTEST_MONITOR_DB_USER"] = "postgres"
3941
os.environ["PYTEST_MONITOR_DB_PASSWORD"] = "testing_db"
@@ -46,6 +48,7 @@ def connected_PostgresDBHandler():
4648

4749

4850
def test_sqlite_handler():
51+
"""Test for working sqlite database"""
4952
# db handler
5053
db = SqliteDBHandler(":memory:")
5154
session, metrics, exc_context = db.query(
@@ -57,6 +60,7 @@ def test_sqlite_handler():
5760

5861

5962
def test_postgres_handler(connected_PostgresDBHandler):
63+
"""Test for working postgres database"""
6064
db = connected_PostgresDBHandler
6165
tables = db.query(
6266
"SELECT tablename FROM pg_tables where schemaname='public'",

tests/test_monitor_session.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
@pytest.fixture()
99
def _setup_environment_postgres():
10+
"""Fixture to set environment variables for postgres connection."""
1011
os.environ["PYTEST_MONITOR_DB_NAME"] = "postgres"
1112
os.environ["PYTEST_MONITOR_DB_USER"] = "postgres"
1213
os.environ["PYTEST_MONITOR_DB_PASSWORD"] = "testing_db"
@@ -16,6 +17,7 @@ def _setup_environment_postgres():
1617

1718
@pytest.mark.usefixtures("_setup_environment_postgres")
1819
def test_pytestmonitorsession_close_connection():
20+
"""Test to check properly closed database connection"""
1921
session = PyTestMonitorSession(":memory:")
2022
db = session._PyTestMonitorSession__db
2123

0 commit comments

Comments
 (0)