def setUp(self): executable = AUTH_BIN if is_windows: executable = AUTH_BIN + ".exe" self._correct_cluster_entry = OrderedDict([ ("cluster", OrderedDict([ ("certificate-authority-data", describe_cluster_response()\ ["cluster"]["certificateAuthority"]["data"]), ("server", describe_cluster_response()["cluster"]["endpoint"]) ])), ("name", describe_cluster_response()["cluster"]["arn"]) ]) self._correct_user_entry = OrderedDict([ ("name", describe_cluster_response()["cluster"]["arn"]), ("user", OrderedDict([("exec", OrderedDict([("apiVersion", API_VERSION), ("args", ["token", "-i", "ExampleCluster"]), ("command", executable)]))])) ]) self._mock_client = mock.Mock() self._mock_client.describe_cluster.return_value =\ describe_cluster_response() self._session = mock.Mock(spec=botocore.session.Session) self._session.create_client.return_value = self._mock_client self._client = EKSClient(self._session, "ExampleCluster", None)
def setUp(self): self._correct_cluster_entry = OrderedDict([ ("cluster", OrderedDict([ ("certificate-authority-data", describe_cluster_response()\ ["cluster"]["certificateAuthority"]["data"]), ("server", describe_cluster_response()["cluster"]["endpoint"]) ])), ("name", describe_cluster_response()["cluster"]["arn"]) ]) self._correct_user_entry = OrderedDict([ ("name", describe_cluster_response()["cluster"]["arn"]), ("user", OrderedDict([("exec", OrderedDict([("apiVersion", API_VERSION), ("args", [ "--region", "region", "eks", "get-token", "--cluster-name", "ExampleCluster" ]), ("command", "aws")]))])) ]) self._mock_client = mock.Mock() self._mock_client.describe_cluster.return_value =\ describe_cluster_response() self._session = mock.Mock(spec=botocore.session.Session) self._session.create_client.return_value = self._mock_client self._session.profile = None self._client = EKSClient(self._session, "ExampleCluster", None)
def setUp(self): self._correct_cluster_entry = OrderedDict([ ("cluster", OrderedDict([ ("certificate-authority-data", describe_cluster_response()\ ["cluster"]["certificateAuthority"]["data"]), ("server", describe_cluster_response()["cluster"]["endpoint"]) ])), ("name", describe_cluster_response()["cluster"]["arn"]) ]) self._correct_user_entry = OrderedDict([ ("name", describe_cluster_response()["cluster"]["arn"]), ("user", OrderedDict([ ("exec", OrderedDict([ ("apiVersion", API_VERSION), ("args", [ "--region", "region", "eks", "get-token", "--cluster-name", "ExampleCluster" ]), ("command", "aws") ])) ])) ]) self._mock_client = mock.Mock() self._mock_client.describe_cluster.return_value =\ describe_cluster_response() self._session = mock.Mock(spec=botocore.session.Session) self._session.create_client.return_value = self._mock_client self._session.profile = None self._client = EKSClient(self._session, "ExampleCluster", None)
class TestEKSClient(unittest.TestCase): def setUp(self): executable = AUTH_BIN if is_windows: executable = AUTH_BIN + ".exe" self._correct_cluster_entry = OrderedDict([ ("cluster", OrderedDict([ ("certificate-authority-data", describe_cluster_response()\ ["cluster"]["certificateAuthority"]["data"]), ("server", describe_cluster_response()["cluster"]["endpoint"]) ])), ("name", describe_cluster_response()["cluster"]["arn"]) ]) self._correct_user_entry = OrderedDict([ ("name", describe_cluster_response()["cluster"]["arn"]), ("user", OrderedDict([("exec", OrderedDict([("apiVersion", API_VERSION), ("args", ["token", "-i", "ExampleCluster"]), ("command", executable)]))])) ]) self._mock_client = mock.Mock() self._mock_client.describe_cluster.return_value =\ describe_cluster_response() self._session = mock.Mock(spec=botocore.session.Session) self._session.create_client.return_value = self._mock_client self._client = EKSClient(self._session, "ExampleCluster", None) def test_get_cluster_description(self): self.assertEqual(self._client._get_cluster_description(), describe_cluster_response()["cluster"]) self._mock_client.describe_cluster.assert_called_once_with( name="ExampleCluster") self._session.create_client.assert_called_once_with("eks") def test_get_cluster_description_no_status(self): self._mock_client.describe_cluster.return_value = \ describe_cluster_no_status_response() self.assertRaises(EKSClusterError, self._client._get_cluster_description) self._mock_client.describe_cluster.assert_called_once_with( name="ExampleCluster") self._session.create_client.assert_called_once_with("eks") def test_get_cluster_entry(self): self.assertEqual(self._client.get_cluster_entry(), self._correct_cluster_entry) self._mock_client.describe_cluster.assert_called_once_with( name="ExampleCluster") self._session.create_client.assert_called_once_with("eks") def test_get_user_entry(self): self.assertEqual(self._client.get_user_entry(), self._correct_user_entry) self._mock_client.describe_cluster.assert_called_once_with( name="ExampleCluster") self._session.create_client.assert_called_once_with("eks") def test_get_both(self): self.assertEqual(self._client.get_cluster_entry(), self._correct_cluster_entry) self.assertEqual(self._client.get_user_entry(), self._correct_user_entry) self._mock_client.describe_cluster.assert_called_once_with( name="ExampleCluster") self._session.create_client.assert_called_once_with("eks") def test_cluster_creating(self): self._mock_client.describe_cluster.return_value =\ describe_cluster_creating_response() self.assertRaises(EKSClusterError, self._client._get_cluster_description) self._mock_client.describe_cluster.assert_called_once_with( name="ExampleCluster") self._session.create_client.assert_called_once_with("eks") def test_cluster_deleting(self): self._mock_client.describe_cluster.return_value =\ describe_cluster_deleting_response() self.assertRaises(EKSClusterError, self._client._get_cluster_description) self._mock_client.describe_cluster.assert_called_once_with( name="ExampleCluster") self._session.create_client.assert_called_once_with("eks")
class TestEKSClient(unittest.TestCase): def setUp(self): self._correct_cluster_entry = OrderedDict([ ("cluster", OrderedDict([ ("certificate-authority-data", describe_cluster_response()\ ["cluster"]["certificateAuthority"]["data"]), ("server", describe_cluster_response()["cluster"]["endpoint"]) ])), ("name", describe_cluster_response()["cluster"]["arn"]) ]) self._correct_user_entry = OrderedDict([ ("name", describe_cluster_response()["cluster"]["arn"]), ("user", OrderedDict([("exec", OrderedDict([("apiVersion", API_VERSION), ("args", [ "--region", "region", "eks", "get-token", "--cluster-name", "ExampleCluster" ]), ("command", "aws")]))])) ]) self._mock_client = mock.Mock() self._mock_client.describe_cluster.return_value =\ describe_cluster_response() self._session = mock.Mock(spec=botocore.session.Session) self._session.create_client.return_value = self._mock_client self._session.profile = None self._client = EKSClient(self._session, "ExampleCluster", None) def test_get_cluster_description(self): self.assertEqual(self._client._get_cluster_description(), describe_cluster_response()["cluster"]) self._mock_client.describe_cluster.assert_called_once_with( name="ExampleCluster") self._session.create_client.assert_called_once_with("eks") def test_get_cluster_description_no_status(self): self._mock_client.describe_cluster.return_value = \ describe_cluster_no_status_response() self.assertRaises(EKSClusterError, self._client._get_cluster_description) self._mock_client.describe_cluster.assert_called_once_with( name="ExampleCluster") self._session.create_client.assert_called_once_with("eks") def test_get_cluster_entry(self): self.assertEqual(self._client.get_cluster_entry(), self._correct_cluster_entry) self._mock_client.describe_cluster.assert_called_once_with( name="ExampleCluster") self._session.create_client.assert_called_once_with("eks") def test_get_user_entry(self): self.assertEqual(self._client.get_user_entry(), self._correct_user_entry) self._mock_client.describe_cluster.assert_called_once_with( name="ExampleCluster") self._session.create_client.assert_called_once_with("eks") def test_get_both(self): self.assertEqual(self._client.get_cluster_entry(), self._correct_cluster_entry) self.assertEqual(self._client.get_user_entry(), self._correct_user_entry) self._mock_client.describe_cluster.assert_called_once_with( name="ExampleCluster") self._session.create_client.assert_called_once_with("eks") def test_cluster_creating(self): self._mock_client.describe_cluster.return_value =\ describe_cluster_creating_response() self.assertRaises(EKSClusterError, self._client._get_cluster_description) self._mock_client.describe_cluster.assert_called_once_with( name="ExampleCluster") self._session.create_client.assert_called_once_with("eks") def test_cluster_deleting(self): self._mock_client.describe_cluster.return_value =\ describe_cluster_deleting_response() self.assertRaises(EKSClusterError, self._client._get_cluster_description) self._mock_client.describe_cluster.assert_called_once_with( name="ExampleCluster") self._session.create_client.assert_called_once_with("eks") def test_profile(self): self._session.profile = "profile" self._correct_user_entry["user"]["exec"]["env"] = [ OrderedDict([("name", "AWS_PROFILE"), ("value", "profile")]) ] self.assertEqual(self._client.get_user_entry(), self._correct_user_entry) self._mock_client.describe_cluster.assert_called_once_with( name="ExampleCluster") self._session.create_client.assert_called_once_with("eks")
class TestEKSClient(unittest.TestCase): def setUp(self): self._correct_cluster_entry = OrderedDict([ ("cluster", OrderedDict([ ("certificate-authority-data", describe_cluster_response()\ ["cluster"]["certificateAuthority"]["data"]), ("server", describe_cluster_response()["cluster"]["endpoint"]) ])), ("name", describe_cluster_response()["cluster"]["arn"]) ]) self._correct_user_entry = OrderedDict([ ("name", describe_cluster_response()["cluster"]["arn"]), ("user", OrderedDict([ ("exec", OrderedDict([ ("apiVersion", API_VERSION), ("args", [ "--region", "region", "eks", "get-token", "--cluster-name", "ExampleCluster" ]), ("command", "aws") ])) ])) ]) self._mock_client = mock.Mock() self._mock_client.describe_cluster.return_value =\ describe_cluster_response() self._session = mock.Mock(spec=botocore.session.Session) self._session.create_client.return_value = self._mock_client self._session.profile = None self._client = EKSClient(self._session, "ExampleCluster", None) def test_get_cluster_description(self): self.assertEqual(self._client._get_cluster_description(), describe_cluster_response()["cluster"]) self._mock_client.describe_cluster.assert_called_once_with( name="ExampleCluster" ) self._session.create_client.assert_called_once_with("eks") def test_get_cluster_description_no_status(self): self._mock_client.describe_cluster.return_value = \ describe_cluster_no_status_response() self.assertRaises(EKSClusterError, self._client._get_cluster_description) self._mock_client.describe_cluster.assert_called_once_with( name="ExampleCluster" ) self._session.create_client.assert_called_once_with("eks") def test_get_cluster_entry(self): self.assertEqual(self._client.get_cluster_entry(), self._correct_cluster_entry) self._mock_client.describe_cluster.assert_called_once_with( name="ExampleCluster" ) self._session.create_client.assert_called_once_with("eks") def test_get_user_entry(self): self.assertEqual(self._client.get_user_entry(), self._correct_user_entry) self._mock_client.describe_cluster.assert_called_once_with( name="ExampleCluster" ) self._session.create_client.assert_called_once_with("eks") def test_get_both(self): self.assertEqual(self._client.get_cluster_entry(), self._correct_cluster_entry) self.assertEqual(self._client.get_user_entry(), self._correct_user_entry) self._mock_client.describe_cluster.assert_called_once_with( name="ExampleCluster" ) self._session.create_client.assert_called_once_with("eks") def test_cluster_creating(self): self._mock_client.describe_cluster.return_value =\ describe_cluster_creating_response() self.assertRaises(EKSClusterError, self._client._get_cluster_description) self._mock_client.describe_cluster.assert_called_once_with( name="ExampleCluster" ) self._session.create_client.assert_called_once_with("eks") def test_cluster_deleting(self): self._mock_client.describe_cluster.return_value =\ describe_cluster_deleting_response() self.assertRaises(EKSClusterError, self._client._get_cluster_description) self._mock_client.describe_cluster.assert_called_once_with( name="ExampleCluster" ) self._session.create_client.assert_called_once_with("eks") def test_profile(self): self._session.profile = "profile" self._correct_user_entry["user"]["exec"]["env"] = [ OrderedDict([ ("name", "AWS_PROFILE"), ("value", "profile") ]) ] self.assertEqual(self._client.get_user_entry(), self._correct_user_entry) self._mock_client.describe_cluster.assert_called_once_with( name="ExampleCluster" ) self._session.create_client.assert_called_once_with("eks")