Example #1
0
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)
Example #2
0
    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
Example #3
0
    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)
Example #4
0
    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)
Example #5
0
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
Example #6
0
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
Example #7
0
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)
Example #8
0
    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)
Example #9
0
    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)
Example #10
0
 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
Example #11
0
def test_release_dryrun(workspace, mocker):
    config = Config({
        'file': 'fake.py',
        'files': [str(workspace.readme)],
        'vcs': 'fake',
        'dryrun': True,
        'push': True,
    })
    releaser = Releaser(config)
    execute = mocker.patch('bumpr.releaser.execute')
    vcs = mocker.patch.object(releaser, 'vcs')
    releaser.release()
    assert not execute.called
    assert not vcs.commit.called
    assert not vcs.tag.called
    assert not vcs.push.called

    for file in workspace.module, workspace.readme:
        with file.open() as f:
            content = f.read()
            assert '1.2.3.dev' in content
            assert '1.2.4' not in content
Example #12
0
    def test_release_dryrun(self, workspace):
        config = Config({
            'file': 'fake.py',
            'files': [workspace.readme_filename],
            'vcs': 'fake',
            'dryrun': True,
            'push': True,
        })
        releaser = Releaser(config)
        with patch('bumpr.releaser.execute') as execute:
            with patch.object(releaser, 'vcs') as vcs:
                releaser.release()
                assert not execute.called
                assert not vcs.commit.called
                assert not vcs.tag.called
                assert not vcs.push.called

        for filename in workspace.module_filename, workspace.readme_filename:
            with open(filename) as f:
                content = f.read()
                assert '1.2.3.dev' in content
                assert '1.2.4' not in content
Example #13
0
def test_release_dryrun(workspace, mocker):
    config = Config({
        "file": "fake.py",
        "files": [str(workspace.readme)],
        "vcs": "fake",
        "dryrun": True,
        "push": True,
    })
    releaser = Releaser(config)
    execute = mocker.patch("bumpr.releaser.execute")
    vcs = mocker.patch.object(releaser, "vcs")
    releaser.release()
    assert not execute.called
    assert not vcs.commit.called
    assert not vcs.tag.called
    assert not vcs.push.called

    for file in workspace.module, workspace.readme:
        with file.open() as f:
            content = f.read()
            assert "1.2.3.dev" in content
            assert "1.2.4" not in content
Example #14
0
def test_release(workspace, mocker):
    config = Config({
        'file': 'fake.py',
        'files': [str(workspace.readme)],
        'vcs': 'fake',
        'push': True,
    })
    releaser = Releaser(config)
    clean = mocker.patch.object(releaser, 'clean')
    test = mocker.patch.object(releaser, 'test')
    bump = mocker.patch.object(releaser, 'bump')
    publish = mocker.patch.object(releaser, 'publish')
    prepare = mocker.patch.object(releaser, 'prepare')
    push = mocker.patch.object(releaser, 'push')

    releaser.release()

    assert clean.called
    assert test.called
    assert bump.called
    assert publish.called
    assert prepare.called
    assert push.called
Example #15
0
def test_release(workspace, mocker):
    config = Config({
        "file": "fake.py",
        "files": [str(workspace.readme)],
        "vcs": "fake",
        "push": True,
    })
    releaser = Releaser(config)
    clean = mocker.patch.object(releaser, "clean")
    test = mocker.patch.object(releaser, "test")
    bump = mocker.patch.object(releaser, "bump")
    publish = mocker.patch.object(releaser, "publish")
    prepare = mocker.patch.object(releaser, "prepare")
    push = mocker.patch.object(releaser, "push")

    releaser.release()

    assert clean.called
    assert test.called
    assert bump.called
    assert publish.called
    assert prepare.called
    assert push.called