Skip to content

Commit

Permalink
Update test_validate_test_data.py
Browse files Browse the repository at this point in the history
The path construction for some tests doesn't work on Windows. I modified it so it does. the "qc_json" works because the test before it caches the reference files.
  • Loading branch information
ptth222 committed Mar 1, 2024
1 parent 27ba1ad commit 1d48792
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions tests/validators/test_validate_test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import logging
import os
import unittest
import pathlib

from jsonschema import Draft4Validator
from jsonschema import RefResolver
Expand Down Expand Up @@ -304,8 +305,11 @@ class TestIsaJsonCreateTestData(unittest.TestCase):

def setUp(self):
self._reporting_level = logging.ERROR
self.v2_create_schemas_path = os.path.join(
os.path.dirname(__file__), '../..', 'isatools', 'resources', 'schemas',
# self.v2_create_schemas_path = os.path.join(
# os.path.dirname(__file__), '..', '..', 'isatools', 'resources', 'schemas',
# 'isa_model_version_2_0_schemas', 'create')
self.v2_create_schemas_path = pathlib.PurePosixPath(
pathlib.Path(__file__).parents[0], '..', '..', 'isatools', 'resources', 'schemas',
'isa_model_version_2_0_schemas', 'create')

def test_validate_testdata_sampleassayplan_json(self):
Expand All @@ -314,10 +318,13 @@ def test_validate_testdata_sampleassayplan_json(self):
with open(os.path.join(self.v2_create_schemas_path,
'sample_assay_plan_schema.json')) as fp:
sample_assay_plan_schema = json.load(fp)
resolver = RefResolver('file://{}'.format(
os.path.join(self.v2_create_schemas_path,
'sample_assay_plan_schema.json')),
sample_assay_plan_schema)
res_path = str(pathlib.PurePosixPath("file://", self.v2_create_schemas_path,
'sample_assay_plan_schema.json'))
resolver = RefResolver(res_path, sample_assay_plan_schema)
# resolver = RefResolver('file://{}'.format(
# os.path.join(self.v2_create_schemas_path,
# 'sample_assay_plan_schema.json')),
# sample_assay_plan_schema)
validator = Draft4Validator(sample_assay_plan_schema,
resolver=resolver)
validator.validate(json.load(test_case_fp))
Expand All @@ -342,10 +349,13 @@ def test_validate_testdata_treatment_sequence_json(self):
with open(os.path.join(self.v2_create_schemas_path,
'treatment_sequence_schema.json')) as fp:
treatment_sequence_schema = json.load(fp)
resolver = RefResolver('file://{}'.format(
os.path.join(self.v2_create_schemas_path,
'treatment_sequence_schema.json')),
treatment_sequence_schema)
res_path = str(pathlib.PurePosixPath("file://", self.v2_create_schemas_path,
'treatment_sequence_schema.json'))
resolver = RefResolver(res_path, treatment_sequence_schema)
# resolver = RefResolver('file://{}'.format(
# os.path.join(self.v2_create_schemas_path,
# 'treatment_sequence_schema.json')),
# treatment_sequence_schema)
validator = Draft4Validator(treatment_sequence_schema,
resolver=resolver)
validator.validate(json.load(test_case_fp))
Expand Down

0 comments on commit 1d48792

Please sign in to comment.