Skip to content

Commit

Permalink
Merge branch 'master' into sqlalchemy20-support
Browse files Browse the repository at this point in the history
  • Loading branch information
matjam committed Jan 12, 2024
2 parents c96a3bb + e845749 commit 97e7cfb
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 9 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/build-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: PR Checks

on:
pull_request:
types: [opened, synchronize, reopened, edited, ready_for_review]
push:
branches: [master]

jobs:
build:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:latest
env:
POSTGRES_PASSWORD: "postgres"
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
ports:
- "5432:5432"

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
cache: "pip"

- name: Install Python Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt -e .[dev]
# temporarily don't fail on pylint failures so they can be fixed later
- name: Lint with pylint
run: pylint --disable=C0115,C0116,C0104,C0114,W0511 src tests || true

- name: Check with flake8
run: flake8

- name: Check import sorting
run: isort --check-only -p savage -p tests .

- name: Check black formatting
run: black --check --line-length=100 src tests

- name: Run all tests
run: pytest --cov=. tests
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ default: install lint tests
# ---- Install ----

venv:
# Create a local virtual environment in `venv/`
# Use Python 3.9 for local development
python -mvenv $(VENV_DIR)

install: venv
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
test_requires = ["pytest", "pytest-cov", "pytest-mock"]
dev_requires = test_requires + [
"autopep8>=1.4.4",
"black>=23",
"black>=23.12.1",
"flake8",
"ipython",
"isort>=4.3.21",
Expand Down
3 changes: 1 addition & 2 deletions src/savage/api/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,7 @@ def _get_latest_time_slice(table, session, conds, include_deleted, limit, offset


def _get_limit_and_offset(page, page_size):
"""Returns a 0-indexed offset and limit based on page and page_size for a MySQL query.
"""
"""Returns a 0-indexed offset and limit based on page and page_size for a MySQL query."""
if page < 1:
raise ValueError("page must be >= 1")
limit = page_size
Expand Down
2 changes: 1 addition & 1 deletion tests/db_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from psycopg2 import connect
from sqlalchemy.orm import sessionmaker

PG_CONFIG = dict(user="postgres", password="", host="localhost", port=5543)
PG_CONFIG = dict(user="postgres", password="postgres", host="localhost", port=5432)
CI_PG_CONFIG = dict(PG_CONFIG, port=5432)

MASTER_DATABASE = "postgres"
Expand Down
6 changes: 2 additions & 4 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,7 @@ def test_get_products_after_version(session, user_table, get_api_test_setup):


def test_fields_query(session, user_table, get_api_test_setup):
"""Test specifying fields and make sure dedup happens correctly.
"""
"""Test specifying fields and make sure dedup happens correctly."""
p1_history, p2_history, p3_history = get_api_test_setup
conds = [{"product_id": 10}]

Expand Down Expand Up @@ -329,8 +328,7 @@ def test_fields_query(session, user_table, get_api_test_setup):


def test_failure_conditions(session, user_table, get_api_test_setup):
"""Pass invalid conds arguments and ensure the query fails.
"""
"""Pass invalid conds arguments and ensure the query fails."""
conds = [{"product_id": 10, "foo": 15}]
with pytest.raises(ValueError):
get(user_table, session, t1=datetime.utcfromtimestamp(31), conds=conds)
Expand Down

0 comments on commit 97e7cfb

Please sign in to comment.