def test_invalid_schema(): f = tempfile.mktemp(suffix='.json') with open(f, 'w') as fp: json.dump(['a'], fp) with pytest.raises(ValueError) as excinfo: oapi2pm(path=f) assert "expected dict not list" in str(excinfo)
def test_parameter_builder_build(build_params, postman_variables): mormo = oapi2pm(schema_=OpenAPISchemaV3( openapi='3', paths={build_params[1]: { build_params[0].lower(): build_params[2] }}, )) pb = ParameterBuilder(mormo, *build_params) assert pb.build() == postman_variables
def test_parameter_builder_build_exc(build_params, exc, substr_match): mormo = oapi2pm(schema_=OpenAPISchemaV3( openapi='3', paths={build_params[1]: { build_params[0].lower(): build_params[2] }}), ) with pytest.raises(exc) as excinfo: pb = ParameterBuilder(mormo, *build_params) print(pb.build()) assert substr_match in str(excinfo)
def test_test_config_to_postman_config(build_params, test_config, postman_config): mormo = oapi2pm(schema_=OpenAPISchemaV3( openapi='3', paths={build_params[1]: { build_params[0].lower(): build_params[2] }}, test_data=build_params[3], )) assert mormo.test_config_to_postman_config(test_config) == postman_config
def test_load_schema_invalid_file_type(): with pytest.raises(ValueError) as excinfo: oapi2pm(path='schema.tf') assert "Unknown file type" in str(excinfo)
def test_no_args(): with pytest.raises(ValueError) as excinfo: oapi2pm() assert "required field" in str(excinfo)