forked from aws-samples/hardeneks
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Get sensible defaults for args
- Loading branch information
1 parent
c74f80a
commit d0e8fe5
Showing
2 changed files
with
63 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
from unittest.mock import patch | ||
from pathlib import Path | ||
|
||
from click import exceptions | ||
import pytest | ||
from typer.testing import CliRunner | ||
|
||
|
||
from hardeneks import app, _config_callback | ||
|
||
runner = CliRunner() | ||
from hardeneks import ( | ||
_config_callback, | ||
_get_cluster_name, | ||
_get_current_context, | ||
) | ||
|
||
|
||
def test_config_callback_path_non_existent(): | ||
|
@@ -36,6 +38,25 @@ def test_config_callback_bad_yaml(tmp_path): | |
_config_callback(config) | ||
|
||
|
||
def test_app_no_input(): | ||
result = runner.invoke(app, []) | ||
assert result.exit_code == 2 | ||
@patch("kubernetes.config.list_kube_config_contexts") | ||
def test_get_current_context_None(config): | ||
config.return_value = ({}, {"name": "some-context"}) | ||
context = _get_current_context("") | ||
assert context == "some-context" | ||
|
||
|
||
def test_get_current_context(): | ||
context = "some-context" | ||
assert _get_current_context(context) == context | ||
|
||
|
||
@patch("boto3.client") | ||
def test_get_cluster_name(client): | ||
client.return_value.list_clusters.return_value = { | ||
"clusters": ["gpu-cluster-test", "foo-cluster", "bad-cluster"] | ||
} | ||
context = "[email protected]" | ||
region = "us-west-2" | ||
cluster_name = "gpu-cluster-test" | ||
|
||
assert _get_cluster_name(context, region) == cluster_name |