Esempio n. 1
0
 def test_services(self):
     '''
     Tests services 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_service.return_value.to_dict.return_value":
                     {'items': [{'metadata': {'name': 'mock_service_name'}}]}}
             )
             self.assertEqual(kubernetes.services(), ['mock_service_name'])
             self.assertTrue(kubernetes.kubernetes.client.CoreV1Api().list_namespaced_service().to_dict.called)
Esempio n. 2
0
 def test_services(self):
     """
     Tests services 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_service.return_value.to_dict.return_value": {
                         "items": [{"metadata": {"name": "mock_service_name"}}]
                     }
                 }
             )
             self.assertEqual(kubernetes.services(), ["mock_service_name"])
             # pylint: disable=E1120
             self.assertTrue(
                 kubernetes.kubernetes.client.CoreV1Api()
                 .list_namespaced_service()
                 .to_dict.called
             )