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')
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')
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')
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)
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')
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()
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()