Skip to content

Commit

Permalink
🎨 Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Zethson committed Feb 26, 2025
1 parent fa6112e commit 7075467
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 21 deletions.
5 changes: 0 additions & 5 deletions docs/changelog.md

This file was deleted.

27 changes: 17 additions & 10 deletions docs/quickstart.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,47 +11,54 @@
{
"cell_type": "code",
"execution_count": null,
"id": "a51faaf3-ee27-43c6-b48d-13be1adb5c46",
"id": "07aac587",
"metadata": {},
"outputs": [],
"source": [
"from tmp_testing_demo import ExampleClass, example_function"
"!lamin init --storage run-tests --modules bionty"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "fa758625-efb0-4047-9a03-aa534bf6f78e",
"id": "18aa30d9",
"metadata": {},
"outputs": [],
"source": [
"example_function(\"A\")"
"import lamindb as ln\n",
"import pandas as pd\n",
"import numpy as np\n",
"\n",
"ln.track()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ad22eec0-8f75-4e0b-a132-8a43ccb09b37",
"id": "01a61e9b",
"metadata": {},
"outputs": [],
"source": [
"ex = ExampleClass(1)"
"df = pd.DataFrame({\"a\": np.arange(0, 10)})\n",
"\n",
"af = ln.Artifact.from_df(df, description=\"test\").save()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8bf01623-742e-425a-973d-132fc61c3d9c",
"id": "728ac9b5",
"metadata": {},
"outputs": [],
"source": [
"assert ex.bar() == \"hello\""
"!rm -r run-tests\n",
"!lamin delete --force run-tests"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "lamindb",
"language": "python",
"name": "python3"
},
Expand All @@ -65,7 +72,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.12"
"version": "3.12.8"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ authors = [{name = "Lamin Labs", email = "[email protected]"}]
readme = "README.md"
dynamic = ["version", "description"]
dependencies = [
"lamindb",
"lamindb[bionty]",
]

[project.urls]
Expand Down
9 changes: 9 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import lamindb_setup as ln_setup
import pytest


@pytest.fixture(scope="session")
def setup_instance():
ln_setup.init(storage="./testdb", modules="bionty")
yield
ln_setup.delete("testdb", force=True)
18 changes: 13 additions & 5 deletions tests/test_base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
from tmp_testing_demo import ExampleClass, example_function
import numpy as np
import pandas as pd


def test_dummy():
assert example_function("A") == "a"
ex = ExampleClass(1)
assert ex.bar() == "hello"
def test_that_uses_instance(setup_instance):
import lamindb as ln

df = pd.DataFrame({"a": np.arange(0, 10)})

af = ln.Artifact.from_df(df, description="test").save()

# clean up artifacts and stuff that might have side effects
# generally, be careful with concurrency and try not to write
# tests that depend on others
af.delete()
Empty file.
Empty file removed tmp_testing_demo/models.py
Empty file.

0 comments on commit 7075467

Please sign in to comment.