Ejemplo n.º 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)
Ejemplo n.º 2
0
    def test_override_args_keeps_config_values(self):
        bumprrc = '''\
        [bumpr]
        files = README
        [bump]
        message = test
        [prepare]
        part = minor
        '''

        with mock_ini(bumprrc) as mock:
            with patch('bumpr.config.exists', return_value=True):
                config = Config.parse_args(['test.py', '-M', '-v', '-s', 'test-suffix', '-c', 'test.rc'])

        expected = deepcopy(DEFAULTS)
        expected['file'] = 'test.py'
        expected['bump']['part'] = Version.MAJOR
        expected['bump']['suffix'] = 'test-suffix'
        expected['verbose'] = True

        expected['files'] = ['README']
        expected['bump']['message'] = 'test'
        expected['prepare']['part'] = Version.MINOR

        for hook in HOOKS:
            expected[hook.key] = False

        self.assertDictEqual(config, expected)
Ejemplo n.º 3
0
    def test_override_args_keeps_config_values(self):
        bumprrc = '''\
        [bumpr]
        files = README
        [bump]
        message = test
        [prepare]
        part = minor
        '''

        with mock_ini(bumprrc) as mock:
            with patch('bumpr.config.exists', return_value=True):
                config = Config.parse_args([
                    'test.py', '-M', '-v', '-s', 'test-suffix', '-c', 'test.rc'
                ])

        expected = deepcopy(DEFAULTS)
        expected['file'] = 'test.py'
        expected['bump']['part'] = Version.MAJOR
        expected['bump']['suffix'] = 'test-suffix'
        expected['verbose'] = True

        expected['files'] = ['README']
        expected['bump']['message'] = 'test'
        expected['prepare']['part'] = Version.MINOR

        for hook in HOOKS:
            expected[hook.key] = False

        self.assertDictEqual(config, expected)
Ejemplo n.º 4
0
    def test_skip_tests_from_args(self):
        config = Config.parse_args(['-c', 'test.rc', '--skip-tests'])

        expected = deepcopy(DEFAULTS)
        expected['skip_tests'] = True

        for hook in HOOKS:
            expected[hook.key] = False

        assert config == expected
Ejemplo n.º 5
0
    def test_do_override_commit(self):
        config = Config.parse_args(['-c', 'test.rc', '-nc'])

        expected = deepcopy(DEFAULTS)
        expected['commit'] = False

        for hook in HOOKS:
            expected[hook.key] = False

        assert config == expected
Ejemplo n.º 6
0
    def test_do_override_commit(self):
        config = Config.parse_args(["-c", "test.rc", "-nc"])

        expected = deepcopy(DEFAULTS)
        expected["commit"] = False

        for hook in HOOKS:
            expected[hook.key] = False

        assert config == expected
Ejemplo n.º 7
0
    def test_force_push_from_args(self):
        config = Config.parse_args(['-c', 'test.rc', '--push'])

        expected = deepcopy(DEFAULTS)
        expected['push'] = True

        for hook in HOOKS:
            expected[hook.key] = False

        assert config == expected
Ejemplo n.º 8
0
    def test_do_not_override_push_when_not_in_args(self, mocker, mock_ini):
        config = Config.parse_args(['-c', 'test.rc'])

        expected = deepcopy(DEFAULTS)
        expected['push'] = True

        for hook in HOOKS:
            expected[hook.key] = False

        assert config == expected
Ejemplo n.º 9
0
    def test_force_push_from_args(self):
        config = Config.parse_args(['-c', 'test.rc', '--push'])

        expected = deepcopy(DEFAULTS)
        expected['push'] = True

        for hook in HOOKS:
            expected[hook.key] = False

        assert config == expected
Ejemplo n.º 10
0
    def test_do_not_override_prepare_only_when_not_in_args(self):
        config = Config.parse_args(['-c', 'test.rc'])

        expected = deepcopy(DEFAULTS)
        expected['prepare_only'] = True

        for hook in HOOKS:
            expected[hook.key] = False

        assert config == expected
Ejemplo n.º 11
0
    def test_do_override_commit(self):
        config = Config.parse_args(['-c', 'test.rc', '-nc'])

        expected = deepcopy(DEFAULTS)
        expected['commit'] = False

        for hook in HOOKS:
            expected[hook.key] = False

        assert config == expected
Ejemplo n.º 12
0
    def test_skip_tests_from_args(self):
        config = Config.parse_args(['-c', 'test.rc', '--skip-tests'])

        expected = deepcopy(DEFAULTS)
        expected['skip_tests'] = True

        for hook in HOOKS:
            expected[hook.key] = False

        assert config == expected
Ejemplo n.º 13
0
    def test_do_not_override_bump_only_when_not_in_args(self):
        config = Config.parse_args(["-c", "test.rc"])

        expected = deepcopy(DEFAULTS)
        expected["bump_only"] = True

        for hook in HOOKS:
            expected[hook.key] = False

        assert config == expected
Ejemplo n.º 14
0
    def test_do_not_override_prepare_only_when_not_in_args(self):
        config = Config.parse_args(['-c', 'test.rc'])

        expected = deepcopy(DEFAULTS)
        expected['prepare_only'] = True

        for hook in HOOKS:
            expected[hook.key] = False

        assert config == expected
Ejemplo n.º 15
0
    def test_force_push_from_args(self):
        config = Config.parse_args(["-c", "test.rc", "--push"])

        expected = deepcopy(DEFAULTS)
        expected["push"] = True

        for hook in HOOKS:
            expected[hook.key] = False

        assert config == expected
Ejemplo n.º 16
0
    def test_do_not_override_push_when_not_in_args(self, mocker, mock_ini):
        config = Config.parse_args(['-c', 'test.rc'])

        expected = deepcopy(DEFAULTS)
        expected['push'] = True

        for hook in HOOKS:
            expected[hook.key] = False

        assert config == expected
Ejemplo n.º 17
0
    def test_skip_tests_from_args(self):
        config = Config.parse_args(["-c", "test.rc", "--skip-tests"])

        expected = deepcopy(DEFAULTS)
        expected["skip_tests"] = True

        for hook in HOOKS:
            expected[hook.key] = False

        assert config == expected
Ejemplo n.º 18
0
    def test_override_from_args(self):
        config = Config.parse_args(['test.py', '-M', '-v', '-s', 'test-suffix', '-c', 'fake'])

        expected = deepcopy(DEFAULTS)
        expected['file'] = 'test.py'
        expected['bump']['part'] = Version.MAJOR
        expected['bump']['suffix'] = 'test-suffix'
        expected['verbose'] = True
        for hook in HOOKS:
            expected[hook.key] = False

        self.assertDictEqual(config, expected)
Ejemplo n.º 19
0
    def test_override_from_args(self):
        config = Config.parse_args(["test.py", "-M", "-v", "-s", "test-suffix", "-c", "fake"])

        expected = deepcopy(DEFAULTS)
        expected["file"] = "test.py"
        expected["bump"]["part"] = Version.MAJOR
        expected["bump"]["suffix"] = "test-suffix"
        expected["verbose"] = True
        for hook in HOOKS:
            expected[hook.key] = False

        assert config == expected
Ejemplo n.º 20
0
    def test_override_from_args(self):
        config = Config.parse_args(
            ['test.py', '-M', '-v', '-s', 'test-suffix', '-c', 'fake'])

        expected = deepcopy(DEFAULTS)
        expected['file'] = 'test.py'
        expected['bump']['part'] = Version.MAJOR
        expected['bump']['suffix'] = 'test-suffix'
        expected['verbose'] = True
        for hook in HOOKS:
            expected[hook.key] = False

        self.assertDictEqual(config, expected)
Ejemplo n.º 21
0
    def test_skip_tests_from_args(self):
        bumprrc = '''\
        [bumpr]
        '''

        with mock_ini(bumprrc):
            with patch('bumpr.config.exists', return_value=True):
                config = Config.parse_args(['-c', 'test.rc', '--skip-tests'])

        expected = deepcopy(DEFAULTS)
        expected['skip_tests'] = True

        for hook in HOOKS:
            expected[hook.key] = False

        assert config == expected
Ejemplo n.º 22
0
    def test_override_push_from_args(self):
        bumprrc = '''\
        [bumpr]
        push = true
        '''

        with mock_ini(bumprrc):
            with patch('bumpr.config.exists', return_value=True):
                config = Config.parse_args(['-c', 'test.rc', '--no-push'])

        expected = deepcopy(DEFAULTS)
        expected['push'] = False

        for hook in HOOKS:
            expected[hook.key] = False

        assert config == expected
Ejemplo n.º 23
0
    def test_do_override_commit(self):
        bumprrc = '''\
        [bumpr]
        commit = True
        '''

        with mock_ini(bumprrc):
            with patch('bumpr.config.exists', return_value=True):
                config = Config.parse_args(['-c', 'test.rc', '-nc'])

        expected = deepcopy(DEFAULTS)
        expected['commit'] = False

        for hook in HOOKS:
            expected[hook.key] = False

        assert config == expected
Ejemplo n.º 24
0
    def test_override_args_keeps_config_values(self):
        config = Config.parse_args(['test.py', '-M', '-v', '-s', 'test-suffix', '-c', 'test.rc'])

        expected = deepcopy(DEFAULTS)
        expected['file'] = 'test.py'
        expected['bump']['part'] = Version.MAJOR
        expected['bump']['suffix'] = 'test-suffix'
        expected['verbose'] = True

        expected['files'] = ['README']
        expected['bump']['message'] = 'test'
        expected['prepare']['part'] = Version.MINOR

        for hook in HOOKS:
            expected[hook.key] = False

        assert config == expected
Ejemplo n.º 25
0
    def test_do_not_override_prepare_only_when_not_in_args(self):
        bumprrc = '''\
        [bumpr]
        prepare_only = True
        '''

        with mock_ini(bumprrc):
            with patch('bumpr.config.exists', return_value=True):
                config = Config.parse_args(['-c', 'test.rc'])

        expected = deepcopy(DEFAULTS)
        expected['prepare_only'] = True

        for hook in HOOKS:
            expected[hook.key] = False

        assert config == expected
Ejemplo n.º 26
0
    def test_override_args_keeps_config_values(self):
        config = Config.parse_args(["test.py", "-M", "-v", "-s", "test-suffix", "-c", "test.rc"])

        expected = deepcopy(DEFAULTS)
        expected["file"] = "test.py"
        expected["bump"]["part"] = Version.MAJOR
        expected["bump"]["suffix"] = "test-suffix"
        expected["verbose"] = True

        expected["files"] = ["README"]
        expected["bump"]["message"] = "test"
        expected["prepare"]["part"] = Version.MINOR

        for hook in HOOKS:
            expected[hook.key] = False

        assert config == expected
Ejemplo n.º 27
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)
Ejemplo n.º 28
0
    def test_override_args_keeps_config_values(self):
        config = Config.parse_args(
            ['test.py', '-M', '-v', '-s', 'test-suffix', '-c', 'test.rc'])

        expected = deepcopy(DEFAULTS)
        expected['file'] = 'test.py'
        expected['bump']['part'] = Version.MAJOR
        expected['bump']['suffix'] = 'test-suffix'
        expected['verbose'] = True

        expected['files'] = ['README']
        expected['bump']['message'] = 'test'
        expected['prepare']['part'] = Version.MINOR

        for hook in HOOKS:
            expected[hook.key] = False

        assert config == expected