Esempio n. 1
0
 def test_pods(self):
     '''
     Tests pods listing.
     :return:
     '''
     with mock_kubernetes_library() as mock_kubernetes_lib:
         with patch.dict(kubernetes.__salt__, {'config.option': Mock(side_effect=self.settings)}):
             mock_kubernetes_lib.client.CoreV1Api.return_value = Mock(
                 **{"list_namespaced_pod.return_value.to_dict.return_value":
                     {'items': [{'metadata': {'name': 'mock_pod_name'}}]}}
             )
             self.assertEqual(kubernetes.pods(), ['mock_pod_name'])
             self.assertTrue(kubernetes.kubernetes.client.CoreV1Api().
                             list_namespaced_pod().to_dict.called)
Esempio n. 2
0
 def test_pods(self):
     """
     Tests pods listing.
     :return:
     """
     with mock_kubernetes_library() as mock_kubernetes_lib:
         with patch.dict(
             kubernetes.__salt__, {"config.option": Mock(side_effect=self.settings)}
         ):
             mock_kubernetes_lib.client.CoreV1Api.return_value = Mock(
                 **{
                     "list_namespaced_pod.return_value.to_dict.return_value": {
                         "items": [{"metadata": {"name": "mock_pod_name"}}]
                     }
                 }
             )
             self.assertEqual(kubernetes.pods(), ["mock_pod_name"])
             # pylint: disable=E1120
             self.assertTrue(
                 kubernetes.kubernetes.client.CoreV1Api()
                 .list_namespaced_pod()
                 .to_dict.called
             )