Skip to content

Commit

Permalink
Merge branch 'fix-local-tests'
Browse files Browse the repository at this point in the history
* fix-local-tests:
  Local tests work
  Working towards fixing local tests
  • Loading branch information
davenquinn committed Sep 18, 2023
2 parents 2893e7d + b2f540d commit 204ddc6
Show file tree
Hide file tree
Showing 6 changed files with 219 additions and 90 deletions.
27 changes: 17 additions & 10 deletions _cli/sparrow_cli/commands/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,17 +239,24 @@ def run_tests_locally(basedir: Path, *pytest_args: List[str]):
test_db = environ.get("SPARROW_TESTING_DATABASE", None)
# Need to bring up database separately to ensure ports are mapped...
# NOTE: if we specify a local database we would not need to do this
if test_db is None and not container_is_running("db"):
compose("up -d db")

# Could use some fancy container magic
db_port = environ.get("SPARROW_DB_PORT", 54321)
newenv = dict(
**environ,
SPARROW_TESTING_DATABASE=test_db
or f"postgresql://postgres@localhost:{db_port}/sparrow_test"
# Reset virtualenv to allow poetry to apply the correct one.
db_port = environ.get("SPARROW_TEST_DATABASE_PORT", 54322)
postgrest_port = environ.get("SPARROW_TEST_POSTGREST_PORT", 3001)

newenv = dict(**environ)
newenv.setdefault(
"SPARROW_SECRET_KEY", "test_secret_must_be_at_least_32_characters"
)

if test_db is None:
env = dict(**newenv)
env["COMPOSE_PROFILES"] = "data-services"
compose("up -d", env=env)
newenv.setdefault(
"SPARROW_TESTING_DATABASE",
f"postgresql://postgres@localhost:{db_port}/sparrow_test",
)
newenv.setdefault("SPARROW_POSTGREST_URL", f"http://localhost:{postgrest_port}")

del newenv["VIRTUAL_ENV"]

# Get virtualenv path
Expand Down
8 changes: 4 additions & 4 deletions backend/loader/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "sparrow-loader"
version = "1.0.9"
version = "1.1.0"
description = "Utilities for loading data into Sparrow"
authors = ["Daven Quinn <dev@davenquinn.com>"]
license = "MIT"
Expand All @@ -10,13 +10,13 @@ include = ["sparrow/loader/sparrow-db-models.pickle"]

[tool.poetry.dependencies]
python = "^3.9"
marshmallow = "^3.11.1"
marshmallow-sqlalchemy = "^0.24.2"
marshmallow = "^3.20.1"
marshmallow-sqlalchemy = "^0.29.0"
marshmallow-jsonschema = "^0.13.0"
GeoAlchemy2 = "^0.9.4"
SQLAlchemy = "^1.4.41"
"macrostrat.database" = "^2.0.1"
stringcase = "^1.2.0"
marshmallow-jsonschema = "^0.10.0"
shapely = "^1"
typer = "^0.6.1"
rich = "^12.6.0"
Expand Down
Loading

0 comments on commit 204ddc6

Please sign in to comment.