Skip to content
Snippets Groups Projects
Verified Commit e6b358dd authored by Karel van Klink's avatar Karel van Klink :smiley_cat:
Browse files

remove redundant trailing commas, and reformat

parent ba647a07
No related branches found
No related tags found
2 merge requests!72Feature/ignore trailing comma,!71Publish LSO version 1.0
Pipeline #85189 passed
......@@ -6,9 +6,7 @@ import lso
config_filename = os.path.join(os.path.dirname(__file__), "..", "config.json.example")
output_filename = os.path.join(
os.path.dirname(__file__), "source", "_static", "openapi.json"
)
output_filename = os.path.join(os.path.dirname(__file__), "source", "_static", "openapi.json")
os.environ["SETTINGS_FILENAME"] = config_filename
app = lso.create_app()
......
......@@ -16,9 +16,7 @@ import json
import os
import sys
sys.path.insert(
0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "lso"))
)
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "lso")))
class RenderAsJSON(Directive):
......@@ -37,7 +35,7 @@ class RenderAsJSON(Directive):
return [
addnodes.desc_name(text=member_name),
addnodes.desc_content("", literal),
addnodes.desc_content("", literal)
]
......@@ -57,7 +55,7 @@ extensions = [
"sphinx_rtd_theme",
"sphinx.ext.autodoc",
"sphinx.ext.coverage",
"sphinx.ext.todo",
"sphinx.ext.todo"
]
templates_path = ["templates"]
......@@ -67,9 +65,7 @@ exclude_patterns = []
html_theme = "sphinx_rtd_theme"
html_static_path = ["_static"]
html_theme_options = {
"style_nav_header_background": "rgb(0 63 95)",
}
html_theme_options = {"style_nav_header_background": "rgb(0 63 95)"}
html_css_files = ["custom.css"]
html_logo = "_static/geant_logo_white.svg"
......
......@@ -18,11 +18,7 @@ def create_app() -> FastAPI:
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"]
)
app.include_router(default_router, prefix="/api")
......
......@@ -15,9 +15,7 @@ from pydantic import BaseModel
CONFIG_SCHEMA = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"ansible_playbooks_root_dir": {"type": "string"},
},
"properties": {"ansible_playbooks_root_dir": {"type": "string"}},
"required": ["ansible_playbooks_root_dir"],
"additionalProperties": False,
}
......
......@@ -15,15 +15,9 @@ LOGGING_DEFAULT_CONFIG = {
"level": "DEBUG",
"formatter": "simple",
"stream": "ext://sys.stdout",
},
},
"loggers": {
"resource_management": {
"level": "DEBUG",
"handlers": ["console"],
"propagate": False,
},
}
},
"loggers": {"resource_management": {"level": "DEBUG", "handlers": ["console"], "propagate": False}},
"root": {"level": "INFO", "handlers": ["console"]},
}
......
......@@ -44,11 +44,7 @@ def playbook_launch_error(reason: str, status_code: int = status.HTTP_400_BAD_RE
def _run_playbook_proc(
job_id: str,
playbook_path: str,
extra_vars: dict,
inventory: dict[str, Any] | str,
callback: str,
job_id: str, playbook_path: str, extra_vars: dict, inventory: dict[str, Any] | str, callback: str
) -> None:
"""Run a playbook, internal function.
......@@ -58,11 +54,7 @@ def _run_playbook_proc(
:param str callback: Callback URL to return output to when execution is completed.
:param dict[str, Any] | str inventory: Ansible inventory to run the playbook against.
"""
ansible_playbook_run = ansible_runner.run(
playbook=playbook_path,
inventory=inventory,
extravars=extra_vars,
)
ansible_playbook_run = ansible_runner.run(playbook=playbook_path, inventory=inventory, extravars=extra_vars)
payload = {
"status": ansible_playbook_run.status,
......
......@@ -18,27 +18,10 @@ def test_playbook_endpoint_dict_inventory_success(client: TestClient, mocked_ans
"playbook_name": "placeholder.yaml",
"callback": TEST_CALLBACK_URL,
"inventory": {
"_meta": {
"vars": {
"host1.local": {
"foo": "bar",
},
"host2.local": {
"hello": "world",
},
},
},
"all": {
"hosts": {
"host1.local": None,
"host2.local": None,
},
},
},
"extra_vars": {
"dry_run": True,
"commit_comment": "I am a robot!",
"_meta": {"vars": {"host1.local": {"foo": "bar"}, "host2.local": {"hello": "world"}}},
"all": {"hosts": {"host1.local": None, "host2.local": None}},
},
"extra_vars": {"dry_run": True, "commit_comment": "I am a robot!"},
}
with patch("lso.playbook.ansible_runner.run", new=mocked_ansible_runner_run) as _:
......@@ -60,11 +43,7 @@ def test_playbook_endpoint_str_inventory_success(client: TestClient, mocked_ansi
params = {
"playbook_name": "placeholder.yaml",
"callback": TEST_CALLBACK_URL,
"inventory": {
"all": {
"hosts": "host1.local\nhost2.local\nhost3.local",
},
},
"inventory": {"all": {"hosts": "host1.local\nhost2.local\nhost3.local"}},
}
with patch("lso.playbook.ansible_runner.run", new=mocked_ansible_runner_run) as _:
......@@ -85,19 +64,8 @@ def test_playbook_endpoint_invalid_host_vars(client: TestClient, mocked_ansible_
"playbook_name": "placeholder.yaml",
"callback": TEST_CALLBACK_URL,
"inventory": {
"_meta": {
"host_vars": {
"host1.local": {
"foo": "bar",
},
"host2.local": {
"hello": "world",
},
},
},
"all": {
"hosts": "host1.local\nhost2.local\nhost3.local",
},
"_meta": {"host_vars": {"host1.local": {"foo": "bar"}, "host2.local": {"hello": "world"}}},
"all": {"hosts": "host1.local\nhost2.local\nhost3.local"},
},
}
......@@ -122,16 +90,8 @@ def test_playbook_endpoint_invalid_hosts(client: TestClient, mocked_ansible_runn
"playbook_name": "placeholder.yaml",
"callback": TEST_CALLBACK_URL,
"inventory": {
"_meta": {
"vars": {
"host1.local": {
"foo": "bar",
},
},
},
"all": {
"hosts": ["host1.local", "host2.local", "host3.local"],
},
"_meta": {"vars": {"host1.local": {"foo": "bar"}}},
"all": {"hosts": ["host1.local", "host2.local", "host3.local"]},
},
}
......
......@@ -22,12 +22,7 @@ def test_validate_testenv_config(data_config_filename: str) -> None:
@pytest.mark.parametrize(
"bad_config",
[
{"name": "bad version", "version": 123},
{"name": "missing version"},
{"version": "missing name"},
],
"bad_config", [{"name": "bad version", "version": 123}, {"name": "missing version"}, {"version": "missing name"}]
)
def test_bad_config(bad_config: dict) -> None:
with tempfile.NamedTemporaryFile(mode="w") as file:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment