def test_markup_no_results(sn): """Unit test for markup save including as_df.""" script = get_script("markup_no_results.sql") exported_paths_for_current_test = export_markup_combinations_from_script( script=script, run=False, run_args={}) paths_under_test_mapped_to_validation_paths = { p: get_validation_file(path1=p) for p in exported_paths_for_current_test } for ( p_under_test, p_validation, ) in paths_under_test_mapped_to_validation_paths.items(): assert contents_are_identical(path1=p_under_test, path2=p_validation)
def test_markup_scaffolding(sn, tmpdir): """Verifies calling markup.save() without a pre-existing directory.""" from pathlib import Path # given script = get_script("markup_template_anchor.sql") # when script.path = Path(tmpdir) / script.path.name markup = script.doc() markup.save() # then assert not script.path.exists() # script path is set but never written to assert Path( markup._path_md).exists() # doc paths take directory of script path assert Path(markup._path_sql).exists()
def test_markup_using_template_anchor_attributes(sn): """Unit test for markup save using an __anchor__ that is included in the `script.markdown.attributes.markers` section of ``snowmobile.toml``..""" script = get_script("markup_template_anchor.sql") exported_paths_for_current_test = export_markup_combinations_from_script( script=script, run=False, run_args={}) paths_under_test_mapped_to_validation_paths = { p: get_validation_file(path1=p) for p in exported_paths_for_current_test } for ( p_under_test, p_validation, ) in paths_under_test_mapped_to_validation_paths.items(): assert contents_are_identical(path1=p_under_test, path2=p_validation)
def _setup_for_test_tag_from_stripped_line(): """Gets test cases and generates IDs for statement tags.""" # get script with tag test cases script = get_script(script_name="no_tags.sql") # remove index from generated tag for s in script._statements_all.values(): s.incl_idx_in_desc = False # generate test cases test_cases = [(s.nm_ge, s.nm_pr) for s in script.statements.values()] # generate IDs test cases/console output # ids = [ # f"FirstLine='{s.first_line}',Name='{s.nm}'" for s in script.statements.values() # ] ids = [f"nm_ge='{t[1]}', nm_pr='{t[0]}'" for t in test_cases] return ids, test_cases
def test_markup_dunder_methods(sn): """Verifies __str__ and __repr__ do not cause errors.""" script = get_script("markup_template_anchor.sql") markup = script.doc() assert str(markup) assert repr(markup)