From 94808c80160cc4edd7b5fe1bd2efa6ae7d70a470 Mon Sep 17 00:00:00 2001 From: Xing Zhou Date: Fri, 7 Apr 2023 19:32:32 +0800 Subject: [PATCH] Fix aks install cli test 0407 (#26073) * fix test * fix 2 * fix 3 * fix 4 --------- Co-authored-by: Fuming Zhang --- .../acs/tests/hybrid_2020_09_01/test_custom.py | 10 +++++----- .../command_modules/acs/tests/latest/test_custom.py | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/acs/tests/hybrid_2020_09_01/test_custom.py b/src/azure-cli/azure/cli/command_modules/acs/tests/hybrid_2020_09_01/test_custom.py index 521e2f77396..fd3e7e70ecb 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/tests/hybrid_2020_09_01/test_custom.py +++ b/src/azure-cli/azure/cli/command_modules/acs/tests/hybrid_2020_09_01/test_custom.py @@ -645,10 +645,10 @@ def test_k8s_install_kubelogin_emit_warnings(self, logger_mock, mock_url_retriev try: temp_dir = os.path.realpath(tempfile.mkdtemp()) # tempfile.TemporaryDirectory() is no available on 2.7 test_location = os.path.join(temp_dir, 'kubelogin') - k8s_install_kubelogin(mock.MagicMock(), client_version='0.0.4', install_location=test_location) + k8s_install_kubelogin(mock.MagicMock(), client_version='0.0.4', install_location=test_location, arch="amd64") self.assertEqual(mock_url_retrieve.call_count, 1) - # 3 warnings, 1st for arch, 2nd for download result, 3rd for updating PATH - self.assertEqual(logger_mock.warning.call_count, 3) # 3 warnings, one for download result + # 2 warnings, 1st for download result, 2nd for updating PATH + self.assertEqual(logger_mock.warning.call_count, 2) # 3 warnings, one for download result finally: shutil.rmtree(temp_dir) @@ -659,7 +659,7 @@ def test_k8s_install_kubelogin_create_installation_dir(self, logger_mock, mock_u try: temp_dir = tempfile.mkdtemp() # tempfile.TemporaryDirectory() is no available on 2.7 test_location = os.path.join(temp_dir, 'foo', 'kubelogin') - k8s_install_kubelogin(mock.MagicMock(), client_version='0.0.4', install_location=test_location) + k8s_install_kubelogin(mock.MagicMock(), client_version='0.0.4', install_location=test_location, arch="amd64") self.assertTrue(os.path.exists(test_location)) finally: shutil.rmtree(temp_dir) @@ -688,7 +688,7 @@ def test_k8s_install_kubelogin_with_custom_source_url(self, logger_mock, mock_ur test_location = os.path.join(temp_dir, 'foo', 'kubelogin') test_ver = '1.2.6' test_source_url = 'http://url2' - k8s_install_kubelogin(mock.MagicMock(), client_version=test_ver, install_location=test_location, source_url=test_source_url) + k8s_install_kubelogin(mock.MagicMock(), client_version=test_ver, install_location=test_location, source_url=test_source_url, arch="amd64") mock_url_retrieve.assert_called_with(mockUrlretrieveUrlValidator(test_source_url, test_ver), mock.ANY) finally: shutil.rmtree(temp_dir) diff --git a/src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_custom.py b/src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_custom.py index 872d6fedb7c..00a3518bdf8 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_custom.py +++ b/src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_custom.py @@ -629,10 +629,10 @@ def test_k8s_install_kubelogin_emit_warnings(self, logger_mock, mock_url_retriev try: temp_dir = os.path.realpath(tempfile.mkdtemp()) # tempfile.TemporaryDirectory() is no available on 2.7 test_location = os.path.join(temp_dir, 'kubelogin') - k8s_install_kubelogin(mock.MagicMock(), client_version='0.0.4', install_location=test_location) + k8s_install_kubelogin(mock.MagicMock(), client_version='0.0.4', install_location=test_location, arch="amd64") self.assertEqual(mock_url_retrieve.call_count, 1) - # 3 warnings, 1st for arch, 2nd for download result, 3rd for updating PATH - self.assertEqual(logger_mock.warning.call_count, 3) # 3 warnings, one for download result + # 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) @@ -643,7 +643,7 @@ def test_k8s_install_kubelogin_create_installation_dir(self, logger_mock, mock_u try: temp_dir = tempfile.mkdtemp() # tempfile.TemporaryDirectory() is no available on 2.7 test_location = os.path.join(temp_dir, 'foo', 'kubelogin') - k8s_install_kubelogin(mock.MagicMock(), client_version='0.0.4', install_location=test_location) + k8s_install_kubelogin(mock.MagicMock(), client_version='0.0.4', install_location=test_location, arch="amd64") self.assertTrue(os.path.exists(test_location)) finally: shutil.rmtree(temp_dir) @@ -672,7 +672,7 @@ def test_k8s_install_kubelogin_with_custom_source_url(self, logger_mock, mock_ur test_location = os.path.join(temp_dir, 'foo', 'kubelogin') test_ver = '1.2.6' test_source_url = 'http://url2' - k8s_install_kubelogin(mock.MagicMock(), client_version=test_ver, install_location=test_location, source_url=test_source_url) + k8s_install_kubelogin(mock.MagicMock(), client_version=test_ver, install_location=test_location, source_url=test_source_url, arch="amd64") mock_url_retrieve.assert_called_with(MockUrlretrieveUrlValidator(test_source_url, test_ver), mock.ANY) finally: shutil.rmtree(temp_dir)