-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/SK-1289 | Added test for store list functionality (#808)
- Loading branch information
1 parent
9e5ce66
commit 2058d71
Showing
28 changed files
with
1,131 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "PyTest All", | ||
"type": "python", | ||
"request": "launch", | ||
"module": "pytest", | ||
"justMyCode": true | ||
}, | ||
{ | ||
"args": [ | ||
"--nf", | ||
"--lf" | ||
], | ||
"name": "PyTest New and Failing", | ||
"type": "python", | ||
"request": "launch", | ||
"module": "pytest", | ||
"justMyCode": true | ||
}, | ||
] | ||
} |
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
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
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
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
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
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
Empty file.
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,20 @@ | ||
|
||
import sys | ||
import pytest | ||
|
||
from fedn.tests.stores.helpers.database_helper import mongo_connection, sql_connection, postgres_connection | ||
|
||
|
||
# These lines ensure that pytests trigger breakpoints when assertions fail during debugging | ||
def is_debugging(): | ||
return 'debugpy' in sys.modules | ||
|
||
# enable_stop_on_exceptions if the debugger is running during a test | ||
if is_debugging(): | ||
@pytest.hookimpl(tryfirst=True) | ||
def pytest_exception_interact(call): | ||
raise call.excinfo.value | ||
|
||
@pytest.hookimpl(tryfirst=True) | ||
def pytest_internalerror(excinfo): | ||
raise excinfo.value |
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,69 @@ | ||
import pytest | ||
from unittest.mock import patch | ||
|
||
from fedn.network.storage.dbconnection import DatabaseConnection | ||
from fedn.tests.stores.helpers.mongo_docker import start_mongodb_container, stop_mongodb_container | ||
from fedn.tests.stores.helpers.postgres_docker import start_postgres_container, stop_postgres_container | ||
|
||
|
||
def network_id(): | ||
return "test_network" | ||
|
||
@pytest.fixture(scope="package") | ||
def mongo_connection(): | ||
already_running, _, port = start_mongodb_container() | ||
|
||
def mongo_config(): | ||
return { | ||
"type": "MongoDB", | ||
"mongo_config": { | ||
"host": "localhost", | ||
"port": port, | ||
"username": "fedn_admin", | ||
"password": "password" | ||
} | ||
} | ||
|
||
with patch('fedn.network.storage.dbconnection.get_statestore_config', return_value=mongo_config()), \ | ||
patch('fedn.network.storage.dbconnection.get_network_config', return_value=network_id()): | ||
yield DatabaseConnection(force_create_new=True) | ||
if not already_running: | ||
stop_mongodb_container() | ||
|
||
@pytest.fixture(scope="package") | ||
def sql_connection(): | ||
def sql_config(): | ||
return { | ||
"type": "SQLite", | ||
"sqlite_config": { | ||
"dbname": ":memory:", | ||
} | ||
} | ||
|
||
with patch('fedn.network.storage.dbconnection.get_statestore_config', return_value=sql_config()), \ | ||
patch('fedn.network.storage.dbconnection.get_network_config', return_value=network_id()): | ||
return DatabaseConnection(force_create_new=True) | ||
|
||
@pytest.fixture(scope="package") | ||
def postgres_connection(): | ||
already_running, _, port = start_postgres_container() | ||
|
||
|
||
|
||
def postgres_config(): | ||
return { | ||
"type": "PostgreSQL", | ||
"postgres_config": { | ||
"username": "fedn_admin", | ||
"password": "password", | ||
"database": "fedn_db", | ||
"host": "localhost", | ||
"port": port | ||
} | ||
} | ||
|
||
with patch('fedn.network.storage.dbconnection.get_statestore_config', return_value=postgres_config()), \ | ||
patch('fedn.network.storage.dbconnection.get_network_config', return_value=network_id()): | ||
yield DatabaseConnection(force_create_new=True) | ||
if not already_running: | ||
stop_postgres_container() |
Oops, something went wrong.