def test_generate_from_schema_deprecation_warning( tmp_path: Path, caplog: LogCaptureFixture, minify: bool, expect_warning: bool) -> None: caplog.set_level(logging.INFO) generate_from_schema(get_test_case_path("basic"), minify=minify) _assert_deprecation_message(caplog, expect_warning)
def test_generate_from_schema_config_object(tmp_path: Path, caplog: LogCaptureFixture) -> None: config = GenerationConfiguration(minify=False, default_from_description=True, copy_css=False, copy_js=False) caplog.set_level(logging.INFO) generate_from_schema(get_test_case_path("basic"), config=config) _assert_deprecation_message(caplog, False) assert_css_and_js_not_copied(tmp_path)
def _generate_case(case_name: str, find_deprecated: bool = False, find_default: bool = False) -> BeautifulSoup: """Get the BeautifulSoup object for a test case""" return BeautifulSoup( generate_from_schema(_get_test_case(case_name), False, find_deprecated, find_default), "html.parser")
def generate_case(self, case_name: str, config: GenerationConfiguration = None) -> str: """Get the generated markdown schema string for a given schema test case""" return generate_from_schema(get_test_case_path(case_name), None, config=config)
def generate_case(case_name: str, config: GenerationConfiguration = None) -> BeautifulSoup: """Get the BeautifulSoup object for a test case""" return BeautifulSoup( generate_from_schema(get_test_case_path(case_name), None, config=config), "html.parser", )
def test_generate_from_schema_using_path(tmp_path: Path) -> None: """Test providing a schema path as a str with the file not opened""" rendered = generate_from_schema(get_test_case_path("basic")) soup = BeautifulSoup(rendered, "html.parser") assert_basic_case(soup) assert_css_and_js_not_copied(tmp_path)
def test_generate_from_schema_using_file_object(tmp_path: Path) -> None: """Test providing a schema path as an opened file object""" with open(get_test_case_path("basic")) as test_case_fp: rendered = generate_from_schema(test_case_fp) soup = BeautifulSoup(rendered, "html.parser") assert_basic_case(soup) assert_css_and_js_not_copied(tmp_path)
def _generate_case(case_name: str, find_deprecated: bool = False, find_default: bool = False, link_to_reused_ref: bool = True) -> BeautifulSoup: """Get the BeautifulSoup object for a test case""" test_contents, test_path = _get_test_case(case_name) return BeautifulSoup( generate_from_schema(test_contents, test_path, False, find_deprecated, find_default, True, link_to_reused_ref=link_to_reused_ref), "html.parser", )
def test_generate_from_schema_using_path_already_loaded( tmp_path: Path) -> None: """Test providing a schema path as a str with the file not opened but also the loaded schema in a dict. Ensure the schema is not loaded again """ test_case_path = os.path.realpath(get_test_case_path("basic")) with open(test_case_path, encoding="utf-8") as test_case_fp: loaded = {test_case_path: yaml.safe_load(test_case_fp.read())} with patch("yaml.safe_load") as patched_yaml_load: rendered = generate_from_schema(test_case_path, loaded_schemas=loaded) patched_yaml_load.assert_not_called() soup = BeautifulSoup(rendered, "html.parser") assert_basic_case(soup) assert_css_and_js_not_copied(tmp_path)
print('WARNING: ignoring file {}, $id is missing'.format( that_file)) # create the output directory if not os.path.exists(args.version): os.mkdir(args.version) # now iterate through the same files to generate the html documentation config = GenerationConfiguration(copy_css=True, copy_js=True, expand_buttons=True, collapse_long_descriptions=False) for schema_file in schema_files: html = generate_from_schema(schema_file=schema_file, loaded_schemas=schema_store, config=config) # file name with version and without .schema.json html_file = os.path.normpath('{}/{}.html'.format(args.version, schema_file)).replace( '.schema.json', '') print('Generating {}'.format(html_file)) with open(html_file, 'w') as file_descriptor: file_descriptor.write(html) # also copy the original schema file shutil.copy(schema_file, args.version) # copy css and js files to directory with all files copy_css_and_js_to_target(config=config, result_file_path=args.version) shutil.copy('schema_doc.css', args.version) shutil.copy('schema_doc.min.js', args.version)