generated from worldbank/template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
50 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from space2stats import StatsTable, Settings | ||
|
||
|
||
def test_stats_table(mock_env): | ||
with StatsTable.connect() as stats_table: | ||
assert stats_table.table_name == "space2stats" | ||
assert stats_table.conn.closed == 0 | ||
stats_table.conn.execute("SELECT 1") | ||
|
||
|
||
def test_stats_table_connect(mock_env, database): | ||
with StatsTable.connect( | ||
PGHOST=database.host, | ||
PGPORT=database.port, | ||
PGDATABASE=database.dbname, | ||
PGUSER=database.user, | ||
PGPASSWORD=database.password, | ||
PGTABLENAME="XYZ", | ||
) as stats_table: | ||
assert stats_table.table_name == "XYZ" | ||
assert stats_table.conn.closed == 0 | ||
stats_table.conn.execute("SELECT 1") | ||
|
||
|
||
def test_stats_table_settings(mock_env, database): | ||
settings = Settings( | ||
PGHOST=database.host, | ||
PGPORT=database.port, | ||
PGDATABASE=database.dbname, | ||
PGUSER=database.user, | ||
PGPASSWORD=database.password, | ||
PGTABLENAME="ABC", | ||
) | ||
with StatsTable.connect(settings) as stats_table: | ||
assert stats_table.table_name == "ABC" | ||
assert stats_table.conn.closed == 0 | ||
stats_table.conn.execute("SELECT 1") |