Skip to content

Commit b2fdd33

Browse files
committed
BF: need to account for change of size due to strain added, just replaced with ANY_INT for contentSize check
Also added explicit comparison of dicts since makes it possible to catch that diff. Unfortunately pytest is not smart enough to depict diff between pydantic models
1 parent e371001 commit b2fdd33

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

dandi/tests/test_metadata.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import shutil
77
from typing import Any
88

9-
from anys import ANY_AWARE_DATETIME, AnyFullmatch, AnyIn
9+
from anys import ANY_AWARE_DATETIME, ANY_INT, AnyFullmatch, AnyIn
1010
from dandischema.consts import DANDI_SCHEMA_VERSION
1111
from dandischema.metadata import validate
1212
from dandischema.models import (
@@ -24,7 +24,7 @@
2424
SexType,
2525
Software,
2626
SpeciesType,
27-
StrainType
27+
StrainType,
2828
)
2929
from dandischema.models import Dandiset as DandisetMeta
3030
from dateutil.tz import tzutc
@@ -837,7 +837,8 @@ def test_ndtypes(ndtypes, asset_dict):
837837
def test_nwb2asset(simple2_nwb: Path) -> None:
838838
# Classes with ANY_AWARE_DATETIME fields need to be constructed with
839839
# model_construct()
840-
assert nwb2asset(simple2_nwb, digest=DUMMY_DANDI_ETAG) == BareAsset.model_construct(
840+
extracted = nwb2asset(simple2_nwb, digest=DUMMY_DANDI_ETAG)
841+
target = BareAsset.model_construct(
841842
schemaKey="Asset",
842843
schemaVersion=DANDI_SCHEMA_VERSION,
843844
keywords=["keyword1", "keyword 2"],
@@ -874,7 +875,7 @@ def test_nwb2asset(simple2_nwb: Path) -> None:
874875
],
875876
),
876877
],
877-
contentSize=ByteSize(19664),
878+
contentSize=ANY_INT,
878879
encodingFormat="application/x-nwb",
879880
digest={DigestType.dandi_etag: "dddddddddddddddddddddddddddddddd-1"},
880881
path=str(simple2_nwb),
@@ -907,6 +908,8 @@ def test_nwb2asset(simple2_nwb: Path) -> None:
907908
approach=[],
908909
relatedResource=[],
909910
)
911+
assert dict(extracted) == dict(target) # for easier comprehension of diffs
912+
assert extracted == target # for ultimate equality
910913

911914

912915
@pytest.mark.xfail(reason="https://github.com/dandi/dandi-cli/issues/1450")

0 commit comments

Comments
 (0)