def test_config_parameters_flags_no() -> None: """Test providing configuration parameters using the --config CLI parameter and the special 'no_' syntax for flags""" test_path = get_test_case_path("basic") runner = CliRunner() with runner.isolated_filesystem(): result = runner.invoke(main, [test_path, "--config", "no_copy_css", "--config", "no_copy_js"]) assert_cli_runner_result(result) assert_css_and_js_not_copied(Path.cwd())
def test_config_parameters() -> None: """Test providing configuration parameters using the --config CLI parameter""" test_path = get_test_case_path("basic") runner = CliRunner() with runner.isolated_filesystem(): result = runner.invoke(main, [test_path, "--config", "copy_css=false", "--config", "copy_js=false"]) assert_cli_runner_result(result) assert_css_and_js_not_copied(Path.cwd())
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 test_config_file_parameter_json() -> None: test_path = get_test_case_path("basic") runner = CliRunner() with runner.isolated_filesystem(): config_file_name = "jsfh_config.json" with open(config_file_name, "w", encoding="utf-8") as config_file: config_file.write("""{"copy_css": false, "copy_js": false}""") result = runner.invoke(main, [test_path, "--config-file", config_file_name]) assert_cli_runner_result(result) assert_css_and_js_not_copied(Path.cwd())
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 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)