Example #1
0
 def test_nodes(self):
     '''
     Test node 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_node.return_value.to_dict.return_value":
                     {'items': [{'metadata': {'name': 'mock_node_name'}}]}}
             )
             self.assertEqual(kubernetes.nodes(), ['mock_node_name'])
             self.assertTrue(kubernetes.kubernetes.client.CoreV1Api().list_node().to_dict.called)
Example #2
0
 def test_nodes(self):
     """
     Test node 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_node.return_value.to_dict.return_value": {
                         "items": [{"metadata": {"name": "mock_node_name"}}]
                     }
                 }
             )
             self.assertEqual(kubernetes.nodes(), ["mock_node_name"])
             self.assertTrue(
                 kubernetes.kubernetes.client.CoreV1Api().list_node().to_dict.called
             )