Skip to content

Commit

Permalink
Add more tests to EKS
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardobranco777 committed Jun 26, 2023
1 parent 2e11c1e commit 4da909c
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion tests/test_eks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -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']}
Expand Down

0 comments on commit 4da909c

Please sign in to comment.