77# from schematic import init
88from schematic .schemas .commands import schema
99from schematic .utils .google_api_utils import download_creds_file
10- from schematic . manifest . commands import manifest
10+
1111
1212@pytest .fixture
1313def runner () -> CliRunner :
@@ -16,75 +16,21 @@ def runner() -> CliRunner:
1616 return CliRunner ()
1717
1818
19- @pytest .fixture
20- def data_model_jsonld (helpers ):
21- data_model_jsonld = helpers .get_data_path ("example.model.jsonld" )
22- yield data_model_jsonld
23-
24-
2519class TestSchemaCli :
26- def test_schema_convert_cli (self , runner , helpers , data_model_jsonld ):
20+ def test_schema_convert_cli (self , runner , config_path , helpers ):
2721
2822 data_model_csv_path = helpers .get_data_path ("example.model.csv" )
2923
24+ output_path = helpers .get_data_path ("example.model.jsonld" )
25+
3026 result = runner .invoke (
31- schema , ["convert" , data_model_csv_path , "--output_jsonld" , data_model_jsonld ]
27+ schema , ["convert" , data_model_csv_path , "--output_jsonld" , output_path ]
3228 )
3329
3430 assert result .exit_code == 0
3531
3632 expected_substr = (
37- "The Data Model was created and saved to " f"'{ data_model_jsonld } ' location."
33+ "The Data Model was created and saved to " f"'{ output_path } ' location."
3834 )
3935
4036 assert expected_substr in result .output
41-
42- # get manifest by default
43- @pytest .mark .google_credentials_needed
44- def test_get_manifest_cli (self , runner , helpers , config , data_model_jsonld ):
45- output_path = helpers .get_data_path ("example.Patient.manifest.csv" )
46-
47- result = runner .invoke (
48- manifest , ["--config" , config .CONFIG_PATH , "get" , "--data_type" , "Patient" , "--jsonld" , data_model_jsonld ]
49- )
50-
51-
52- assert result .exit_code == 0
53-
54- expected_substr_one = "Find the manifest template using this CSV file path:"
55-
56- assert expected_substr_one in result .output
57- assert output_path in result .output
58-
59- # clean up
60- helpers .clean_up_file (helpers , file_name = output_path )
61-
62- # get manifest as a csv
63- # use google drive to export
64- @pytest .mark .google_credentials_needed
65- def test_get_manifest_csv (self , runner , helpers , config , data_model_jsonld ):
66- output_path = helpers .get_data_path ("test.csv" )
67-
68- result = runner .invoke (
69- manifest , ["--config" , config .CONFIG_PATH , "get" , "--data_type" , "Patient" , "--jsonld" , data_model_jsonld , "--output_csv" , output_path ]
70- )
71- assert result .exit_code == 0
72- assert output_path in result .output
73-
74- # clean up
75- helpers .clean_up_file (helpers , file_name = output_path )
76-
77- # get manifest as an excel spreadsheet
78- @pytest .mark .google_credentials_needed
79- def test_get_manifest_excel (self , runner , helpers , config , data_model_jsonld ):
80- output_path = helpers .get_data_path ("test.xlsx" )
81-
82- result = runner .invoke (
83- manifest , ["--config" , config .CONFIG_PATH , "get" , "--data_type" , "Patient" , "--jsonld" , data_model_jsonld , "--output_xlsx" , output_path ]
84- )
85-
86- assert result .exit_code == 0
87- assert output_path in result .output
88-
89- # clean up
90- helpers .clean_up_file (helpers , file_name = output_path )
0 commit comments