def test_tarball_extract_bad_path(self, mock_tarfile, mock_path): mock_path.exists.return_value = False path = '/tmp/armada' with self.assertRaises(Exception): source.extract_tarball(path) mock_tarfile.open.assert_not_called() mock_tarfile.extractall.assert_not_called()
def test_tarball_extract(self, mock_tarfile, mock_path, mock_temp): mock_path.exists.return_value = True mock_temp.mkdtemp.return_value = '/tmp/armada' mock_opened_file = mock.Mock() mock_tarfile.open.return_value = mock_opened_file path = '/tmp/mariadb-0.1.0.tgz' source.extract_tarball(path) mock_path.exists.assert_called_once() mock_temp.mkdtemp.assert_called_once() mock_tarfile.open.assert_called_once_with(path) mock_opened_file.extractall.assert_called_once_with('/tmp/armada')