Skip to content

Commit

Permalink
Add scicat backend test unit test helper.
Browse files Browse the repository at this point in the history
  • Loading branch information
YooSunYoung committed Aug 13, 2024
1 parent 4da7d7f commit da183bf
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 16 deletions.
1 change: 1 addition & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ jobs:
- run: docker-compose version
- run: docker-compose -f tests/docker-compose-file-writer.yml up -d
- run: python tests/_scicat_ingestor.py -c resources/config.sample.json --verbose
- run: pytest --backend-tests
- run: docker-compose -f tests/docker-compose-file-writer.yml down
1 change: 1 addition & 0 deletions requirements/basetest.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
# Do not make an environment from this file, use test.txt instead!

pytest
scitacean
43 changes: 42 additions & 1 deletion requirements/basetest.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,56 @@
# SHA1:0eaa389e1fdb3a1917c0f987514bd561be5718ee
# SHA1:e820b087b52d0475bec279a238bcec7a1730ea9d
#
# This file is autogenerated by pip-compile-multi
# To update, run:
#
# pip-compile-multi
#
annotated-types==0.7.0
# via pydantic
anyio==4.4.0
# via httpx
certifi==2024.7.4
# via
# httpcore
# httpx
dnspython==2.6.1
# via email-validator
email-validator==2.2.0
# via scitacean
h11==0.14.0
# via httpcore
httpcore==1.0.5
# via httpx
httpx==0.27.0
# via scitacean
idna==3.7
# via
# anyio
# email-validator
# httpx
iniconfig==2.0.0
# via pytest
packaging==24.1
# via pytest
pluggy==1.5.0
# via pytest
pydantic==2.8.2
# via scitacean
pydantic-core==2.20.1
# via pydantic
pytest==8.3.2
# via -r basetest.in
python-dateutil==2.9.0.post0
# via scitacean
scitacean==24.5.0
# via -r basetest.in
six==1.16.0
# via python-dateutil
sniffio==1.3.1
# via
# anyio
# httpx
typing-extensions==4.12.2
# via
# pydantic
# pydantic-core
2 changes: 1 addition & 1 deletion requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pyproject-api==1.7.1
# via tox
smmap==5.0.1
# via gitdb
tox==4.17.0
tox==4.17.1
# via -r ci.in
virtualenv==20.26.3
# via tox
16 changes: 8 additions & 8 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
-r mypy.txt
-r static.txt
-r test.txt
annotated-types==0.7.0
# via pydantic
build==1.2.1
# via pip-tools
click==8.1.7
Expand All @@ -20,12 +18,18 @@ click==8.1.7
# pip-tools
copier==9.3.1
# via -r dev.in
dunamai==1.21.2
dunamai==1.22.0
# via copier
funcy==2.0
# via copier
jinja2==3.1.4
# via
# copier
# jinja2-ansible-filters
jinja2-ansible-filters==1.3.2
# via copier
markupsafe==2.1.5
# via jinja2
pathspec==0.12.1
# via copier
pip-compile-multi==2.6.4
Expand All @@ -36,10 +40,6 @@ plumbum==1.8.3
# via copier
prompt-toolkit==3.0.36
# via questionary
pydantic==2.8.2
# via copier
pydantic-core==2.20.1
# via pydantic
pyproject-hooks==1.1.0
# via
# build
Expand All @@ -50,7 +50,7 @@ toposort==1.10
# via pip-compile-multi
wcwidth==0.2.13
# via prompt-toolkit
wheel==0.43.0
wheel==0.44.0
# via pip-tools

# The following packages are considered to be unsafe in a requirements file:
Expand Down
2 changes: 0 additions & 2 deletions requirements/mypy.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,3 @@ mypy==1.11.1
# via -r mypy.in
mypy-extensions==1.0.0
# via mypy
typing-extensions==4.12.2
# via mypy
4 changes: 0 additions & 4 deletions requirements/nightly.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
# pip-compile-multi
#
-r basetest.txt
certifi==2024.7.4
# via requests
charset-normalizer==3.3.2
# via requests
confluent-kafka==2.5.0
Expand All @@ -20,8 +18,6 @@ graypy==2.1.0
# via -r nightly.in
h5py==3.11.0
# via -r nightly.in
idna==3.7
# via requests
kafka-python==2.0.2
# via -r nightly.in
markdown-it-py==3.0.0
Expand Down
8 changes: 8 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import pytest
from scitacean.testing.backend import add_pytest_option as add_backend_option

pytest_plugins = ("scitacean.testing.backend.fixtures",)


def pytest_addoption(parser: pytest.Parser) -> None:
add_backend_option(parser)
40 changes: 40 additions & 0 deletions tests/test_scicat_communication.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import logging

from scicat_communication import create_scicat_dataset
from scicat_configuration import SciCatOptions
from scicat_dataset import ScicatDataset, scicat_dataset_to_dict

SAMPLE_OPTION = SciCatOptions(
host="localhost",
token="",
headers={},
timeout=1,
stream=False,
verify=False,
)


def test_create_scicat_dataset(require_scicat_backend: bool):
assert require_scicat_backend
dummy_dataset = ScicatDataset(
pid='abc',
size=0,
numberOfFiles=0,
isPublished=False,
datasetName='datasetName',
description='description',
principalInvestigator='principalInvestigator',
creationLocation="here",
scientificMetadata={},
owner="me",
ownerEmail="",
sourceFolder="",
contactEmail="",
creationTime="now",
sampleId="",
)
create_scicat_dataset(
dataset=scicat_dataset_to_dict(dummy_dataset),
config=SAMPLE_OPTION,
logger=logging.getLogger(__name__),
)

0 comments on commit da183bf

Please sign in to comment.