From 1d48792ec40b0b2859925fc6b8e85827d59a93c5 Mon Sep 17 00:00:00 2001
From: Travis Thompson <ptth222@uky.edu>
Date: Fri, 1 Mar 2024 01:23:47 -0500
Subject: [PATCH] Update test_validate_test_data.py

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.
---
 tests/validators/test_validate_test_data.py | 30 ++++++++++++++-------
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/tests/validators/test_validate_test_data.py b/tests/validators/test_validate_test_data.py
index 33fb9840..83524130 100644
--- a/tests/validators/test_validate_test_data.py
+++ b/tests/validators/test_validate_test_data.py
@@ -2,6 +2,7 @@
 import logging
 import os
 import unittest
+import pathlib
 
 from jsonschema import Draft4Validator
 from jsonschema import RefResolver
@@ -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):
@@ -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))
@@ -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))