예제 #1
0
    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)
예제 #2
0
    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)
예제 #3
0
    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)
예제 #4
0
파일: test_hooks.py 프로젝트: eight04/bumpr
    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)
예제 #5
0
 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)
예제 #6
0
    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)
예제 #7
0
 def test_validate(self, workspace):
     workspace.write("changelog", "")
     self.releaser.config.__getitem__.return_value = ObjectDict(
         {"file": "changelog"})
     ChangelogHook(self.releaser)
예제 #8
0
 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)
예제 #9
0
 def test_validate_no_file(self):
     with pytest.raises(BumprError):
         ChangelogHook(self.releaser)
예제 #10
0
 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)
예제 #11
0
 def test_validate_no_file(self):
     with self.assertRaises(BumprError):
         hook = ChangelogHook(self.releaser)
예제 #12
0
 def test_validate(self, workspace):
     workspace.write('changelog', '')
     self.releaser.config.__getitem__.return_value = ObjectDict(
         {'file': 'changelog'})
     ChangelogHook(self.releaser)