def test_tag_custom_pattern(self, workspace): config = Config({'file': 'fake.py', 'vcs': 'fake', 'tag_format': 'v{version}'}) releaser = Releaser(config) with patch.object(releaser, 'vcs') as vcs: releaser.tag() vcs.tag.assert_called_with('v{0}'.format(releaser.version))
def test_commit(self, workspace): config = Config({'file': 'fake.py', 'vcs': 'fake'}) releaser = Releaser(config) with patch.object(releaser, 'vcs') as vcs: releaser.commit('message') vcs.commit.assert_called_with('message')
def test_commit_no_commit(self, workspace): config = Config({'file': 'fake.py', 'vcs': 'fake', 'commit': False}) releaser = Releaser(config) with patch.object(releaser, 'vcs') as vcs: releaser.commit('message') assert not vcs.commit.called
def test_prepare(workspace, mocker): config = Config({ 'file': 'fake.py', 'files': [str(workspace.readme)], 'prepare': { 'part': Version.PATCH, 'suffix': 'dev', } }) releaser = Releaser(config) hook = mocker.MagicMock() mocker.patch.object(releaser, 'hooks', [hook]) commit = mocker.patch.object(releaser, 'commit') tag = mocker.patch.object(releaser, 'tag') releaser.prepare() assert not commit.called assert not tag.called assert hook.prepare.called for file in workspace.module, workspace.readme: with file.open() as f: content = f.read() assert '1.2.4.dev' in content assert '1.2.3' not in content
def test_push_disabled_by_default(self, workspace): config = Config({'file': 'fake.py', 'vcs': 'fake'}) releaser = Releaser(config) with patch.object(releaser, 'vcs') as vcs: releaser.push() assert not vcs.push.called
def test_push_no_commit(self, workspace): config = Config({'file': 'fake.py', 'vcs': 'fake', 'push': True, 'commit': False}) releaser = Releaser(config) with patch.object(releaser, 'vcs') as vcs: releaser.push() assert not vcs.push.called
def test_prepare(workspace, mocker): config = Config({ "file": "fake.py", "files": [str(workspace.readme)], "prepare": { "part": Version.PATCH, "suffix": "dev", }, }) releaser = Releaser(config) hook = mocker.MagicMock() mocker.patch.object(releaser, "hooks", [hook]) commit = mocker.patch.object(releaser, "commit") tag = mocker.patch.object(releaser, "tag") releaser.prepare() assert not commit.called assert not tag.called assert hook.prepare.called for file in workspace.module, workspace.readme: with file.open() as f: content = f.read() assert "1.2.4.dev" in content assert "1.2.3" not in content
def test_tag_no_tag(self, workspace): config = Config({'file': 'fake.py', 'vcs': 'fake', 'tag': False}) releaser = Releaser(config) with patch.object(releaser, 'vcs') as vcs: releaser.tag() assert not vcs.tag.called
def main(): import sys from bumpr import log log.init() from bumpr.config import Config, ValidationError from bumpr.releaser import Releaser from bumpr.helpers import BumprError from logging import DEBUG, INFO, getLogger config = Config.parse_args() getLogger().setLevel(DEBUG if config.verbose else INFO) logger = getLogger(__name__) try: config.validate() except ValidationError as e: msg = 'Invalid configuration: {0}'.format(e) logger.error(msg) sys.exit(1) try: releaser = Releaser(config) releaser.release() except BumprError as error: logger.error(str(error)) sys.exit(1)
def test_tag(self, workspace): config = Config({'file': 'fake.py', 'vcs': 'fake'}) releaser = Releaser(config) with patch.object(releaser, 'vcs') as vcs: releaser.tag() vcs.tag.assert_called_with(str(releaser.version))
def test_push(workspace, mocker): config = Config({"file": "fake.py", "vcs": "fake", "push": True}) releaser = Releaser(config) vcs = mocker.patch.object(releaser, "vcs") releaser.push() assert vcs.push.called
def test_push_disabled_by_default(workspace, mocker): config = Config({"file": "fake.py", "vcs": "fake"}) releaser = Releaser(config) vcs = mocker.patch.object(releaser, "vcs") releaser.push() assert not vcs.push.called
def test_tag_no_tag(workspace, mocker): config = Config({"file": "fake.py", "vcs": "fake", "tag": False}) releaser = Releaser(config) vcs = mocker.patch.object(releaser, "vcs") releaser.tag() assert not vcs.tag.called
def test_tag(workspace, mocker): config = Config({"file": "fake.py", "vcs": "fake"}) releaser = Releaser(config) vcs = mocker.patch.object(releaser, "vcs") releaser.tag() vcs.tag.assert_called_with(str(releaser.version))
def test_commit_no_commit(workspace, mocker): config = Config({"file": "fake.py", "vcs": "fake", "commit": False}) releaser = Releaser(config) vcs = mocker.patch.object(releaser, "vcs") releaser.commit("message") assert not vcs.commit.called
def test_commit(workspace, mocker): config = Config({"file": "fake.py", "vcs": "fake"}) releaser = Releaser(config) vcs = mocker.patch.object(releaser, "vcs") releaser.commit("message") vcs.commit.assert_called_with("message")
def test_commit(workspace, mocker): config = Config({'file': 'fake.py', 'vcs': 'fake'}) releaser = Releaser(config) vcs = mocker.patch.object(releaser, 'vcs') releaser.commit('message') vcs.commit.assert_called_with('message')
def test_tag(workspace, mocker): config = Config({'file': 'fake.py', 'vcs': 'fake'}) releaser = Releaser(config) vcs = mocker.patch.object(releaser, 'vcs') releaser.tag() vcs.tag.assert_called_with(str(releaser.version))
def test_commit_no_commit(workspace, mocker): config = Config({'file': 'fake.py', 'vcs': 'fake', 'commit': False}) releaser = Releaser(config) vcs = mocker.patch.object(releaser, 'vcs') releaser.commit('message') assert not vcs.commit.called
def test_tag(self): config = Config({'file': 'fake.py', 'vcs': 'fake'}) with workspace('fake') as wksp: releaser = Releaser(config) with patch.object(releaser, 'vcs') as vcs: releaser.tag() vcs.tag.assert_called_with(str(releaser.version))
def test_tag_no_tag(workspace, mocker): config = Config({'file': 'fake.py', 'vcs': 'fake', 'tag': False}) releaser = Releaser(config) vcs = mocker.patch.object(releaser, 'vcs') releaser.tag() assert not vcs.tag.called
def test_tag_custom_pattern(workspace, mocker): config = Config({'file': 'fake.py', 'vcs': 'fake', 'tag_format': 'v{version}'}) releaser = Releaser(config) vcs = mocker.patch.object(releaser, 'vcs') releaser.tag() vcs.tag.assert_called_with('v{0}'.format(releaser.version))
def test_commit(self): config = Config({'file': 'fake.py', 'vcs': 'fake'}) with workspace('fake') as wksp: releaser = Releaser(config) with patch.object(releaser, 'vcs') as vcs: releaser.commit('message') vcs.commit.assert_called_with('message')
def test_push_disabled_by_default(workspace, mocker): config = Config({'file': 'fake.py', 'vcs': 'fake'}) releaser = Releaser(config) vcs = mocker.patch.object(releaser, 'vcs') releaser.push() assert not vcs.push.called
def test_push_no_commit(workspace, mocker): config = Config({'file': 'fake.py', 'vcs': 'fake', 'push': True, 'commit': False}) releaser = Releaser(config) vcs = mocker.patch.object(releaser, 'vcs') releaser.push() assert not vcs.push.called
def test_test(self, workspace): config = Config({ 'file': 'fake.py', 'tests': 'test command', }) releaser = Releaser(config) with patch('bumpr.releaser.execute') as execute: releaser.test() execute.assert_called_with('test command', replacements=ANY, dryrun=ANY, verbose=ANY)
def test_skip_test(self, workspace): config = Config({ 'file': 'fake.py', 'tests': 'test command', 'skip_tests': True, }) releaser = Releaser(config) with patch('bumpr.releaser.execute') as execute: releaser.test() assert not execute.called
def test_test(workspace, mocker): config = Config({ 'file': 'fake.py', 'tests': 'test command', }) releaser = Releaser(config) execute = mocker.patch('bumpr.releaser.execute') releaser.test() execute.assert_called_with('test command', replacements=mocker.ANY, dryrun=mocker.ANY, verbose=mocker.ANY)
def test_clean(self): config = Config({ 'file': 'fake.py', 'clean': 'clean command', }) with workspace('fake'): releaser = Releaser(config) with patch('bumpr.releaser.execute') as execute: releaser.clean() execute.assert_called_with('clean command', replacements=ANY, dryrun=ANY, verbose=ANY)
def test_tag_custom_pattern(workspace, mocker): config = Config({ "file": "fake.py", "vcs": "fake", "tag_format": "v{version}" }) releaser = Releaser(config) vcs = mocker.patch.object(releaser, "vcs") releaser.tag() vcs.tag.assert_called_with("v{0}".format(releaser.version))
def test_skip_test(workspace, mocker): config = Config({ "file": "fake.py", "tests": "test command", "skip_tests": True, }) releaser = Releaser(config) execute = mocker.patch("bumpr.releaser.execute") releaser.test() assert not execute.called
def test_skip_test(workspace, mocker): config = Config({ 'file': 'fake.py', 'tests': 'test command', 'skip_tests': True, }) releaser = Releaser(config) execute = mocker.patch('bumpr.releaser.execute') releaser.test() assert not execute.called
def test_test(workspace, mocker): config = Config({ "file": "fake.py", "tests": "test command", }) releaser = Releaser(config) execute = mocker.patch("bumpr.releaser.execute") releaser.test() execute.assert_called_with("test command", replacements=mocker.ANY, dryrun=mocker.ANY, verbose=mocker.ANY)
def test_release_wihtout_vcs_or_commands(self, workspace): config = Config({'file': 'fake.py', 'files': [workspace.readme_filename]}) releaser = Releaser(config) with patch('bumpr.releaser.execute') as execute: with patch.object(releaser, 'commit') as commit: releaser.release() assert not execute.called assert not commit.called for filename in workspace.module_filename, workspace.readme_filename: with open(filename) as f: content = f.read() assert '1.2.3' in content assert '1.2.3.dev' not in content
def test_bump(self): with workspace('fake', '1.2.3.dev') as wksp: config = Config({'file': 'fake.py', 'files': [wksp.readme]}) releaser = Releaser(config) with patch.object(releaser, 'commit') as commit: with patch.object(releaser, 'tag') as tag: releaser.bump() self.assertFalse(commit.called) self.assertFalse(tag.called) for filename in wksp.module, wksp.readme: with open(filename) as f: content = f.read() self.assertIn('1.2.3', content) self.assertNotIn('1.2.3.dev', content)
def test_release_wihtout_vcs_or_commands(self): with workspace('fake', '1.2.3.dev') as wksp: config = Config({'file': 'fake.py', 'files': [wksp.readme]}) releaser = Releaser(config) with patch('bumpr.releaser.execute') as execute: with patch.object(releaser, 'commit') as commit: releaser.release() self.assertFalse(execute.called) self.assertFalse(commit.called) for filename in wksp.module, wksp.readme: with open(filename) as f: content = f.read() self.assertIn('1.2.3', content) self.assertNotIn('1.2.3.dev', content)
def test_constructor_version_bad_format(workspace): config = Config({ 'file': 'fake.py', }) workspace.write('fake.py', '__badversion__ = "1.2.3"') with pytest.raises(BumprError): Releaser(config)
def test_release_wihtout_vcs_or_commands(workspace, mocker): config = Config({'file': 'fake.py', 'files': [str(workspace.readme)]}) releaser = Releaser(config) execute = mocker.patch('bumpr.releaser.execute') commit = mocker.patch.object(releaser, 'commit') releaser.release() assert not execute.called assert not commit.called for file in workspace.module, workspace.readme: with file.open() as f: content = f.read() assert '1.2.3' in content assert '1.2.3.dev' not in content
def test_release_wihtout_vcs_or_commands(workspace, mocker): config = Config({"file": "fake.py", "files": [str(workspace.readme)]}) releaser = Releaser(config) execute = mocker.patch("bumpr.releaser.execute") commit = mocker.patch.object(releaser, "commit") releaser.release() assert not execute.called assert not commit.called for file in workspace.module, workspace.readme: with file.open() as f: content = f.read() assert "1.2.3" in content assert "1.2.3.dev" not in content
def test_constructor_version_not_found(workspace): config = Config({ 'file': 'fake.py' }) workspace.write('fake.py', '') with pytest.raises(BumprError): Releaser(config)
def test_bump_vcs(self, workspace): config = Config({ 'file': 'fake.py', 'files': [workspace.readme_filename], 'vcs': 'fake', }) releaser = Releaser(config) with patch.object(releaser, 'commit') as commit: with patch.object(releaser, 'tag') as tag: releaser.bump() assert commit.call_count == 1 assert tag.called for filename in workspace.module_filename, workspace.readme_filename: with open(filename) as f: content = f.read() assert '1.2.3' in content assert '1.2.3.dev' not in content
def main(): import sys from bumpr import log log.init() from bumpr.config import Config from bumpr.releaser import Releaser from bumpr.helpers import BumprError from logging import DEBUG, INFO, getLogger config = Config.parse_args() getLogger().setLevel(DEBUG if config.verbose else INFO) try: releaser = Releaser(config) releaser.release() except BumprError as error: getLogger(__name__).error(error.message) sys.exit(1)
def test_bump_vcs(workspace, mocker): config = Config({ 'file': 'fake.py', 'files': [str(workspace.readme)], 'vcs': 'fake', }) releaser = Releaser(config) commit = mocker.patch.object(releaser, 'commit') tag = mocker.patch.object(releaser, 'tag') releaser.bump() assert commit.call_count == 1 assert tag.called for file in workspace.module, workspace.readme: with file.open() as f: content = f.read() assert '1.2.3' in content assert '1.2.3.dev' not in content
def test_release_dryrun(self): with workspace('fake', '1.2.3.dev') as wksp: config = Config({ 'file': 'fake.py', 'files': [wksp.readme], 'vcs': 'fake', 'dryrun': True, }) releaser = Releaser(config) with patch('bumpr.releaser.execute') as execute: with patch.object(releaser, 'vcs') as vcs: releaser.release() self.assertFalse(execute.called) self.assertFalse(vcs.commit.called) self.assertFalse(vcs.tag.called) for filename in wksp.module, wksp.readme: with open(filename) as f: content = f.read() self.assertIn('1.2.3.dev', content) self.assertNotIn('1.2.4', content)
def test_release(self, workspace): config = Config({ 'file': 'fake.py', 'files': [workspace.readme_filename], 'vcs': 'fake', 'push': True, }) releaser = Releaser(config) with patch.object(releaser, 'clean') as clean: with patch.object(releaser, 'test') as test: with patch.object(releaser, 'bump') as bump: with patch.object(releaser, 'publish') as publish: with patch.object(releaser, 'prepare') as prepare: with patch.object(releaser, 'push') as push: releaser.release() assert clean.called assert test.called assert bump.called assert publish.called assert prepare.called assert push.called
def test_bump_vcs_with_annotation(workspace, mocker): config = Config({ 'file': 'fake.py', 'files': [str(workspace.readme)], 'vcs': 'fake', 'tag_annotation': 'version {version}' }) releaser = Releaser(config) commit = mocker.patch.object(releaser, 'commit') tag = mocker.patch.object(releaser.vcs, 'tag') releaser.bump() assert commit.call_count == 1 tag.assert_called_with(str(releaser.version), 'version {0}'.format(releaser.version)) for file in workspace.module, workspace.readme: with file.open() as f: content = f.read() assert '1.2.3' in content assert '1.2.3.dev' not in content