This project makes use of pipenv to manage all the needed packages for the project as well as a virtual environment. To install pipenv, follow these steps.
After cloning the repository, under the project root execute the following command to install the needed pip packages:
pipenv install
Activate the enviromnent with:
pipenv shell
And happy coding!
In order to set up your first pydataq test, it is recommended to run two docker containers with postgres. You can easily do that as it follows:
docker pull postgres
docker run -d --name pydataq01 -v pydataq01:/var/lib/postgresql/data -e POSTGRES_PASSWORD=<your_pass> -p <a_port>:5432 postgres
docker run -d --name pydataq02 -v pydataq02:/var/lib/postgresql/data -e POSTGRES_PASSWORD=<your_pass> -p <another_port>:5432 postgres
- Use the script provided in
sample_dataset
folder to populate both databases
Now you're good to start writing tests!
In order to run these tests using the docker images just follow these instructions.
There is a docker-compose file that deploys the environment in a more automated way. It also deploys a pgAdmin service to be able to connect to the created servers. To do so:
-
Edit the file variables.{environment}.env and update the parameters accordingly. Right now, the parameters to update are:
Parameter name Description POSTGRES_PASSWORD Password used for the Postgres servers and the pgAdmin service -
From the project root, execute:
docker-compose -f environment/docker-compose.yml --env-file environment/variables.dev.env up -d
-
If everything was fine, you should be able to go to http://localhost:9999/ and the pgAdmin web interface will be accessible.
-
Login using [email protected] as user and the value you gave to POSTGRES_PASSWORD as password.
-
Once in, add the Postgres servers. You will see some sample tables created in the databases used for testing purposes.
- Create a file named ".env" in the root of your project directory
- Add the following two lines to this file:
SOURCE_CONN=postgresql://<user>:<pass>@localhost:<port>/<dbname> TARGET_CONN=postgresql://<user>:<pass>@localhost:<port>/<dbname>
- Open the file .vscode/settings.json and and this following line
"python.envFile": "${workspaceFolder}/.env"
- Run the tests using the vscode test runner
- Exporting the environment variables should do the trick
- The go to the project root directory and run "pytest"