Skip to content
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

WSG-92 refactor logical models to use templates #24

Closed
wants to merge 3 commits into from
Closed
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,5 @@ who_ocl.py
# Output for testing files

test_output/
tests/data/l2/csv_files/
tests/data/l2/csv_files/
data/
51 changes: 1 addition & 50 deletions tests/test_logical_model_generator.py
Original file line number Diff line number Diff line change
@@ -1,50 +1 @@
import unittest
import os
import pandas as pd
import shutil
import sys
from who_l3_smart_tools.core.logical_models.logical_model_generator import (
LogicalModelAndTerminologyGenerator,
)


class TestLogicalModelAndTerminologyGenerator(unittest.TestCase):
def setUp(self):
self.input_file = os.path.join("tests", "data", "l2", "test_dd.xlsx")
self.output_dir = os.path.join("tests", "output", "fsh")

def test_generate_fsh_from_excel(self):
self.maxDiff = 50000
g = LogicalModelAndTerminologyGenerator(self.input_file, self.output_dir)

g.generate_fsh_from_excel()

output_file = os.path.join(self.output_dir, "models", "HIVARegistration.fsh")
self.assertTrue(os.path.exists(output_file))

with open(output_file, "r") as f:
fsh_artifact = f.read()

with open(
os.path.join("tests", "data", "example_fsh", "HIVARegistration.fsh"), "r"
) as f:
expected_fsh_artifact = f.read()

self.assertEqual(expected_fsh_artifact, fsh_artifact)


class TestFullLogicalModelGeneration(unittest.TestCase):
def setUp(self) -> None:
self.input_file = os.path.join("tests", "data", "l2", "test_dd.xlsx")
self.output_dir = os.path.join("tests", "output", "fsh")

def test_full_data_dictionary(self):
generator = LogicalModelAndTerminologyGenerator(
self.input_file, self.output_dir
)

generator.generate_fsh_from_excel()


if __name__ == "__main__":
unittest.main()
# TODO (Kenneth): Add tests for the logical model generator.
4 changes: 3 additions & 1 deletion who_l3_smart_tools/cli/logical_model_gen.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#! /usr/bin/env python
import argparse

from who_l3_smart_tools.core.logical_models.logical_model_generator import (
LogicalModelAndTerminologyGenerator,
)
Expand All @@ -11,7 +13,7 @@ def main():
parser.add_argument(
"-i",
"--input",
default="./l3-data/test-data.xlsx",
required=True,
help="Input Data Dictionary file location",
)
parser.add_argument(
Expand Down
Loading
Loading