Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions commodore/component/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,11 @@ def _prepare_kapitan_inventory(
# We plug "fake" Argo CD library here because every component relies on it
# and we don't want to provide it every time when compiling a single component.
with open(inv.lib_dir / "argocd.libjsonnet", "w", encoding="utf-8") as argocd_libf:
argocd_libf.write(
dedent(
"""
argocd_libf.write(dedent("""
local ArgoApp(component, namespace, project='', secrets=true, base=null) = {};
local ArgoProject(name) = {};

{
App: ArgoApp,
Project: ArgoProject,
}"""
)
)
}"""))
8 changes: 2 additions & 6 deletions commodore/package/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,11 @@ def _setup_inventory(
# We plug "fake" Argo CD library here because every component relies on it
# and we don't want to provide it every time when compiling a single component.
with open(inv.lib_dir / "argocd.libjsonnet", "w", encoding="utf-8") as argocd_libf:
argocd_libf.write(
dedent(
"""
argocd_libf.write(dedent("""
local ArgoApp(component, namespace, project='', secrets=true) = {};
local ArgoProject(name) = {};

{
App: ArgoApp,
Project: ArgoProject,
}"""
)
)
}"""))
60 changes: 30 additions & 30 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pytest = "9.0.2"
pytest-xdist = "3.8.0"
pytest-benchmark = "5.2.3"
responses = "0.25.8"
black = "25.12.0"
black = "26.1.0"
pyfakefs = "6.0.0"
pytest-cov = "7.0.0"
pylint = "4.0.4"
Expand Down
24 changes: 8 additions & 16 deletions tests/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,18 +444,14 @@ def test_kapitan_029_030_difffunc_suppresses_noise():


def test_ignore_yaml_formatting_difffunc_keep_semantic_whitespace():
before_text = textwrap.dedent(
"""
before_text = textwrap.dedent("""
a:
b: b
"""
)
after_text = textwrap.dedent(
"""
""")
after_text = textwrap.dedent("""
a:
b: b
"""
)
""")

diffs, suppressed = catalog._ignore_yaml_formatting_difffunc(
before_text, after_text, fromfile="test", tofile="test"
Expand All @@ -477,22 +473,18 @@ def test_ignore_yaml_formatting_difffunc_keep_semantic_whitespace():


def test_ignore_yaml_formatting_difffunc_suppresses_noise():
before_text = textwrap.dedent(
"""
before_text = textwrap.dedent("""
a:
- a
- b
b: b
"""
)
after_text = textwrap.dedent(
"""
""")
after_text = textwrap.dedent("""
a:
- a
- b
b: b
"""
)
""")

diffs, suppressed = catalog._ignore_yaml_formatting_difffunc(
before_text, after_text, fromfile="test", tofile="test"
Expand Down
1 change: 0 additions & 1 deletion tests/test_commodore_libjsonnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import pytest
import yaml


TESTS_DIR = Path(__file__).parent / "jsonnet"


Expand Down
8 changes: 2 additions & 6 deletions tests/test_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,7 @@ def _setup_render_jsonnetfile_json(tmp_path: P) -> Component:
ur = cr.clone(upath)
jsonnetfile = upath / "jsonnetfile.jsonnet"
with open(jsonnetfile, "w") as jf:
jf.write(
dedent(
"""
jf.write(dedent("""
{
version: 1,
dependencies: [
Expand All @@ -288,9 +286,7 @@ def _setup_render_jsonnetfile_json(tmp_path: P) -> Component:
},
],
legacyImports: true,
}"""
)
)
}"""))
ur.index.add("*")
ur.index.commit("initial commit")
ur.remote().push()
Expand Down
14 changes: 4 additions & 10 deletions tests/test_component_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ def _prepare_component(
shutil.move(str(component_root / ".git"), str(tmp_path / component_name))

with open(component_root / "component/main.jsonnet", "a") as file:
file.write(
dedent(
"""
file.write(dedent("""
{
"test_service_account": kube.ServiceAccount('test') {
metadata+: {
Expand All @@ -60,9 +58,7 @@ def _prepare_component(
},
},
},
}"""
)
)
}"""))
return component_root


Expand Down Expand Up @@ -343,8 +339,7 @@ def test_component_compile_kustomize(tmp_path: P, cli_runner: RunnerFunc):
with open(
component_path / "component" / "kustomization.jsonnet", "w", encoding="utf-8"
) as f:
f.write(
"""
f.write("""
local com = import 'lib/commodore.libjsonnet';

com.Kustomization(
Expand All @@ -359,8 +354,7 @@ def test_component_compile_kustomize(tmp_path: P, cli_runner: RunnerFunc):
{
namespace: 'foo',
}
)"""
)
)""")
with open(
component_path / "class" / f"{component_name}.yml", "r", encoding="utf-8"
) as cyaml:
Expand Down
6 changes: 2 additions & 4 deletions tests/test_component_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -1729,14 +1729,12 @@ def test_component_update_raises_on_merge_conflict(
with open(
component_path / "lib" / "test-component.libsonnet", "w", encoding="utf-8"
) as f:
f.write(
"""// Test contents
f.write("""// Test contents

{
Foo: {bar: 1, baz: false},
}
"""
)
""")

r = Repo(component_path)
r.index.add([".cruft.json", "lib/test-component.libsonnet"])
Expand Down
9 changes: 2 additions & 7 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,16 +327,11 @@ def test_print_deprecation_notices(config, capsys):

config.print_deprecation_notices()
captured = capsys.readouterr()
assert (
textwrap.dedent(
"""
assert textwrap.dedent("""
Commodore notices:
> test 1
> test 2
"""
)
== captured.out
)
""") == captured.out


def mock_get_token(url: str) -> Optional[str]:
Expand Down
42 changes: 14 additions & 28 deletions tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,44 +62,36 @@ def _test_yaml_dump_fun(
[
(
{"a": 1, "b": "test"},
textwrap.dedent(
"""
textwrap.dedent("""
a: 1
b: test
"""
)[1:],
""")[1:],
),
(
{"a": [1, 2], "b": "test"},
textwrap.dedent(
"""
textwrap.dedent("""
a:
- 1
- 2
b: test
"""
)[1:],
""")[1:],
),
(
{"a": {"test": 1}, "b": "test"},
textwrap.dedent(
"""
textwrap.dedent("""
a:
test: 1
b: test
"""
)[1:],
""")[1:],
),
(
{"a": "first line\nsecond line", "b": "test"},
textwrap.dedent(
"""
textwrap.dedent("""
a: |-
first line
second line
b: test
"""
)[1:],
""")[1:],
),
],
)
Expand All @@ -112,38 +104,32 @@ def test_yaml_dump(tmp_path: Path, input, expected):
[
(
[{"a": 1}, {"b": "test"}],
textwrap.dedent(
"""
textwrap.dedent("""
a: 1
---
b: test
"""
)[1:],
""")[1:],
),
(
[{"a": {"test": "first line\nsecond line"}}, {"b": "test"}],
textwrap.dedent(
"""
textwrap.dedent("""
a:
test: |-
first line
second line
---
b: test
"""
)[1:],
""")[1:],
),
(
[{"a": [1, 2]}, {"b": "test"}],
textwrap.dedent(
"""
textwrap.dedent("""
a:
- 1
- 2
---
b: test
"""
)[1:],
""")[1:],
),
],
)
Expand Down
1 change: 0 additions & 1 deletion tests/test_inventory_lint_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from commodore.inventory import lint_dependency_specification
from commodore.inventory import lint


LINT_FILECONTENTS = [
({}, 0),
({"a": "b"}, 0),
Expand Down
1 change: 0 additions & 1 deletion tests/test_inventory_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from commodore.inventory import parameters
from commodore.helpers import yaml_dump


GLOBAL_PARAMS = {
"components": {
"tc1": {
Expand Down
Loading