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_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)
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)
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
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
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
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
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
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
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
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
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
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)
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
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)
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
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
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
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
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
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
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_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