Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/test-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@ jobs:
run: |
python -m pytest tests/unit/ --cov=cdisc_rules_engine --cov-fail-under=75
python -m pytest tests/QARegressionTests/
python -m pytest -m regression tests/QARegressionTests/test_Issues
20 changes: 10 additions & 10 deletions tests/QARegressionTests/globals.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
issue_datails_sheet = "Issue Details"
dataset_details_sheet = "Dataset Details"
entity_details_sheet = "Entity Details"
rules_report_sheet = "Rules Report"
issue_sheet_coreid_column = "A"
dataset_sheet_dataset_column = "A"
rules_sheet_rule_status_column = "F"
issue_sheet_record_column = "G"
issue_sheet_variable_column = "I"
issue_sheet_values_column = "J"
issue_datails_sheet = "Issue Details"
dataset_details_sheet = "Dataset Details"
entity_details_sheet = "Entity Details"
rules_report_sheet = "Rules Report"
issue_sheet_coreid_column = "A"
dataset_sheet_dataset_column = "A"
rules_sheet_rule_status_column = "F"
issue_sheet_record_column = "F"
issue_sheet_variable_column = "H"
issue_sheet_values_column = "I"
113 changes: 56 additions & 57 deletions tests/QARegressionTests/test_Issues/test_CoreIssue1023.py
Original file line number Diff line number Diff line change
@@ -1,57 +1,56 @@
import os
import subprocess
import json

import pytest
from conftest import get_python_executable


@pytest.mark.regression
class TestCoreIssue1023:

def test_dataset_utf8(self):
"""Test that the engine correctly handles dataset files with utf8 encoding"""
command = [
f"{get_python_executable()}",
"-m",
"core",
"validate",
"-s",
"sdtmig",
"-v",
"3.4",
"-r",
"CORE-000766",
"-e",
"utf8",
"-dp",
os.path.join("tests", "resources", "CoreIssue1023", "ae_utf8.json"),
"--output-format",
"json",
]
subprocess.run(command, check=True)

files = os.listdir()
json_files = [
file
for file in files
if file.startswith("CORE-Report-") and file.endswith(".json")
]
json_report_path = sorted(json_files)[-1]
# Open the JSON report file
json_report = json.load(open(json_report_path, "r", encoding="utf8"))
assert {
"Conformance_Details",
"Dataset_Details",
"Issue_Summary",
"Issue_Details",
"Rules_Report",
}.issubset(json_report.keys())
datasets = {x["filename"] for x in json_report["Dataset_Details"]}
assert datasets == {"AE"}
assert (
json_report["Issue_Details"][0]["USUBJID"]
== f"utf8:{b'\xe1\xbc\x87'.decode('utf8')}"
)
if os.path.exists(json_report_path):
os.remove(json_report_path)
import os
import subprocess
import json

from conftest import get_python_executable


class TestCoreIssue1023:

def test_dataset_utf8(self):
"""Test that the engine correctly handles dataset files with utf8
encoding."""
command = [
f"{get_python_executable()}",
"-m",
"core",
"validate",
"-s",
"sdtmig",
"-v",
"3.4",
"-lr",
os.path.join("tests", "resources", "library_rules", "CORE-000766.json"),
"-e",
"utf8",
"-dp",
os.path.join("tests", "resources", "CoreIssue1023", "ae_utf8.json"),
"--output-format",
"json",
]
subprocess.run(command, check=True)

files = os.listdir()
json_files = [
file
for file in files
if file.startswith("CORE-Report-") and file.endswith(".json")
]
json_report_path = sorted(json_files)[-1]
# Open the JSON report file
json_report = json.load(open(json_report_path, "r", encoding="utf8"))
assert {
"Conformance_Details",
"Dataset_Details",
"Issue_Summary",
"Issue_Details",
"Rules_Report",
}.issubset(json_report.keys())
datasets = {x["filename"] for x in json_report["Dataset_Details"]}
assert datasets == {"AE"}
assert (
json_report["Issue_Details"][0]["USUBJID"]
== f"utf8:{b'\xe1\xbc\x87'.decode('utf8')}"
)
if os.path.exists(json_report_path):
os.remove(json_report_path)
78 changes: 38 additions & 40 deletions tests/QARegressionTests/test_Issues/test_CoreIssue1204.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,38 @@
import subprocess
import pytest
from conftest import get_python_executable


@pytest.mark.regression
def test_non_existing_dataset_shows_helpful_error():
"""Test that the engine displays a helpful error message if dataset files are not found"""
command = [
get_python_executable(),
"-m",
"core",
"validate",
"-s",
"sdtmig",
"-v",
"3.4",
"-dp",
"ds.json",
"-dp",
"ds2.json",
]

process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = process.communicate()

stderr_text = stderr.decode()
stdout_text = stdout.decode()

assert process.returncode == 2, "Expected non-zero exit code"
assert (
"FileNotFoundError" not in stderr_text
), "Should not show FileNotFoundError crash"
assert (
"Failed to execute script" not in stderr_text
), "Should not show script execution failure"
assert "Files ds.json, ds2.json are not found" in stderr_text, (
f"Expected helpful error message about non-existing dataset files. "
f"stderr: {stderr_text}, stdout: {stdout_text}"
)
import subprocess
from conftest import get_python_executable


def test_non_existing_dataset_shows_helpful_error():
"""Test that the engine displays a helpful error message if dataset files are not found"""
command = [
get_python_executable(),
"-m",
"core",
"validate",
"-s",
"sdtmig",
"-v",
"3.4",
"-dp",
"ds.json",
"-dp",
"ds2.json",
]

process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = process.communicate()

stderr_text = stderr.decode()
stdout_text = stdout.decode()

assert process.returncode == 2, "Expected non-zero exit code"
assert (
"FileNotFoundError" not in stderr_text
), "Should not show FileNotFoundError crash"
assert (
"Failed to execute script" not in stderr_text
), "Should not show script execution failure"
assert "Files ds.json, ds2.json are not found" in stderr_text, (
f"Expected helpful error message about non-existing dataset files. "
f"stderr: {stderr_text}, stdout: {stdout_text}"
)
Loading
Loading