def test_commonprefix_single_case(): swagger = yaml.safe_load(""" swagger: '2.0' info: version: v1.0 title: my api paths: /v1/path/path3/: {} """) result = commonprefix(swagger["paths"].keys()) assert result == "/v1/path/path3"
def test_commonprefix_2levels_common(): swagger = yaml.safe_load(""" swagger: '2.0' info: version: v1.0 title: my api paths: /v1/path/path3: {} /v1/path/path4: {} """) result = commonprefix(swagger["paths"].keys()) assert result == "/v1/path"
def test_commonprefix_empty(): result = commonprefix([]) assert result == ""