Skip to content

Commit

Permalink
Update some files from main
Browse files Browse the repository at this point in the history
  • Loading branch information
ways committed Oct 11, 2024
1 parent bcccc8a commit 435c81a
Show file tree
Hide file tree
Showing 6 changed files with 370 additions and 625 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ venv
logs
.tox
old
.mypy_cache
.pytest_cache
.*_cache
898 changes: 281 additions & 617 deletions LICENSE

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
setuptools # prospector requirement
tox
black
prospector
bandit
pymarkdownlnt
mypy
types-requests
ruff
2 changes: 1 addition & 1 deletion sedr/edreq11.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def requirementA11_1(jsondata: str) -> tuple[bool, str]:
return True, url
return (
False,
f"OpenAPI version {util.args.openapi_version if util.args else "unknown"} and version in conformance {url} doesn't match. See <{spec_url}> for more info.",
f"OpenAPI version <{util.args.openapi_version if util.args else "unknown"}> and version in conformance <{url}> doesn't match. See <{spec_url}> for more info.",
)

return (
Expand Down
82 changes: 82 additions & 0 deletions sedr/rodeoprofile10.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
"""rodeo-edr-profile requirements. See <http://rodeo-project.eu/rodeo-edr-profile>."""

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"
)


def requirement7_1(jsondata: str) -> tuple[bool, str]:
"""Check if the conformance page contains the required EDR classes.
jsondata should be the "conformsTo"-part of the conformance page.
"""
spec_url = f"{spec_base_url}#_requirements_class_core"
if conformance_url not in jsondata:
return (
False,
f"Conformance page /conformance does not contain the profile class {conformance_url}. See <{spec_url}> for more info.",
)

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"
servicedoc_type = "text/html"

# A, B, C
for link in jsondata["links"]:
if link["rel"] == "service-desc":
if openapi_type not in link["type"]:
return (
False,
f"OpenAPI link service-desc should identify the content as openAPI and include version. Example <application/vnd.oai.openapi+json;version=3.0>. Found: <{link['type']}> See <{spec_url}> and <{spec_base_url}#_openapi_2> for more info.",
)
break
else:
return (
False,
f"No service-desc link found. See <{spec_url}> for more info.",
)

# D
for link in jsondata["links"]:
if link["rel"] == "service-doc":
if servicedoc_type not in link["type"]:
return (
False,
f"Service-doc should have type <{servicedoc_type}>. Found <{link['type']}> See <{spec_url}> for more info.",
)
break
else:
return (
False,
f"Landing page should linkt to service-doc, with type {servicedoc_type}. See <{spec_url}> for more info.",
)
return True, ""


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
try:
if len(jsondata["title"]) > 50:
return (
False,
f"Collection title should not exceed 50 chars. See <{spec_url}> for more info.",
)
except json.JSONDecodeError as err:
# 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,
"",
)
8 changes: 4 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = unittest, black, prospector, bandit, py{311,312}, markdown
envlist = unittest, format, prospector, bandit, py{311,312}, markdown

# Tell tox to not require a setup.py file
skipsdist = True
Expand Down Expand Up @@ -33,13 +33,13 @@ commands = prospector --no-autodetect \
--zero-exit \
{toxinidir}/sedr/

[testenv:black]
[testenv:format]
ignore_outcome = true
description = Check code style
description = Fix code style
deps =
-r{toxinidir}/requirements.txt
-r{toxinidir}/requirements-dev.txt
commands = black --check {toxinidir}/sedr
commands = ruff format {toxinidir}/sedr

[testenv:mypy]
ignore_outcome = true
Expand Down

0 comments on commit 435c81a

Please sign in to comment.