Skip to content

Commit e3c31e5

Browse files
tomwhitejeromekelleher
authored andcommitted
Add unit test
1 parent 3b4543e commit e3c31e5

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

tests/test_vcz.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,3 +857,42 @@ def test_json_serialization(self, icf_path):
857857

858858
assert isinstance(schema2.dimensions["variants"], vcz.VcfZarrDimension)
859859
assert isinstance(schema2.dimensions["samples"], vcz.VcfZarrDimension)
860+
861+
862+
class TestDimensionSizes:
863+
data_path = "tests/data/vcf/field_type_combos.vcf.gz"
864+
865+
@pytest.fixture(scope="class")
866+
def icf(self, tmp_path_factory):
867+
out = tmp_path_factory.mktemp("data") / "example.exploded"
868+
return icf_mod.explode(out, [self.data_path])
869+
870+
@pytest.fixture(scope="class")
871+
def schema(self, icf):
872+
return icf.generate_schema()
873+
874+
@pytest.mark.parametrize(
875+
("vcf_number", "dimensions", "field"),
876+
[
877+
("A", "alt_alleles", "FORMAT/FIA"),
878+
("R", "alleles", "FORMAT/FIR"),
879+
("G", "genotypes", "FORMAT/FIG"),
880+
],
881+
)
882+
def test_max_number_exceeds_dimension_size(
883+
self, icf, schema, vcf_number, dimensions, field
884+
):
885+
vcf_field = icf.fields[field].vcf_field
886+
assert vcf_field.vcf_number == vcf_number
887+
# this should not fail
888+
vcz.ZarrArraySpec.from_field(vcf_field, schema)
889+
890+
# change max number to be bigger than that allowed by vcf number
891+
max_number = schema.dimensions[dimensions].size + 1
892+
vcf_field.summary.max_number = max_number
893+
894+
# creating an array spec should now fail
895+
with pytest.raises(
896+
ValueError, match=f"Max number of values {max_number} exceeds max"
897+
):
898+
vcz.ZarrArraySpec.from_field(vcf_field, schema)

0 commit comments

Comments
 (0)