# Path: armada/exceptions/source_exceptions.py
# class SourceException(base_exception.ArmadaBaseException):
# class GitException(SourceException):
# class GitAuthException(SourceException):
# class GitProxyException(SourceException):
# class GitSSHException(SourceException):
# class SourceCleanupException(SourceException):
# class TarballDownloadException(SourceException):
# class TarballExtractException(SourceException):
# class InvalidPathException(SourceException):
# class ChartSourceException(SourceException):
#     def __init__(self, location):
#     def __init__(self, repo_url, ssh_key_path):
#     def __init__(self, location):
#     def __init__(self, ssh_key_path):
#     def __init__(self, target_dir):
#     def __init__(self, tarball_url):
#     def __init__(self, tarball_dir):
#     def __init__(self, path):
#     def __init__(self, chart_name, source_type):
# 
# Path: armada/tests/unit/base.py
# CONF = cfg.CONF
# class ArmadaTestCase(testtools.TestCase):
#     def setUp(self):
#     def override_config(self, name, override, group=None):
#     def assertEmpty(self, collection):
#     def patch(self, target, autospec=True, **kwargs):
#     def patchobject(self, target, attribute, new=mock.DEFAULT, autospec=True):
# 
# Path: armada/tests/test_utils.py
# def rand_uuid_hex():
# def rand_name(name='', prefix='armada'):
# def rand_bool():
# def rand_int(min, max):
# def rand_password(length=15):
# def attr(**kwargs):
#     def decorator(f):
# 
# Path: armada/utils/source.py
# CONF = cfg.CONF
# LOG = logging.getLogger(__name__)
# def git_clone(repo_url, ref='master', proxy_server=None, auth_method=None):
# def get_tarball(tarball_url, verify=False):
# def download_tarball(tarball_url, verify=False):
# def extract_tarball(tarball_path):
# def source_cleanup(git_path):


import os
import socket
import shutil
import fixtures
import mock
import testtools
from armada.exceptions import source_exceptions
from armada.tests.unit import base
from armada.tests import test_utils
from armada.utils import source
            actual_call)

    @test_utils.attr(type=['negative'])
    @mock.patch.object(source, 'LOG')
    @mock.patch('armada.utils.source.shutil')
    @mock.patch('armada.utils.source.os.path')
    def test_source_cleanup_missing_git_path(self, mock_path, mock_shutil,
                                             mock_log):
        # Verify that passing in a missing path does nothing but log a warning.
        mock_path.exists.return_value = False
        path = 'armada'
        source.source_cleanup(path)

        mock_shutil.rmtree.assert_not_called()
        self.assertTrue(mock_log.warning.called)
        actual_call = mock_log.warning.mock_calls[0][1]
        self.assertEqual(
            ('Could not delete the path %s. Is it a git repository?', path),
            actual_call)

    @testtools.skipUnless(
        is_connected(), 'git clone requires network connectivity.')
    @test_utils.attr(type=['negative'])
    @mock.patch.object(source, 'os')
    def test_git_clone_ssh_auth_method_fails_auth(self, mock_os):
        mock_os.path.exists.return_value = True
        fake_user = test_utils.rand_name('fake_user')
        url = ('ssh://%s@review.gerrithub.io:29418/att-comdev/armada'
               % fake_user)
        self.assertRaises(

# Path: armada/exceptions/source_exceptions.py
# class SourceException(base_exception.ArmadaBaseException):
# class GitException(SourceException):
# class GitAuthException(SourceException):
# class GitProxyException(SourceException):
# class GitSSHException(SourceException):
# class SourceCleanupException(SourceException):
# class TarballDownloadException(SourceException):
# class TarballExtractException(SourceException):
# class InvalidPathException(SourceException):
# class ChartSourceException(SourceException):
#     def __init__(self, location):
#     def __init__(self, repo_url, ssh_key_path):
#     def __init__(self, location):
#     def __init__(self, ssh_key_path):
#     def __init__(self, target_dir):
#     def __init__(self, tarball_url):
#     def __init__(self, tarball_dir):
#     def __init__(self, path):
#     def __init__(self, chart_name, source_type):
# 
# Path: armada/tests/unit/base.py
# CONF = cfg.CONF
# class ArmadaTestCase(testtools.TestCase):
#     def setUp(self):
#     def override_config(self, name, override, group=None):
#     def assertEmpty(self, collection):
#     def patch(self, target, autospec=True, **kwargs):
#     def patchobject(self, target, attribute, new=mock.DEFAULT, autospec=True):
# 
# Path: armada/tests/test_utils.py
# def rand_uuid_hex():
# def rand_name(name='', prefix='armada'):
# def rand_bool():
# def rand_int(min, max):
# def rand_password(length=15):
# def attr(**kwargs):
#     def decorator(f):
# 
# Path: armada/utils/source.py
# CONF = cfg.CONF
# LOG = logging.getLogger(__name__)
# def git_clone(repo_url, ref='master', proxy_server=None, auth_method=None):
# def get_tarball(tarball_url, verify=False):
# def download_tarball(tarball_url, verify=False):
# def extract_tarball(tarball_path):
# def source_cleanup(git_path):


# Path: armada/tests/unit/utils/test_source.py
import os
import socket
import shutil
import fixtures
import mock
import testtools
from armada.exceptions import source_exceptions
from armada.tests.unit import base
from armada.tests import test_utils
from armada.utils import source

            actual_call)

    @test_utils.attr(type=['negative'])
    @mock.patch.object(source, 'LOG')
    @mock.patch('armada.utils.source.shutil')
    @mock.patch('armada.utils.source.os.path')
    def test_source_cleanup_missing_git_path(self, mock_path, mock_shutil,
                                             mock_log):
        # Verify that passing in a missing path does nothing but log a warning.
        mock_path.exists.return_value = False
        path = 'armada'
        source.source_cleanup(path)

        mock_shutil.rmtree.assert_not_called()
        self.assertTrue(mock_log.warning.called)
        actual_call = mock_log.warning.mock_calls[0][1]
        self.assertEqual(
            ('Could not delete the path %s. Is it a git repository?', path),
            actual_call)

    @testtools.skipUnless(
        is_connected(), 'git clone requires network connectivity.')
    @test_utils.attr(type=['negative'])
    @mock.patch.object(source, 'os')
    def test_git_clone_ssh_auth_method_fails_auth(self, mock_os):
        mock_os.path.exists.return_value = True
        fake_user = test_utils.rand_name('fake_user')
        url = ('ssh://%s@review.gerrithub.io:29418/att-comdev/armada'
               % fake_user)
        self.assertRaises(

            source_exceptions.GitAuthException, source.git_clone, url,