コード例 #1
0
ファイル: release_test.py プロジェクト: evansde77/cirrus
    def test_new_release_skip_existing(self, mock_unmerged, mock_unstaged):
        """
        _test_new_release_

        """
        mock_unstaged.return_value = False
        mock_unmerged.return_value = ['1.2.4']
        opts = mock.Mock()
        opts.micro = True
        opts.major = False
        opts.minor = False
        opts.nightly = False
        opts.bump = None
        opts.skip_existing = True

        # should create a new minor release, editing
        # the cirrus config in the test dir
        new_release(opts)

        # verify new version
        new_conf = Configuration(self.config)
        new_conf.load()
        self.assertEqual(new_conf.package_version(), '1.2.5')

        self.failUnless(self.mock_pull.called)
        self.assertEqual(self.mock_pull.call_args[0][1], 'develop')
        self.failUnless(self.mock_branch.called)
        self.assertEqual(self.mock_branch.call_args[0][1], 'release/1.2.5')
        self.failUnless(self.mock_commit.called)
        self.assertEqual(self.mock_commit.call_args[0][2], False)
        self.assertEqual(self.mock_commit.call_args[0][3], 'cirrus.conf')
コード例 #2
0
    def test_new_nightly_release(self, mock_dt, mock_unstaged):
        """
        _test_new_release_

        """
        mock_ts = mock.Mock()
        mock_ts.strftime = mock.Mock(return_value="TIMESTAMP")
        mock_now = mock.Mock(return_value=mock_ts)
        mock_dt.datetime = mock.Mock()
        mock_dt.datetime.now = mock_now
        mock_unstaged.return_value = False
        opts = mock.Mock()
        opts.micro = False
        opts.major = False
        opts.minor = False
        opts.nightly = True
        opts.bump = None

        # should create a new minor release, editing
        # the cirrus config in the test dir
        new_release(opts)

        # verify new version
        new_conf = Configuration(self.config)
        new_conf.load()
        self.assertEqual(new_conf.package_version(), '1.2.3-nightly-TIMESTAMP')

        self.failUnless(self.mock_pull.called)
        self.assertEqual(self.mock_pull.call_args[0][1], 'develop')
        self.failUnless(self.mock_branch.called)
        self.assertEqual(self.mock_branch.call_args[0][1],
                         'release/1.2.3-nightly-TIMESTAMP')
        self.failUnless(self.mock_commit.called)
        self.assertEqual(self.mock_commit.call_args[0][2], False)
        self.assertEqual(self.mock_commit.call_args[0][3], 'cirrus.conf')
コード例 #3
0
ファイル: release_test.py プロジェクト: evansde77/cirrus
    def test_new_nightly_release(self, mock_dt, mock_unstaged):
        """
        _test_new_release_

        """
        mock_ts = mock.Mock()
        mock_ts.strftime = mock.Mock(return_value="TIMESTAMP")
        mock_now = mock.Mock(return_value=mock_ts)
        mock_dt.datetime=mock.Mock()
        mock_dt.datetime.now = mock_now
        mock_unstaged.return_value = False
        opts = mock.Mock()
        opts.micro = False
        opts.major = False
        opts.minor = False
        opts.nightly = True
        opts.bump = None
        opts.skip_existing = False

        # should create a new minor release, editing
        # the cirrus config in the test dir
        new_release(opts)

        # verify new version
        new_conf = Configuration(self.config)
        new_conf.load()
        self.assertEqual(new_conf.package_version(), '1.2.3-nightly-TIMESTAMP')

        self.failUnless(self.mock_pull.called)
        self.assertEqual(self.mock_pull.call_args[0][1], 'develop')
        self.failUnless(self.mock_branch.called)
        self.assertEqual(self.mock_branch.call_args[0][1], 'release/1.2.3-nightly-TIMESTAMP')
        self.failUnless(self.mock_commit.called)
        self.assertEqual(self.mock_commit.call_args[0][2], False)
        self.assertEqual(self.mock_commit.call_args[0][3], 'cirrus.conf')
コード例 #4
0
ファイル: release_test.py プロジェクト: rajeshv23/cirrus
    def test_new_release_skip_existing(self, mock_unmerged, mock_unstaged):
        """
        _test_new_release_

        """
        mock_unstaged.return_value = False
        mock_unmerged.return_value = ['1.2.4']
        opts = mock.Mock()
        opts.micro = True
        opts.major = False
        opts.minor = False
        opts.nightly = False
        opts.bump = None
        opts.skip_existing = True

        # should create a new minor release, editing
        # the cirrus config in the test dir
        new_release(opts)

        # verify new version
        new_conf = Configuration(self.config)
        new_conf.load()
        self.assertEqual(new_conf.package_version(), '1.2.5')

        self.failUnless(self.mock_pull.called)
        self.assertEqual(self.mock_pull.call_args[0][1], 'develop')
        self.failUnless(self.mock_branch.called)
        self.assertEqual(self.mock_branch.call_args[0][1], 'release/1.2.5')
        self.failUnless(self.mock_commit.called)
        self.assertEqual(self.mock_commit.call_args[0][2], False)
        self.assertEqual(self.mock_commit.call_args[0][3], 'cirrus.conf')
コード例 #5
0
    def test_new_release_bump(self, mock_bump, mock_unstaged):
        """
        _test_new_release_

        """
        mock_unstaged.return_value = False
        opts = mock.Mock()
        opts.micro = True
        opts.major = False
        opts.minor = False
        opts.nightly = False
        opts.bump = [['womp', '1.2.3'], ['wibble', '3.4.5']]

        # should create a new minor release, editing
        # the cirrus config in the test dir
        new_release(opts)

        # verify new version
        new_conf = Configuration(self.config)
        new_conf.load()
        self.assertEqual(new_conf.package_version(), '1.2.4')

        self.failUnless(self.mock_pull.called)
        self.assertEqual(self.mock_pull.call_args[0][1], 'develop')
        self.failUnless(self.mock_branch.called)
        self.assertEqual(self.mock_branch.call_args[0][1], 'release/1.2.4')
        self.failUnless(self.mock_commit.called)
        self.assertEqual(self.mock_commit.call_args[0][2], False)
        self.assertEqual(self.mock_commit.call_args[0][3], 'cirrus.conf')

        self.assertEqual(mock_bump.call_count, 2)
コード例 #6
0
ファイル: harnesses.py プロジェクト: evansde77/cirrus
class CirrusConfigurationHarness(object):
    """
    CirrusConfigurationHarness

    Test harness that generates a mock for load_configuration in the
    module that is being mocked.

    TODO: better location for this, plus maybe combine with
       generating the cirrus config file
    """
    def __init__(self, module_symbol, config_file, gitconf_content=None, **settings):
        self.module_symbol = module_symbol
        self.config_file = config_file
        self.gitconf_str = gitconf_content
        if self.gitconf_str is None:
            self.gitconf_str = "cirrus.credential-plugin=default"

    def setUp(self):
        self.patch_environ = mock.patch.dict(os.environ, {'HOME': 'womp'})
        self.patch_environ.start()
        self.mock_config = mock.patch(self.module_symbol)
        self.load_mock = self.mock_config.start()
        self.patch_gitconfig = mock.patch('cirrus.gitconfig.shell_command')
        self.mock_gitconfig = self.patch_gitconfig.start()
        self.mock_gitconfig.return_value = self.gitconf_str
        self.config = Configuration(self.config_file)
        self.config.load()
        self.load_mock.return_value = self.config

    def tearDown(self):
        self.patch_environ.stop()
        self.mock_config.stop()
        self.patch_gitconfig.stop()
コード例 #7
0
 def setUp(self):
     self.patch_environ = mock.patch.dict(os.environ, {'HOME': 'womp'})
     self.patch_environ.start()
     self.mock_config = mock.patch(self.module_symbol)
     self.load_mock = self.mock_config.start()
     self.patch_gitconfig = mock.patch('cirrus.gitconfig.shell_command')
     self.mock_gitconfig = self.patch_gitconfig.start()
     self.mock_gitconfig.return_value = self.gitconf_str
     self.config = Configuration(self.config_file)
     self.config.load()
     self.load_mock.return_value = self.config
コード例 #8
0
ファイル: harnesses.py プロジェクト: evansde77/cirrus
 def setUp(self):
     self.patch_environ = mock.patch.dict(os.environ, {'HOME': 'womp'})
     self.patch_environ.start()
     self.mock_config = mock.patch(self.module_symbol)
     self.load_mock = self.mock_config.start()
     self.patch_gitconfig = mock.patch('cirrus.gitconfig.shell_command')
     self.mock_gitconfig = self.patch_gitconfig.start()
     self.mock_gitconfig.return_value = self.gitconf_str
     self.config = Configuration(self.config_file)
     self.config.load()
     self.load_mock.return_value = self.config
コード例 #9
0
class CirrusConfigurationHarness(object):
    """
    CirrusConfigurationHarness

    Test harness that generates a mock for load_configuration in the
    module that is being mocked.

    TODO: better location for this, plus maybe combine with
       generating the cirrus config file
    """
    def __init__(self,
                 module_symbol,
                 config_file,
                 gitconf_content=None,
                 **settings):
        self.module_symbol = module_symbol
        self.config_file = config_file
        self.gitconf_str = gitconf_content
        if self.gitconf_str is None:
            self.gitconf_str = "cirrus.credential-plugin=default"

    def setUp(self):
        self.patch_environ = mock.patch.dict(os.environ, {'HOME': 'womp'})
        self.patch_environ.start()
        self.mock_config = mock.patch(self.module_symbol)
        self.load_mock = self.mock_config.start()
        self.patch_gitconfig = mock.patch('cirrus.gitconfig.shell_command')
        self.mock_gitconfig = self.patch_gitconfig.start()
        self.mock_gitconfig.return_value = self.gitconf_str
        self.config = Configuration(self.config_file)
        self.config.load()
        self.load_mock.return_value = self.config

    def tearDown(self):
        self.patch_environ.stop()
        self.mock_config.stop()
        self.patch_gitconfig.stop()
コード例 #10
0
ファイル: docker_test.py プロジェクト: rajeshv23/cirrus
    def setUp(self):
        self.patch_check_output = mock.patch(
            'cirrus.docker.subprocess.check_output')
        self.patch_popen = mock.patch('cirrus.docker.subprocess.Popen')
        self.version_patcher = mock.patch('cirrus.docker.get_docker_version')
        self.mock_check_output = self.patch_check_output.start()
        self.mock_get_docker_version = self.version_patcher.start()
        self.mock_get_docker_version.return_value = 'Docker version 1.12.0, build 8eab29e'
        self.mock_check_output.return_value = 'SUBPROCESS OUT'
        self.mock_popen = self.patch_popen.start()
        self.mock_popen.return_value = self.mock_popen
        self.mock_popen.communicate = mock.Mock()
        self.mock_popen.communicate.return_value = ('STDOUT', 'STDERR')
        self.mock_popen.wait = mock.Mock(return_value=0)

        self.opts = mock.Mock()
        self.opts.login = False
        self.opts.directory = None
        self.opts.dockerstache_template = None
        self.opts.dockerstache_context = None
        self.opts.dockerstache_defaults = None
        self.opts.docker_repo = None
        self.opts.no_cache = False
        self.opts.pull = False
        self.opts.build_arg = {}
        self.opts.local_test = False

        self.config = Configuration(None)
        self.config['package'] = {'version': '1.2.3', 'name': 'unittesting'}
        self.config['docker'] = {
            'directory': 'vm/docker_image',
            'repo': 'unittesting'
        }
        self.config.credentials = mock.Mock()
        self.config.credentials.credential_map = mock.Mock()
        self.config.credentials.credential_map.return_value = {
            'github_credentials': {
                'github_user': '******',
                'github_token': 'steves gh token'
            },
            'pypi_credentials': {
                'username': '******',
                'token': 'steves pypi token'
            }
        }