From 79af8876d33d7bf06912ec4faa2094cfc38b1fc0 Mon Sep 17 00:00:00 2001 From: Mark Andrew Miller Date: Mon, 6 Dec 2021 10:59:56 -0500 Subject: [PATCH 1/3] https://github.com/cancerDHC/ccdhmodel/issues/131 --- decimal_test.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 decimal_test.py diff --git a/decimal_test.py b/decimal_test.py new file mode 100644 index 0000000..8993786 --- /dev/null +++ b/decimal_test.py @@ -0,0 +1,23 @@ +import crdch_model as cm +from linkml_runtime.dumpers import yaml_dumper + + +def test_dumps_vcc(): + vcc_obs = cm.Observation(observation_type=cm.CodeableConcept(), value_codeable_concept=cm.CodeableConcept()) + vcc_dump = yaml_dumper.dumps(vcc_obs) + # print statements ignored by default in passing pytests? + # https://stackoverflow.com/questions/24617397/how-to-print-to-console-in-pytest + # try -s argument or PyCharm specific configuration? + print(vcc_dump) + assert len(vcc_dump) > 0 + + +def test_dumps_decimal(): + decimal_obs = cm.Observation(observation_type=cm.CodeableConcept(), value_decimal="1.23") + vd_dump = "" + try: + vd_dump = yaml_dumper.dumps(decimal_obs) + except Exception as e: + # PEP 8: E722 do not use bare 'except' + print(f"{e}\nCouldn't dump CRDC-H decimal value to YAML string") + assert len(vd_dump) > 0 From 9727f0643a9944dcfbb9def7152aebe0b05a6b11 Mon Sep 17 00:00:00 2001 From: Mark Andrew Miller Date: Thu, 9 Dec 2021 11:26:27 -0500 Subject: [PATCH 2/3] force PyCharm to show print results and the pointof the test is to illustrate that cm.Observation(observation_type=cm.CodeableConcept(), value_decimal=1.23) can't be serialized to YAML --- decimal_test.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/decimal_test.py b/decimal_test.py index 8993786..f4af9d2 100644 --- a/decimal_test.py +++ b/decimal_test.py @@ -3,11 +3,15 @@ def test_dumps_vcc(): - vcc_obs = cm.Observation(observation_type=cm.CodeableConcept(), value_codeable_concept=cm.CodeableConcept()) + vcc_obs = cm.Observation(observation_type=cm.CodeableConcept(), + value_codeable_concept=cm.CodeableConcept( + coding=cm.Coding(code="3.1415", system="math professor"))) vcc_dump = yaml_dumper.dumps(vcc_obs) # print statements ignored by default in passing pytests? # https://stackoverflow.com/questions/24617397/how-to-print-to-console-in-pytest - # try -s argument or PyCharm specific configuration? + # https://intellij-support.jetbrains.com/hc/en-us/community/posts/360007644040-Show-logging-output-when-using-pytest + # added `-p no:logging -s` to "Additional Arguments" in Run Configuration + # also try (global?) Run Configuration Template for pytest print(vcc_dump) assert len(vcc_dump) > 0 From 90786875191c470c38352b87bf7f5ca84779b02a Mon Sep 17 00:00:00 2001 From: Mark Andrew Miller Date: Thu, 9 Dec 2021 11:30:09 -0500 Subject: [PATCH 3/3] ignoring .DS_Store and .idea/ --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index b6e4761..db6c8d9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +.DS_Store +.idea/ + # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod]