diff --git a/tests/test_eks.py b/tests/test_eks.py index 5f7b1450..3abb7c21 100644 --- a/tests/test_eks.py +++ b/tests/test_eks.py @@ -31,9 +31,10 @@ def test_list_clusters(eks_patch, monkeypatch): assert all_clusters == {'region1': ['hastags']} -class MockedEKSClient(): +class MockedEKSClient: def __init__(self): self.clusters_list = [] + self.deleted_clusters = [] def list_clusters(self): return self.clusters_list @@ -49,6 +50,15 @@ def describe_cluster(self, name=None): return {'cluster': {'tags': {'pcw_ignore': '1'}}} return None + def delete_cluster(self, *args, **kwargs): + self.deleted_clusters.append(kwargs['name']) + + def list_nodegroups(self, *args, **kwargs): + return {'nodegroups': []} + + def list_services(self, *args, **kwargs): + return {'services': []} + @pytest.fixture def eks_patch(monkeypatch): @@ -96,6 +106,15 @@ def test_create_credentials_file(eks_patch, monkeypatch): eks_patch.create_credentials_file() +def test_delete_all_clusters(eks_patch, monkeypatch): + mocked_eks = MockedEKSClient() + mocked_eks.clusters_list = {'clusters': ['cluster1']} + monkeypatch.setattr(EKS, 'eks_client', lambda self, region: mocked_eks) + + eks_patch.delete_all_clusters() + assert mocked_eks.deleted_clusters == ['cluster1'] + + def test_cleanup_k8s_jobs(eks_patch, monkeypatch): mocked_eks = MockedEKSClient() mocked_eks.clusters_list = {'clusters': ['cluster1']}