Skip to content

Commit

Permalink
Merge pull request #7 from consbio/test-action
Browse files Browse the repository at this point in the history
Add test action
  • Loading branch information
nikmolnar authored Oct 29, 2023
2 parents 7569b65 + 0001dfe commit ecc91c3
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 80 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Python tests

on:
push:
branches: [ main ]
pull_request:

jobs:
build:

runs-on: ubuntu-latest
env:
DATABASE_CONFIG_JSON: pg_database/tests/test_config.json
DJANGO_SETTINGS_MODULE: pg_database.tests.settings
services:
postgis:
image: postgis/postgis:15-3.3
env:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: ''
POSTGRES_HOST_AUTH_METHOD: trust
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- '5432:5432'
volumes:
- '/var/run/postgresql:/var/run/postgresql'

strategy:
matrix:
python-version: [3.9, '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v2
- name: Install System Dependencies
run: |
sudo apt-get update && sudo apt-get install -y build-essential git curl
pipx install poetry
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install Python Dependencies
run: |
poetry env use ${{ matrix.python-version }}
poetry install
- name: Set up database
run: |
psql -c 'CREATE ROLE django SUPERUSER LOGIN CREATEDB;' -U postgres
psql -c 'CREATE ROLE travis SUPERUSER LOGIN CREATEDB;' -U postgres
psql -c 'CREATE DATABASE test_pg_database;' -U postgres
psql -c 'CREATE EXTENSION postgis;' -U postgres -d test_pg_database
psql -c 'CREATE EXTENSION postgis_topology;' -U postgres -d test_pg_database
- name: Run Tests
run: |
poetry run pytest
41 changes: 0 additions & 41 deletions .travis.yml

This file was deleted.

3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# pg-database-utils

[![Build Status](https://api.travis-ci.com/consbio/pg-database-utils.png?branch=main)](https://app.travis-ci.com/github/consbio/pg-database-utils)
[![Coverage Status](https://coveralls.io/repos/github/consbio/pg-database-utils/badge.svg?branch=main)](https://coveralls.io/github/consbio/pg-database-utils?branch=main)

A suite of utilities for PostgreSQL database queries and operations built on sqlalchemy.

This library includes support for:
Expand Down
1 change: 1 addition & 0 deletions pg_database/tests/test_config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"database-name": "test_pg_database",
"database-user": "postgres",
"django-db-key": "other",
"connect-args": {"sslmode": "prefer"},
"pooling-args": {
Expand Down
6 changes: 3 additions & 3 deletions pg_database/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ def db_drop(postgres_engine):
def db_engine():
""" Create a database engine for use in implementing tests """

postgres_engine = create_engine("postgresql:///postgres", isolation_level="AUTOCOMMIT")
postgres_engine = create_engine(URL(drivername="postgresql", username="postgres"), isolation_level="AUTOCOMMIT")

db_create(postgres_engine)
engine = create_engine(URL(**DATABASE_INFO))
Expand Down Expand Up @@ -1057,7 +1057,7 @@ def test_get_engine(db_metadata):
# Test with all params provided

test_metadata = MetaData(schema.get_engine(
connect_args={"sslmode": "require"},
connect_args={"sslmode": "prefer"},
pooling_args={"pool_size": 20, "max_overflow": 0},
))
test_metadata.reflect()
Expand Down Expand Up @@ -1088,7 +1088,7 @@ def test_get_metadata(db_metadata):
# Test with all params provided

test_metadata = schema.get_metadata(
connect_args={"sslmode": "require"},
connect_args={"sslmode": "prefer"},
pooling_args={"pool_size": 20, "max_overflow": 0},
)
assert sorted(test_metadata.tables) == sorted(db_metadata.tables)
Expand Down
33 changes: 0 additions & 33 deletions tox.ini

This file was deleted.

0 comments on commit ecc91c3

Please sign in to comment.