Ejemplo n.º 1
0
 def test_k8s_install_kubectl_create_installation_dir(self, logger_mock, mock_url_retrieve):
     mock_url_retrieve.side_effect = lambda _, install_location: open(install_location, 'a').close()
     try:
         temp_dir = tempfile.mkdtemp()  # tempfile.TemporaryDirectory() is no available on 2.7
         test_location = os.path.join(temp_dir, 'foo', 'kubectl')
         k8s_install_kubectl(mock.MagicMock(), client_version='1.2.3', install_location=test_location)
         self.assertTrue(os.path.exists(test_location))
     finally:
         shutil.rmtree(temp_dir)
Ejemplo n.º 2
0
 def test_k8s_install_kubectl_emit_warnings(self, logger_mock, mock_url_retrieve):
     mock_url_retrieve.side_effect = lambda _, install_location: open(install_location, 'a').close()
     try:
         temp_dir = tempfile.mkdtemp()  # tempfile.TemporaryDirectory() is no available on 2.7
         test_location = os.path.join(temp_dir, 'kubectl')
         k8s_install_kubectl(mock.MagicMock(), client_version='1.2.3', install_location=test_location)
         self.assertEqual(mock_url_retrieve.call_count, 1)
         # 2 warnings, 1st for download result; 2nd for updating PATH
         self.assertEqual(logger_mock.warning.call_count, 2)  # 2 warnings, one for download result
     finally:
         shutil.rmtree(temp_dir)
Ejemplo n.º 3
0
 def test_k8s_install_kubectl_with_custom_source_url(self, logger_mock, mock_url_retrieve):
     mock_url_retrieve.side_effect = lambda _, install_location: open(install_location, 'a').close()
     try:
         temp_dir = tempfile.mkdtemp()
         test_location = os.path.join(temp_dir, 'foo', 'kubectl')
         test_ver = '1.2.5'
         test_source_url = 'http://url1'
         k8s_install_kubectl(mock.MagicMock(), client_version=test_ver, install_location=test_location, source_url=test_source_url)
         mock_url_retrieve.assert_called_with(mockUrlretrieveUrlValidator(test_source_url, test_ver), mock.ANY)
     finally:
         shutil.rmtree(temp_dir)