def test_prepare_no_separator(self, workspace): content = dedent('''\ ## 1.2.3 {0:%Y-%m-%d} - some changes ''').format(self.releaser.timestamp) workspace.write('changelog', content) self.releaser.config.__getitem__.return_value = ObjectDict({ 'file': 'changelog', 'separator': '', 'bump': '## {version} {date:%Y-%m-%d}', 'prepare': '## Dev', 'empty': 'Empty', }) hook = ChangelogHook(self.releaser) hook.prepare([]) expected = dedent('''\ ## Dev - Empty ## 1.2.3 {0:%Y-%m-%d} - some changes ''').format(self.releaser.timestamp) self.releaser.perform.assert_called_once_with('changelog', content, expected)
def test_bump_no_separator(self, workspace): content = dedent('''\ ## Dev - some changes ''') workspace.write('changelog', content) self.releaser.config.__getitem__.return_value = ObjectDict({ 'file': 'changelog', 'separator': '', 'bump': '## {version} {date:%Y-%m-%d}', 'prepare': '## Dev', 'empty': 'Empty', }) hook = ChangelogHook(self.releaser) hook.bump([]) expected = dedent('''\ ## 1.2.3 {0:%Y-%m-%d} - some changes ''').format(self.releaser.timestamp) self.releaser.perform.assert_called_once_with('changelog', content, expected)
def test_bump_no_separator(self, workspace): content = dedent("""\ ## Dev - some changes """) workspace.write("changelog", content) self.releaser.config.__getitem__.return_value = ObjectDict({ "file": "changelog", "separator": "", "bump": "## {version} {date:%Y-%m-%d}", "prepare": "## Dev", "empty": "Empty", }) hook = ChangelogHook(self.releaser) hook.bump([]) expected = dedent("""\ ## 1.2.3 {0:%Y-%m-%d} - some changes """).format(self.releaser.timestamp) self.releaser.perform.assert_called_once_with("changelog", content, expected)
def test_bump(self): content = dedent('''\ Dev ### - some changes ''') with workspace() as wksp: with codecs.open('changelog', 'wb', encoding='utf8') as f: f.write(content) self.releaser.config.__getitem__.return_value = ObjectDict({ 'file': 'changelog', 'separator': '#', 'bump': '{version} {date:%Y-%m-%d}', 'prepare': 'Dev', 'empty': 'Empty', }) hook = ChangelogHook(self.releaser) hook.bump([]) expected = dedent('''\ 1.2.3 {0:%Y-%m-%d} ################ - some changes ''').format(self.releaser.timestamp) self.releaser.perform.assert_called_once_with('changelog', content, expected)
def test_validate(self): with workspace() as wksp: with codecs.open('changelog', 'wb', encoding='utf8') as f: f.write('') self.releaser.config.__getitem__.return_value = ObjectDict( {'file': 'changelog'}) ChangelogHook(self.releaser)
def test_prepare(self): content = dedent('''\ 1.2.3 {0:%Y-%m-%d} ################ - some changes ''').format(self.releaser.timestamp) with workspace() as wksp: with codecs.open('changelog', 'wb', encoding='utf8') as f: f.write(content) self.releaser.config.__getitem__.return_value = ObjectDict({ 'file': 'changelog', 'separator': '#', 'bump': '{version} {date:%Y-%m-%d}', 'prepare': 'Dev', 'empty': 'Empty', }) hook = ChangelogHook(self.releaser) hook.prepare([]) expected = dedent('''\ Dev ### - Empty 1.2.3 {0:%Y-%m-%d} ################ - some changes ''').format(self.releaser.timestamp) self.releaser.perform.assert_called_once_with( 'changelog', content, expected)
def test_validate(self, workspace): workspace.write("changelog", "") self.releaser.config.__getitem__.return_value = ObjectDict( {"file": "changelog"}) ChangelogHook(self.releaser)
def test_validate_file_does_not_exists(self, workspace): self.releaser.config.__getitem__.return_value = ObjectDict( {"file": "changelog"}) with pytest.raises(BumprError): ChangelogHook(self.releaser)
def test_validate_no_file(self): with pytest.raises(BumprError): ChangelogHook(self.releaser)
def test_validate_file_does_not_exists(self): with workspace(): self.releaser.config.__getitem__.return_value = ObjectDict( {'file': 'changelog'}) with self.assertRaises(BumprError): hook = ChangelogHook(self.releaser)
def test_validate_no_file(self): with self.assertRaises(BumprError): hook = ChangelogHook(self.releaser)
def test_validate(self, workspace): workspace.write('changelog', '') self.releaser.config.__getitem__.return_value = ObjectDict( {'file': 'changelog'}) ChangelogHook(self.releaser)