-
Notifications
You must be signed in to change notification settings - Fork 15
Testing the SDK Locally
The SDK unit tests use poetry. To get these unit tests running locally, follow the following steps.
Instructions differ for Windows and Unix.
- On your terminal (command line) go to the base folder for phdi - which should be phdi. (example:
C:\REPOS\phdi
- for my machine) - Create a virtual environment (named venv) at this level/folder
python -m venv .venv
- Activate your virtual environment at this same level/folder
.venv/Scripts/Activate.ps1
- Once activated your terminal command prompt will look something like this:
(.venv) PS <base folder>
ie... for my machine:(.venv) PS C:\REPOS\phdi
- On your terminal (command line) go to the base folder for phdi - which should be phdi. (example:
cd phdi
) - Create a virtual environment (named venv) at this level/folder
python -m venv .venv
- Activate your virtual environment at this same level/folder
source .venv/bin/activate
for bash/zsh. See commands for all shells here. - Once activated your terminal command prompt will look something like this:
phdi py
-
Clear your poetry cache
poetry cache clear --all .
a. Choose 'Y' to clear
-
Install all dependent packages using poetry
poetry install
-
Get to the tests folder under phdi:
cd tests
-
You can run the tests a few different ways....
a.
pytest
b.
python pytest
c.
pytest -vv
for more verbose response -
If you only want to run specific tests in a subfolder, just move to the subfolder that contains the test and run
pytest
orpytest -vv
-
Confirm that you have Docker installed by running
docker -v
in your terminal. If you do not see a response similar what is shown below, follow these instructions to install Docker. -
Download a copy of the Docker Postgres image:
docker pull postgres
-
Start up the Docker container with Postgres:
docker run --name pgsql_dev -e POSTGRES_PASSWORD=pw -p 5432:5432 postgres
a. The settings above are the same settings used in the record linkage tests and are recommended, but you can change the settings (e.g., the port
-p
) if needed. -
In a new terminal window, connect to the Postgres container you just started by running
docker exec -it pgsql_dev sh
and thenpsql -h localhost -U postgres
-
Create a database called
testdb
by runningcreate database testdb;
-
Check that the database has been created:
\l
You should now be able to run the tests in
phdi\tests\linkage\test_postgres_mpi_connector.py
locally and write additional tests to your local database.