Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .github/workflows/correction_multistream_ztf_step.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,20 @@ jobs:
with:
base-folder: "correction_multistream_ztf_step"
sources-folder: "correction_multistream_ztf_step"
correction_step_integration:
uses: ./.github/workflows/poetry-tests-template.yaml
with:
base-folder: "correction_multistream_ztf_step"
sources-folder: "correction_multistream_ztf_step"
test-folder: "tests/integration"
codecov-flags: "" # Do not upload
secrets:
GH_TOKEN: "${{ secrets.ADMIN_TOKEN }}"
build-correction-multistream-ztf-dagger:
uses: ./.github/workflows/template_build_with_dagger.yaml
with:
ref: ${{ github.ref }}
stage: staging
extra-args: correction_multistream_ztf_step --dry-run
secrets:
GH_TOKEN: ${{ secrets.ADMIN_TOKEN }}
GH_TOKEN: ${{ secrets.ADMIN_TOKEN }}
1 change: 1 addition & 0 deletions correction_multistream_ztf_step/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
correction_venv
2 changes: 1 addition & 1 deletion correction_multistream_ztf_step/core/DB/database_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from sqlalchemy import create_engine, select
from sqlalchemy.orm import sessionmaker, Session
from db_plugins.db.sql.models_new import (
from db_plugins.db.sql.models import (
Base,
Detection,
ZtfForcedPhotometry,
Expand Down
2 changes: 1 addition & 1 deletion correction_multistream_ztf_step/core/parsers/parser_sql.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from db_plugins.db.sql.models_new import (
from db_plugins.db.sql.models import (
ZtfDetection,
ZtfForcedPhotometry,
ForcedPhotometry,
Expand Down
68 changes: 68 additions & 0 deletions correction_multistream_ztf_step/tests/integration/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import os

import psycopg2
import pytest
from db_plugins.db.sql._connection import PsqlDatabase

psql_config = {
"ENGINE": "postgresql",
"HOST": "localhost",
"USER": "postgres",
"PASSWORD": "postgres",
"PORT": 5432,
"DB_NAME": "postgres",
}


@pytest.fixture(scope="session")
def docker_compose_file(pytestconfig):
return os.path.join(
str(pytestconfig.rootdir), "tests/integration", "docker-compose.yml"
)


@pytest.fixture(scope="session")
def docker_compose_command():
version = os.getenv("COMPOSE", "v2")
return "docker compose" if version == "v2" else "docker-compose"


def is_responsive_psql(host, port):
try:
conn = psycopg2.connect(
f"dbname='postgres' user='postgres' host={host} port={port} password='postgres'"
)
conn.close()
return True
except Exception as e:
print(f"Connection failed: {e}")
return False


@pytest.fixture(scope="session")
def psql_service(docker_ip, docker_services):
"""Ensure that PSQL service is up and responsive."""
# `port_for` takes a container port and returns the corresponding host port
port = docker_services.port_for("postgres", 5432)
docker_services.wait_until_responsive(
timeout=30.0,
pause=0.1,
check=lambda: is_responsive_psql(docker_ip, port),
)


@pytest.fixture(scope="session")
def psql_db(docker_ip, docker_services):
port = docker_services.port_for("postgres", 5432)
docker_services.wait_until_responsive(
timeout=30.0,
pause=0.1,
check=lambda: is_responsive_psql(docker_ip, port),
)

psql_db = PsqlDatabase(psql_config)
psql_db.create_db()

yield psql_db

psql_db.drop_db()

Large diffs are not rendered by default.

Loading