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
23 changes: 13 additions & 10 deletions cdisc_rules_engine/operations/parent_library_model_column_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,18 @@ def _execute_operation(self):
in accordance to "ordinal" key of library metadata.
"""
domain_to_datasets = self._get_domain_to_datasets()
rdomain_values = self.evaluation_dataset.get(
"RDOMAIN", [None] * len(self.evaluation_dataset)
)

rdomain_names_list = {}
return self.evaluation_dataset.convert_to_series(
Series(
rdomain_names_list.setdefault(
rdomain,
self._get_parent_variable_names_list(domain_to_datasets, rdomain),
)
for rdomain in self.evaluation_dataset.get(
"RDOMAIN", [None] * len(self.evaluation_dataset)
)
for rdomain in set(rdomain_values):
rdomain_names_list[rdomain] = self._get_parent_variable_names_list(
domain_to_datasets, rdomain
)

return self.evaluation_dataset.convert_to_series(
Series(rdomain_names_list[rdomain] for rdomain in rdomain_values)
)

def _get_domain_to_datasets(self):
Expand All @@ -40,7 +41,9 @@ def _get_domain_to_datasets(self):
domain_to_datasets[dataset.domain].append(dataset)
return domain_to_datasets

def _get_parent_variable_names_list(self, domain_to_datasets: dict, rdomain: str):
def _get_parent_variable_names_list(
self, domain_to_datasets: dict, rdomain: str
) -> list[str]:
parent_datasets = domain_to_datasets.get(rdomain, [])
if len(parent_datasets) < 1:
raise DomainNotFoundError(
Expand Down
56 changes: 56 additions & 0 deletions tests/QARegressionTests/test_Issues/test_CoreIssue1699.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import os
import subprocess
import unittest
import pytest
import json
from conftest import get_python_executable


@pytest.mark.regression
class TestCoreIssue1501(unittest.TestCase):
def test_raw_report(self):
# Run the command in the terminal
command = [
f"{get_python_executable()}",
"-m",
"core",
"validate",
"-s",
"sendig",
"-v",
"3-1",
"-d",
os.path.join(
"tests",
"resources",
"CoreIssue1699",
),
"-lr",
os.path.join("tests", "resources", "CoreIssue1699", "rule.yml"),
"-ps",
"1",
"-of",
"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))
assert {
"Conformance_Details",
"Dataset_Details",
"Issue_Summary",
"Issue_Details",
"Rules_Report",
}.issubset(json_report.keys())
assert json_report["Rules_Report"][0]["status"] == "SUCCESS"

if os.path.exists(json_report_path):
os.remove(json_report_path)
Loading
Loading