Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup unit tests using pytest #54

Merged
merged 15 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Avoid using DLite for Python 3.12
  • Loading branch information
CasperWA committed Nov 22, 2023
commit 3b5d386e833e92ed907d7e49d0c1e8746f65abf4
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ classifiers = [
"Programming Language :: Python :: 3.12",
"Natural Language :: English",
"Operating System :: OS Independent",
"Private :: Do Not Upload",
]
keywords = ["dlite", "mongodb"]
requires-python = "~=3.10"
Expand All @@ -37,7 +36,7 @@ dependencies = [

[project.optional-dependencies]
testing = [
"dlite-python >=0.4.5,<1",
"dlite-python >=0.4.5,<1; python_version < '3.12'",
"httpx >=0.25.1,<1",
"mongomock ~=4.1",
"pytest ~=7.4",
Expand Down
9 changes: 7 additions & 2 deletions tests/test_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ def test_get_entity(
client: TestClient,
) -> None:
"""Test the route to retrieve a DLite/SOFT entity."""
import sys

import yaml
from dlite import Instance
from fastapi import status

entities: list[dict[str, Any]] = yaml.safe_load(
Expand All @@ -40,7 +41,11 @@ def test_get_entity(
assert (resolved_entity := response.json()) == entity, resolved_entity

# Validate that we can instantiate an Instance from the response
Instance.from_dict(resolved_entity)
# DLite does not support Python 3.12 yet.
if sys.version_info < (3, 12):
from dlite import Instance

Instance.from_dict(resolved_entity)


def test_get_entity_not_found(client: TestClient) -> None:
Expand Down