Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Commit

Permalink
🎨 Test bionty in __repr__
Browse files Browse the repository at this point in the history
Signed-off-by: zethson <[email protected]>
  • Loading branch information
Zethson committed Jul 31, 2024
1 parent aef8ca4 commit 3cec9cd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.10"]
python-version: ["3.11"]
timeout-minutes: 15

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: ".github/workflows/build.yml" # See dependencies below
- name: cache pre-commit
uses: actions/cache@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ def test(session: nox.Session) -> None:
run(session, "uv pip install --system -e .[dev]")
run(
session,
"uv pip install --system lamindb@git+https://github.com/laminlabs/lamindb",
"uv pip install --system lamindb@git+https://github.com/laminlabs/lamindb[bionty]",
)
run_pytest(session, coverage=False)
18 changes: 11 additions & 7 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
import textwrap

import lamindb as ln
import pytest


@pytest.fixture(scope="module")
def setup_instance():
ln.setup.init(storage="./testdb", schema="bionty")
yield
ln.setup.delete("testdb", force=True)


def strip_ansi(text: str) -> str:
Expand All @@ -10,7 +18,7 @@ def strip_ansi(text: str) -> str:
return ansi_escape.sub("", text)


def test_registry__repr__param():
def test_registry__repr__param(setup_instance):
param = ln.Param
expected_repr = textwrap.dedent("""\
Param
Expand All @@ -31,7 +39,7 @@ def test_registry__repr__param():
assert actual_repr.strip() == expected_repr.strip()


def test_registry__repr__artifact():
def test_registry__repr__artifact(setup_instance):
artifact = ln.Artifact
expected_repr = textwrap.dedent("""\
Artifact
Expand Down Expand Up @@ -70,10 +78,6 @@ def test_registry__repr__artifact():
.environment_of: Run
.collection: Collection
.collections: Collection
""").strip()

# TODO these fields should also be tested for but they require an instance with Bionty
"""
Bionty fields
.organisms: bionty.Organism
.genes: bionty.Gene
Expand All @@ -90,7 +94,7 @@ def test_registry__repr__artifact():
.ethnicities: bionty.Ethnicity
.reference_of_source: bionty.Source
.reference_of_sources: bionty.Source
"""
""").strip()

actual_repr = strip_ansi(repr(artifact))
assert actual_repr.strip() == expected_repr.strip()

0 comments on commit 3cec9cd

Please sign in to comment.