Skip to content

Commit

Permalink
Store ns pool list in config.py
Browse files Browse the repository at this point in the history
  • Loading branch information
bsquizz committed Jun 23, 2022
1 parent 20134bd commit d1336c0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 27 deletions.
14 changes: 4 additions & 10 deletions bonfire/bonfire.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,10 @@ def _validate_reservation_duration(ctx, param, value):
),
click.option(
"--pool",
type=click.Choice(["default", "minimal", "managed-kafka"], case_sensitive=False),
type=click.Choice(conf.NAMESPACE_POOLS, case_sensitive=False),
default="default",
show_default=True,
help="Specifies the pool type name.",
help="Specifies the pool type name",
),
_local_option,
]
Expand Down Expand Up @@ -645,7 +645,7 @@ def _list_namespaces(available, mine, output):
"status": ns.status,
"requester": ns.requester,
"expires_in": ns.expires_in,
"pool_type": ns.pool_type
"pool_type": ns.pool_type,
}
click.echo(json.dumps(data, indent=2))
else:
Expand Down Expand Up @@ -833,13 +833,7 @@ def _process(
@pool.command("list")
def _cmd_pool_types():
"""List all pool types"""
pool_type_list = [
"default",
"minimal",
"managed-kafka"
]

click.echo("\n".join([pool_name for pool_name in pool_type_list]))
click.echo("\n".join(conf.NAMESPACE_POOLS))


@main.command("process")
Expand Down
2 changes: 2 additions & 0 deletions bonfire/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
DEFAULT_ENV_PATH = get_config_path().joinpath("env")
DEFAULT_SECRETS_DIR = get_config_path().joinpath("secrets")

NAMESPACE_POOLS = ["default", "minimal", "managed-kafka"]

DEFAULT_CLOWDENV_TEMPLATE = resource_filename(
"bonfire", "resources/local-cluster-clowdenvironment.yaml"
)
Expand Down
27 changes: 10 additions & 17 deletions tests/test_bonfire.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import json
from pathlib import Path
from unittest.mock import ANY

import pytest
from unittest.mock import ANY
from click.testing import CliRunner

import bonfire.config as conf
from bonfire import bonfire

DATA_PATH = Path(__file__).parent.joinpath("data")
Expand Down Expand Up @@ -206,31 +207,21 @@ def test_ns_list_flag_output(
"reserved": True,
"status": "false",
"requester": "user-1",
"pool_type": "minimal"
"pool_type": "minimal",
}
test_items_2 = {
"reserved": True,
"status": "false",
"requester": "user-2",
"pool_type": "default"
}
test_items_3 = {
"reserved": False,
"status": "ready",
"requester": None,
"pool_type": "default"
}
test_items_4 = {
"reserved": False,
"status": "ready",
"requester": None,
"pool_type": "default"
"pool_type": "default",
}
test_items_3 = {"reserved": False, "status": "ready", "requester": None, "pool_type": "default"}
test_items_4 = {"reserved": False, "status": "ready", "requester": None, "pool_type": "default"}
test_items_5 = {
"reserved": True,
"status": "false",
"requester": "user-5",
"pool_type": "default"
"pool_type": "default",
}

assert all([item in test_items_1.items() for item in actual_ns_1.items()])
Expand Down Expand Up @@ -271,4 +262,6 @@ def test_pool_list_command(caplog):
runner = CliRunner()
result = runner.invoke(bonfire.pool, ["list"])

assert result.output == "default\nminimal\nmanaged-kafka\n"
output = [r for r in result.output.split("\n") if r != ""]

assert output == conf.NAMESPACE_POOLS

0 comments on commit d1336c0

Please sign in to comment.