Skip to content

Commit 53fbdc4

Browse files
committed
Add unit tests
1 parent d2157cd commit 53fbdc4

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

src/aks-preview/azext_aks_preview/tests/latest/test_managed_cluster_decorator.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4617,6 +4617,23 @@ def test_get_enable_high_log_scale_mode_explicit_true(self):
46174617
result = ctx.get_enable_high_log_scale_mode()
46184618
self.assertTrue(result)
46194619

4620+
def test_get_enable_high_log_scale_mode_flag_without_value_create(self):
4621+
"""Test passing --enable-high-log-scale-mode without an explicit boolean value.
4622+
4623+
When using get_three_state_flag() and the user passes the flag without a value
4624+
(e.g. --enable-high-log-scale-mode), argparse sets it to True via nargs='?'.
4625+
This should behave identically to passing --enable-high-log-scale-mode true.
4626+
"""
4627+
# get_three_state_flag uses nargs='?'; no value => True
4628+
ctx = AKSPreviewManagedClusterContext(
4629+
self.cmd,
4630+
AKSManagedClusterParamDict({"enable_high_log_scale_mode": True}),
4631+
self.models,
4632+
decorator_mode=DecoratorMode.CREATE,
4633+
)
4634+
result = ctx.get_enable_high_log_scale_mode()
4635+
self.assertTrue(result)
4636+
46204637
def test_get_enable_high_log_scale_mode_auto_enable_with_container_network_logs(self):
46214638
"""Test auto-enable when container network logs are enabled with proper prerequisites."""
46224639
ctx = AKSPreviewManagedClusterContext(
@@ -4780,6 +4797,31 @@ def test_get_enable_high_log_scale_mode_update_error_without_existing_monitoring
47804797
with self.assertRaises(RequiredArgumentMissingError):
47814798
ctx.get_enable_high_log_scale_mode()
47824799

4800+
def test_get_enable_high_log_scale_mode_flag_without_value_update(self):
4801+
"""Test passing --enable-high-log-scale-mode without an explicit boolean in update mode.
4802+
4803+
When using get_three_state_flag() and the user passes the flag without a value
4804+
(e.g. --enable-high-log-scale-mode), argparse sets it to True via nargs='?'.
4805+
In update mode this should enable HLSM on the existing cluster.
4806+
"""
4807+
ctx = AKSPreviewManagedClusterContext(
4808+
self.cmd,
4809+
AKSManagedClusterParamDict({"enable_high_log_scale_mode": True}),
4810+
self.models,
4811+
decorator_mode=DecoratorMode.UPDATE,
4812+
)
4813+
mc = self.models.ManagedCluster(
4814+
location="test_location",
4815+
addon_profiles={
4816+
"omsagent": self.models.ManagedClusterAddonProfile(
4817+
enabled=True,
4818+
)
4819+
},
4820+
)
4821+
ctx.attach_mc(mc)
4822+
result = ctx.get_enable_high_log_scale_mode()
4823+
self.assertTrue(result)
4824+
47834825
def test_get_container_network_logs_returns_none_when_not_specified(self):
47844826
"""Test get_container_network_logs returns None when neither enable nor disable is specified."""
47854827
ctx = AKSPreviewManagedClusterContext(

0 commit comments

Comments
 (0)