Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
dstansby committed Nov 23, 2024
1 parent 5dc05e7 commit 9798766
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/ome_zarr_models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ class Config:
"""

validate_assignment = True
# This allows fields with aliases to be populated by either
# their alias or class attribute name
#
# We use this so we can handle (at least) the "bioformats2raw.version"
# key - attributes in Python can't contain a "."
populate_by_name = True
21 changes: 18 additions & 3 deletions tests/v04/test_bioformats2raw.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import json
from pathlib import Path

from ome_zarr_models.v04.bioformats2raw import BioFormats2Raw
Expand All @@ -13,6 +12,22 @@

def test_bioformats2raw_exmaple_json():
with open(Path(__file__).parent / "data" / "bioformats2raw_example.json") as f:
data = json.load(f)
model = BioFormats2Raw.model_validate_json(f.read())

assert BioFormats2Raw(**data["bioformats"])
assert model == BioFormats2Raw(
bioformats2raw_layout=3,
plate=Plate(
acquisitions=[
AcquisitionInPlate(
id=0, maximumfieldcount=None, name=None, description=None
)
],
columns=[ColumnInPlate(name="1")],
field_count=1,
name="Plate Name 0",
rows=[RowInPlate(name="A")],
version="0.4",
wells=[WellInPlate(path="A/1", rowIndex=0, columnIndex=0)],
),
series=None,
)

0 comments on commit 9798766

Please sign in to comment.