Skip to content

Commit

Permalink
new formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Molaire committed Jul 24, 2023
1 parent 12848be commit 7bbda75
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 17 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ s3transfer==0.6.0
setuptools==65.5.1
six==1.15.0
sshpubkeys==3.1.0
task-processing==0.12.2
stack-data==0.6.2
task-processing==0.12.2
traitlets==5.0.0
Twisted==22.10.0
typing-extensions==4.5.0
Expand Down
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
"Intended Audience :: System Administrators",
"Development Status :: 4 - Beta",
],
packages=find_packages(exclude=["tests.*", "tests", "example-cluster"],) + ["tronweb"],
packages=find_packages(
exclude=["tests.*", "tests", "example-cluster"],
)
+ ["tronweb"],
scripts=glob.glob("bin/*") + glob.glob("tron/bin/*.py"),
include_package_data=True,
long_description="""
Expand Down
52 changes: 41 additions & 11 deletions tests/config/config_parse_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,9 @@ class ConfigTestCase(TestCase):
secret_name="secret1",
container_path="/b/c",
default_mode="0644",
items=[dict(key="secret1", path="abcd", mode="777"),],
items=[
dict(key="secret1", path="abcd", mode="777"),
],
),
],
cap_add=["KILL"],
Expand Down Expand Up @@ -1592,8 +1594,14 @@ class TestValidSecretVolumeItem:
"config",
[
{"path": "abc"},
{"key": "abc",},
{"key": "abc", "path": "abc", "extra_key": None,},
{
"key": "abc",
},
{
"key": "abc",
"path": "abc",
"extra_key": None,
},
{"key": "abc", "path": "abc", "mode": "a"},
],
)
Expand All @@ -1602,7 +1610,8 @@ def test_invalid(self, config):
config_parse.valid_secret_volume_item(config, NullConfigContext)

@pytest.mark.parametrize(
"config", [{"key": "abc", "path": "abc"}, {"key": "abc", "path": "abc", "mode": "777"}],
"config",
[{"key": "abc", "path": "abc"}, {"key": "abc", "path": "abc", "mode": "777"}],
)
def test_valid_job_secret_volume_success(self, config):
config_parse.valid_secret_volume_item(config, NullConfigContext)
Expand All @@ -1617,15 +1626,23 @@ class TestValidSecretVolume:
secret_name="secret1",
container_path="/b/c",
default_mode="0644",
items=[dict(key="secret1", path="abcd", mode="7778"),],
items=[
dict(key="secret1", path="abcd", mode="7778"),
],
),
dict(
secret_volume_name="abc",
container_path="/b/c",
default_mode="0644",
items=[dict(key="secret1", path="abcd", mode="7777"),],
items=[
dict(key="secret1", path="abcd", mode="7777"),
],
),
dict(
secret_volume_name="abc",
secret_name="secret1",
container_path=123,
),
dict(secret_volume_name="abc", secret_name="secret1", container_path=123,),
dict(
secret_volume_name="abc",
secret_name="secret1",
Expand All @@ -1643,7 +1660,9 @@ def test_wrong_item_key(self):
secret_volume_name="abc",
secret_name="secret1",
container_path="/b/c",
items=[dict(key="secret2", path="abc"),],
items=[
dict(key="secret2", path="abc"),
],
)
with pytest.raises(ConfigError):
config_parse.valid_secret_volume(config, NullConfigContext)
Expand All @@ -1656,10 +1675,21 @@ def test_wrong_item_key(self):
secret_name="secret1",
container_path="/b/c",
default_mode="0644",
items=[dict(key="secret1", path="abc"),],
items=[
dict(key="secret1", path="abc"),
],
),
dict(
secret_volume_name="abc",
secret_name="secret1",
container_path="/b/c",
items=[],
),
dict(
secret_volume_name="abc",
secret_name="secret1",
container_path="/b/c",
),
dict(secret_volume_name="abc", secret_name="secret1", container_path="/b/c", items=[],),
dict(secret_volume_name="abc", secret_name="secret1", container_path="/b/c",),
],
)
def test_valid(self, config):
Expand Down
8 changes: 7 additions & 1 deletion tests/core/action_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ def test_from_config_full(self, disk):
items=[ConfigSecretVolumeItem(key="key", path="path", mode="0755")],
),
],
extra_volumes=[ConfigVolume(host_path="/tmp", container_path="/nail/tmp", mode="RO",),],
extra_volumes=[
ConfigVolume(
host_path="/tmp",
container_path="/nail/tmp",
mode="RO",
),
],
trigger_downstreams=True,
triggered_by=["foo.bar"],
)
Expand Down
22 changes: 19 additions & 3 deletions tron/config/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,23 @@ def config_object_factory(name, required=None, optional=None):
optional=[],
)

ConfigVolume = config_object_factory(name="ConfigVolume", required=["container_path", "host_path",], optional=["mode"],)
ConfigVolume = config_object_factory(
name="ConfigVolume",
required=[
"container_path",
"host_path",
],
optional=["mode"],
)


ConfigSecretVolumeItem = config_object_factory(
name="ConfigSecretVolumeItem", required=["key", "path",], optional=["mode"],
name="ConfigSecretVolumeItem",
required=[
"key",
"path",
],
optional=["mode"],
)


Expand All @@ -259,7 +271,11 @@ def _asdict(self) -> dict:
return d


ConfigSecretSource = config_object_factory(name="ConfigSecretSource", required=["secret_name", "key"], optional=[],)
ConfigSecretSource = config_object_factory(
name="ConfigSecretSource",
required=["secret_name", "key"],
optional=[],
)

ConfigFieldSelectorSource = config_object_factory(
name="ConfigFieldSelectorSource",
Expand Down

0 comments on commit 7bbda75

Please sign in to comment.