Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Lars Falk-Petersen committed Oct 11, 2024
1 parent 11d3b04 commit e7fa3c5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
21 changes: 11 additions & 10 deletions sedr/rodeoprofile10.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""rodeo-edr-profile requirements. See <http://rodeo-project.eu/rodeo-edr-profile>."""

import util

conformance_url = "http://rodeo-project.eu/spec/rodeo-edr-profile/1/req/core"
spec_base_url = "https://rodeo-project.eu/rodeo-edr-profile/standard/rodeo-edr-profile-DRAFT.html"
spec_base_url = (
"https://rodeo-project.eu/rodeo-edr-profile/standard/rodeo-edr-profile-DRAFT.html"
)


def requirement7_1(jsondata: str) -> tuple[bool, str]:
Expand All @@ -20,10 +20,11 @@ def requirement7_1(jsondata: str) -> tuple[bool, str]:

return True, ""


def requirement7_2(jsondata: str) -> tuple[bool, str]:
"""Check OpenAPI."""
spec_url = f"{spec_base_url}#_openapi"
openapi_type = "application/vnd.oai.openapi+json;version=" #3.0"
openapi_type = "application/vnd.oai.openapi+json;version=" # 3.0"
servicedoc_type = "text/html"

# A, B, C
Expand Down Expand Up @@ -62,20 +63,20 @@ def requirement7_4(jsondata: str) -> tuple[bool, str]:
"""Check collection title. Can only test A, B."""
spec_url = f"{spec_base_url}#_collection_title"

#B
# B
try:
if len(jsondata["title"]) > 50:
return (
False,
False,
f"Collection title should not exceed 50 chars. See <{spec_url}> for more info.",
)
except json.JSONDecodeError as err:
#A
# A
return (
False,
f"Collection must have a title. Error {err}. See <{spec_url}> and {spec_base_url}#_collection_title_2 for more info.",
)
return (
True,
"",
)
True,
"",
)
4 changes: 3 additions & 1 deletion sedr/schemat.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ def set_up_schemathesis(args):

try:
schema = set_up_schemathesis(util.args)
except requests.exceptions.ConnectionError as err:
except requests.exceptions.ConnectionError:
msg = f"Unable to connect to site <{util.args.url}>"
pytest.fail(msg)


@schema.parametrize() # parametrize => Create tests for all operations in schema
@settings(max_examples=util.args.iterations, deadline=None)
def test_openapi(case):
Expand Down Expand Up @@ -209,6 +210,7 @@ def test_edr_collections(case):
if not requirement7_4:
raise AssertionError(requirement7_4_message)


for p in schema.raw_schema["paths"].keys():
# Include position endpoint if exists (otherwise schemathesis will refuse to run)
if p.endswith("/position"):
Expand Down

0 comments on commit e7fa3c5

Please sign in to comment.