-
Notifications
You must be signed in to change notification settings - Fork 36
1023: Ensure UTF Support #1729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
DmitryMK
wants to merge
7
commits into
main
Choose a base branch
from
1023-Ensure-UTF-Support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
1023: Ensure UTF Support #1729
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4f90029
Adding tests to ensure different encoding support
DmitryMK 8f1caeb
Renaming to distinguish two tests
DmitryMK 6f4f9ef
Applying prettier formatting
DmitryMK 761503c
Merge branch 'main' into 1023-Ensure-UTF-Support
gerrycampion 2f7f024
json only allows utf encodings
gerrycampion 8aca95d
fixed json report encoding and moved regression test
gerrycampion 84bf98f
Merge branch 'main' into 1023-Ensure-UTF-Support
gerrycampion File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,319 @@ | ||
| { | ||
| "datasetJSONCreationDateTime": "2024-11-11T15:09:14", | ||
| "datasetJSONVersion": "1.1.0", | ||
| "fileOID": "www.cdisc.org/StudyMSGv2/1/Define-XML_2.1.0/2024-11-11/ae", | ||
| "dbLastModifiedDateTime": "2020-08-21T09:14:28", | ||
| "originator": "CDISC SDTM MSG Team", | ||
| "sourceSystem": { | ||
| "name": "SAS on X64_10PRO", | ||
| "version": "9.0401M7" | ||
| }, | ||
| "studyOID": "cdisc.com/CDISCPILOT01", | ||
| "metaDataVersionOID": "MDV.MSGv2.0.SDTMIG.3.3.SDTM.1.7", | ||
| "metaDataRef": "define.xml", | ||
| "itemGroupOID": "IG.AE", | ||
| "records": 1, | ||
| "name": "AE", | ||
| "label": "Adverse Events", | ||
| "columns": [ | ||
| { | ||
| "itemOID": "IT.AE.STUDYID", | ||
| "name": "STUDYID", | ||
| "label": "Study Identifier", | ||
| "dataType": "string", | ||
| "length": 12, | ||
| "keySequence": 1 | ||
| }, | ||
| { | ||
| "itemOID": "IT.AE.DOMAIN", | ||
| "name": "DOMAIN", | ||
| "label": "Domain Abbreviation", | ||
| "dataType": "string", | ||
| "length": 2 | ||
| }, | ||
| { | ||
| "itemOID": "IT.AE.USUBJID", | ||
| "name": "USUBJID", | ||
| "label": "Unique Subject Identifier", | ||
| "dataType": "string", | ||
| "length": 8, | ||
| "keySequence": 2 | ||
| }, | ||
| { | ||
| "itemOID": "IT.AE.AESEQ", | ||
| "name": "AESEQ", | ||
| "label": "Sequence Number", | ||
| "dataType": "integer" | ||
| }, | ||
| { | ||
| "itemOID": "IT.AE.AELNKID", | ||
| "name": "AELNKID", | ||
| "label": "Link ID", | ||
| "dataType": "string", | ||
| "length": 50, | ||
| "keySequence": 5 | ||
| }, | ||
| { | ||
| "itemOID": "IT.AE.AETERM", | ||
| "name": "AETERM", | ||
| "label": "Reported Term for the Adverse Event", | ||
| "dataType": "string", | ||
| "length": 200 | ||
| }, | ||
| { | ||
| "itemOID": "IT.AE.AELLT", | ||
| "name": "AELLT", | ||
| "label": "Lowest Level Term", | ||
| "dataType": "string", | ||
| "length": 1 | ||
| }, | ||
| { | ||
| "itemOID": "IT.AE.AELLTCD", | ||
| "name": "AELLTCD", | ||
| "label": "Lowest Level Term Code", | ||
| "dataType": "string", | ||
| "length": 1 | ||
| }, | ||
| { | ||
| "itemOID": "IT.AE.AEDECOD", | ||
| "name": "AEDECOD", | ||
| "label": "Dictionary-Derived Term", | ||
| "dataType": "string", | ||
| "length": 1, | ||
| "keySequence": 3 | ||
| }, | ||
| { | ||
| "itemOID": "IT.AE.AEPTCD", | ||
| "name": "AEPTCD", | ||
| "label": "Preferred Term Code", | ||
| "dataType": "string", | ||
| "length": 1 | ||
| }, | ||
| { | ||
| "itemOID": "IT.AE.AEHLT", | ||
| "name": "AEHLT", | ||
| "label": "High Level Term", | ||
| "dataType": "string", | ||
| "length": 1 | ||
| }, | ||
| { | ||
| "itemOID": "IT.AE.AEHLTCD", | ||
| "name": "AEHLTCD", | ||
| "label": "High Level Term Code", | ||
| "dataType": "string", | ||
| "length": 1 | ||
| }, | ||
| { | ||
| "itemOID": "IT.AE.AEHLGT", | ||
| "name": "AEHLGT", | ||
| "label": "High Level Group Term", | ||
| "dataType": "string", | ||
| "length": 1 | ||
| }, | ||
| { | ||
| "itemOID": "IT.AE.AEHLGTCD", | ||
| "name": "AEHLGTCD", | ||
| "label": "High Level Group Term Code", | ||
| "dataType": "string", | ||
| "length": 1 | ||
| }, | ||
| { | ||
| "itemOID": "IT.AE.AEBODSYS", | ||
| "name": "AEBODSYS", | ||
| "label": "Body System or Organ Class", | ||
| "dataType": "string", | ||
| "length": 1 | ||
| }, | ||
| { | ||
| "itemOID": "IT.AE.AEBDSYCD", | ||
| "name": "AEBDSYCD", | ||
| "label": "Body System or Organ Class Code", | ||
| "dataType": "string", | ||
| "length": 1 | ||
| }, | ||
| { | ||
| "itemOID": "IT.AE.AESOC", | ||
| "name": "AESOC", | ||
| "label": "Primary System Organ Class", | ||
| "dataType": "string", | ||
| "length": 1 | ||
| }, | ||
| { | ||
| "itemOID": "IT.AE.AESOCCD", | ||
| "name": "AESOCCD", | ||
| "label": "Primary System Organ Class Code", | ||
| "dataType": "string", | ||
| "length": 1 | ||
| }, | ||
| { | ||
| "itemOID": "IT.AE.AESEV", | ||
| "name": "AESEV", | ||
| "label": "Severity/Intensity", | ||
| "dataType": "string", | ||
| "length": 8 | ||
| }, | ||
| { | ||
| "itemOID": "IT.AE.AESER", | ||
| "name": "AESER", | ||
| "label": "Serious Event", | ||
| "dataType": "string", | ||
| "length": 1 | ||
| }, | ||
| { | ||
| "itemOID": "IT.AE.AEACN", | ||
| "name": "AEACN", | ||
| "label": "Action Taken with Study Treatment", | ||
| "dataType": "string", | ||
| "length": 16 | ||
| }, | ||
| { | ||
| "itemOID": "IT.AE.AEREL", | ||
| "name": "AEREL", | ||
| "label": "Causality", | ||
| "dataType": "string", | ||
| "length": 16 | ||
| }, | ||
| { | ||
| "itemOID": "IT.AE.AEOUT", | ||
| "name": "AEOUT", | ||
| "label": "Outcome of Adverse Event", | ||
| "dataType": "string", | ||
| "length": 32 | ||
| }, | ||
| { | ||
| "itemOID": "IT.AE.AESCAN", | ||
| "name": "AESCAN", | ||
| "label": "Involves Cancer", | ||
| "dataType": "string", | ||
| "length": 1 | ||
| }, | ||
| { | ||
| "itemOID": "IT.AE.AESCONG", | ||
| "name": "AESCONG", | ||
| "label": "Congenital Anomaly or Birth Defect", | ||
| "dataType": "string", | ||
| "length": 1 | ||
| }, | ||
| { | ||
| "itemOID": "IT.AE.AESDISAB", | ||
| "name": "AESDISAB", | ||
| "label": "Persist or Signif Disability/Incapacity", | ||
| "dataType": "string", | ||
| "length": 1 | ||
| }, | ||
| { | ||
| "itemOID": "IT.AE.AESDTH", | ||
| "name": "AESDTH", | ||
| "label": "Results in Death", | ||
| "dataType": "string", | ||
| "length": 1 | ||
| }, | ||
| { | ||
| "itemOID": "IT.AE.AESHOSP", | ||
| "name": "AESHOSP", | ||
| "label": "Requires or Prolongs Hospitalization", | ||
| "dataType": "string", | ||
| "length": 1 | ||
| }, | ||
| { | ||
| "itemOID": "IT.AE.AESLIFE", | ||
| "name": "AESLIFE", | ||
| "label": "Is Life Threatening", | ||
| "dataType": "string", | ||
| "length": 1 | ||
| }, | ||
| { | ||
| "itemOID": "IT.AE.AESOD", | ||
| "name": "AESOD", | ||
| "label": "Occurred with Overdose", | ||
| "dataType": "string", | ||
| "length": 1 | ||
| }, | ||
| { | ||
| "itemOID": "IT.AE.EPOCH", | ||
| "name": "EPOCH", | ||
| "label": "Epoch", | ||
| "dataType": "string", | ||
| "length": 9 | ||
| }, | ||
| { | ||
| "itemOID": "IT.AE.AESTDTC", | ||
| "name": "AESTDTC", | ||
| "label": "Start Date/Time of Adverse Event", | ||
| "dataType": "date", | ||
| "keySequence": 4 | ||
| }, | ||
| { | ||
| "itemOID": "IT.AE.AEENDTC", | ||
| "name": "AEENDTC", | ||
| "label": "End Date/Time of Adverse Event", | ||
| "dataType": "date" | ||
| }, | ||
| { | ||
| "itemOID": "IT.AE.AESTDY", | ||
| "name": "AESTDY", | ||
| "label": "Study Day of Start of Adverse Event", | ||
| "dataType": "integer" | ||
| }, | ||
| { | ||
| "itemOID": "IT.AE.AEENDY", | ||
| "name": "AEENDY", | ||
| "label": "Study Day of End of Adverse Event", | ||
| "dataType": "integer" | ||
| }, | ||
| { | ||
| "itemOID": "IT.AE.AEENRTPT", | ||
| "name": "AEENRTPT", | ||
| "label": "End Relative to Reference Time Point", | ||
| "dataType": "string", | ||
| "length": 7 | ||
| }, | ||
| { | ||
| "itemOID": "IT.AE.AEENTPT", | ||
| "name": "AEENTPT", | ||
| "label": "End Reference Time Point", | ||
| "dataType": "date" | ||
| } | ||
| ], | ||
| "rows": [ | ||
| [ | ||
| "CDISCPILOT01", | ||
| "AE", | ||
| "utf8:ἇ", | ||
| 9, | ||
| "9", | ||
| "SUDDEN DEATH", | ||
| "", | ||
| "", | ||
| "", | ||
| "", | ||
| "", | ||
| "", | ||
| "", | ||
| "", | ||
| "", | ||
| "", | ||
| "", | ||
| "", | ||
| "SEVERE", | ||
| "Y", | ||
| "DRUG WITHDRAWN", | ||
| "NOT RELATED", | ||
| "FATAL", | ||
| "N", | ||
| "N", | ||
| "N", | ||
| "Y", | ||
| "N", | ||
| "Y", | ||
| "N", | ||
| "TREATMENT", | ||
| "2013-01-14", | ||
| "2013-01-14", | ||
| 61, | ||
| 61, | ||
| "", | ||
| "" | ||
| ] | ||
| ] | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we please move this test under regression testing instead? Regression testing folder has similar tests where we run the engine using subprocess.