Esempio n. 1
0
def test_mac_plugin_extract_invalid_zip(mocker):
    mocker.patch("aws_gate.bootstrap.zipfile.is_zipfile", return_value=False)

    plugin = MacPlugin()

    with pytest.raises(ValueError):
        plugin.extract()
Esempio n. 2
0
    def test_mac_plugin_extract_valid(self):
        plugin = MacPlugin()
        with patch('aws_gate.bootstrap.zipfile.is_zipfile', return_value=True), \
             patch('aws_gate.bootstrap.os.path.split'), \
             patch('aws_gate.bootstrap.zipfile.ZipFile', return_value=MagicMock()) as zip_mock:
            plugin.extract()

            self.assertTrue(zip_mock.called)
Esempio n. 3
0
def test_mac_plugin_extract_valid(mocker):
    mocker.patch("aws_gate.bootstrap.zipfile.is_zipfile", return_value=True)
    mocker.patch("aws_gate.bootstrap.os.path.split")
    zip_mock = mocker.patch("aws_gate.bootstrap.zipfile.ZipFile")

    plugin = MacPlugin()
    plugin.extract()

    assert zip_mock.called
Esempio n. 4
0
    def test_mac_plugin_install_non_existent_bin_dir(self):
        plugin = MacPlugin()
        with patch('aws_gate.bootstrap.os') as os_mock, \
                patch('builtins.open', mock_open(read_data='data')), \
                patch('aws_gate.bootstrap.os.path.exists', return_value=False), \
                patch('aws_gate.bootstrap.shutil') as shutil_mock, \
                patch('aws_gate.bootstrap._check_plugin_version', return_value='1.1.23.0'):
            plugin.install()

            self.assertTrue(os_mock.makedirs.called)
            self.assertEqual(os_mock.makedirs.call_args,
                             call(DEFAULT_GATE_BIN_PATH))
            self.assertTrue(shutil_mock.copyfileobj.called)
            self.assertTrue(os_mock.chmod.called)
Esempio n. 5
0
def test_mac_plugin_install_non_existent_bin_dir(mocker):
    mocker.patch("builtins.open", mocker.mock_open(read_data="data"))
    os_mock = mocker.patch("aws_gate.bootstrap.os")
    mocker.patch("aws_gate.bootstrap.os.path.exists", return_value=False)
    mocker.patch("aws_gate.bootstrap._check_plugin_version",
                 return_value="1.1.23.0")
    shutil_mock = mocker.patch("aws_gate.bootstrap.shutil")

    plugin = MacPlugin()
    plugin.install()

    assert os_mock.makedirs.called
    assert os_mock.makedirs.call_args == mocker.call(DEFAULT_GATE_BIN_PATH)
    assert shutil_mock.copyfileobj.called
    assert os_mock.chmod.called
Esempio n. 6
0
 def test_mac_plugin_extract_invalid_zip(self):
     plugin = MacPlugin()
     with patch('aws_gate.bootstrap.zipfile.is_zipfile',
                return_value=False):
         with self.assertRaises(ValueError):
             plugin.extract()