Skip to content

Commit

Permalink
test: add more unit test coverage
Browse files Browse the repository at this point in the history
fix
  • Loading branch information
andyzhangx committed May 16, 2022
1 parent 9b5566f commit 657106b
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions src/aks-preview/azext_aks_preview/tests/latest/test_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,39 @@ def test_get_disk_driver_update(self):
with self.assertRaises(MutuallyExclusiveArgumentError):
ctx_4.get_snapshot_controller()

# default with csi driver enabled flag
ctx_5 = AKSPreviewContext(
self.cmd,
{
"enable_disk_driver": True,
"enable_file_driver": True,
"enable_snapshot_controller": True,
},
self.models,
decorator_mode=DecoratorMode.UPDATE,
)
storage_profile = (
self.models.ManagedClusterStorageProfile(
disk_csi_driver = self.models.ManagedClusterStorageProfileDiskCSIDriver(
enabled = True,
),
file_csi_driver = self.models.ManagedClusterStorageProfileFileCSIDriver(
enabled = True,
),
snapshot_controller = self.models.ManagedClusterStorageProfileSnapshotController(
enabled = True,
),
)
)
mc = self.models.ManagedCluster(
location="test_location",
storage_profile=storage_profile,
)
ctx_5.attach_mc(mc)
self.assertEqual(
ctx_5.get_storage_profile(), storage_profile
)

def test_get_disk_driver_create(self):
# default
ctx_1 = AKSPreviewContext(
Expand Down Expand Up @@ -927,6 +960,39 @@ def test_get_disk_driver_create(self):
with self.assertRaises(MutuallyExclusiveArgumentError):
ctx_4.get_snapshot_controller()

# default with csi driver enabled flag
ctx_5 = AKSPreviewContext(
self.cmd,
{
"enable_disk_driver": True,
"enable_file_driver": True,
"enable_snapshot_controller": True,
},
self.models,
decorator_mode=DecoratorMode.CREATE,
)
storage_profile = (
self.models.ManagedClusterStorageProfile(
disk_csi_driver = self.models.ManagedClusterStorageProfileDiskCSIDriver(
enabled = True,
),
file_csi_driver = self.models.ManagedClusterStorageProfileFileCSIDriver(
enabled = True,
),
snapshot_controller = self.models.ManagedClusterStorageProfileSnapshotController(
enabled = True,
),
)
)
mc = self.models.ManagedCluster(
location="test_location",
storage_profile=storage_profile,
)
ctx_5.attach_mc(mc)
self.assertEqual(
ctx_5.get_storage_profile(), storage_profile
)

def test_get_enable_pod_security_policy(self):
# default
ctx_1 = AKSPreviewContext(
Expand Down

0 comments on commit 657106b

Please sign in to comment.