示例#1
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)
示例#2
0
    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)
示例#3
0
    def test_validate_ko_not_bazaar(self):
        with workspace('bazaar') as wksp:
            bazaar = Bazaar()

            with patch('bumpr.vcs.execute') as execute:
                with self.assertRaises(BumprError):
                    bazaar.validate()
                self.assertFalse(execute.called)
示例#4
0
    def test_commit(self):
        config = Config({'file': 'fake.py', 'vcs': 'fake'})
        with workspace('fake') as wksp:
            releaser = Releaser(config)

        with patch.object(releaser, 'vcs') as vcs:
            releaser.commit('message')
            vcs.commit.assert_called_with('message')
示例#5
0
    def test_commit(self):
        config = Config({'file': 'fake.py', 'vcs': 'fake'})
        with workspace('fake') as wksp:
            releaser = Releaser(config)

        with patch.object(releaser, 'vcs') as vcs:
            releaser.commit('message')
            vcs.commit.assert_called_with('message')
示例#6
0
文件: test_vcs.py 项目: eight04/bumpr
    def test_validate_ko_not_git(self):
        with workspace('git'):
            git = Git()

            with patch('bumpr.vcs.execute') as execute:
                with self.assertRaises(BumprError):
                    git.validate()
                self.assertFalse(execute.called)
示例#7
0
文件: test_vcs.py 项目: eight04/bumpr
    def test_validate_ko_not_mercurial(self):
        with workspace('mercurial'):
            mercurial = Mercurial()

            with patch('bumpr.vcs.execute') as execute:
                with self.assertRaises(BumprError):
                    mercurial.validate()
                self.assertFalse(execute.called)
示例#8
0
    def test_validate_ko_not_mercurial(self):
        with workspace('mercurial') as wksp:
            mercurial = Mercurial()

            with patch('bumpr.vcs.execute') as execute:
                with self.assertRaises(BumprError):
                    mercurial.validate()
                self.assertFalse(execute.called)
示例#9
0
    def test_tag(self):
        config = Config({'file': 'fake.py', 'vcs': 'fake'})
        with workspace('fake') as wksp:
            releaser = Releaser(config)

        with patch.object(releaser, 'vcs') as vcs:
            releaser.tag()
            vcs.tag.assert_called_with(str(releaser.version))
示例#10
0
文件: test_vcs.py 项目: eight04/bumpr
    def test_validate_ko_not_bazaar(self):
        with workspace('bazaar'):
            bazaar = Bazaar()

            with patch('bumpr.vcs.execute') as execute:
                with self.assertRaises(BumprError):
                    bazaar.validate()
                self.assertFalse(execute.called)
示例#11
0
    def test_validate_ko_not_git(self):
        with workspace('git') as wksp:
            git = Git()

            with patch('bumpr.vcs.execute') as execute:
                with self.assertRaises(BumprError):
                    git.validate()
                self.assertFalse(execute.called)
示例#12
0
    def test_tag(self):
        config = Config({'file': 'fake.py', 'vcs': 'fake'})
        with workspace('fake') as wksp:
            releaser = Releaser(config)

        with patch.object(releaser, 'vcs') as vcs:
            releaser.tag()
            vcs.tag.assert_called_with(str(releaser.version))
示例#13
0
文件: test_vcs.py 项目: eight04/bumpr
    def test_validate_ok(self):
        with workspace('bazaar'):
            os.mkdir('.bzr')
            bazaar = Bazaar()

            with patch('bumpr.vcs.execute') as execute:
                execute.return_value = '? new.py'
                bazaar.validate()
                execute.assert_called_with('bzr status --short', verbose=False)
示例#14
0
文件: test_vcs.py 项目: eight04/bumpr
    def test_validate_ok(self):
        with workspace('mercurial'):
            os.mkdir('.hg')
            mercurial = Mercurial()

            with patch('bumpr.vcs.execute') as execute:
                execute.return_value = '?? new.py'
                mercurial.validate()
                execute.assert_called_with('hg status -mard', verbose=False)
示例#15
0
文件: test_vcs.py 项目: eight04/bumpr
    def test_validate_ok(self):
        with workspace('git'):
            os.mkdir('.git')
            git = Git()

            with patch('bumpr.vcs.execute') as execute:
                execute.return_value = '?? new.py'
                git.validate()
                execute.assert_called_with('git status --porcelain', verbose=False)
示例#16
0
    def test_validate_ok(self):
        with workspace('bazaar') as wksp:
            os.mkdir('.bzr')
            bazaar = Bazaar()

            with patch('bumpr.vcs.execute') as execute:
                execute.return_value = '? new.py'
                bazaar.validate()
                execute.assert_called_with('bzr status --short', verbose=False)
示例#17
0
    def test_validate_ok(self):
        with workspace('mercurial') as wksp:
            os.mkdir('.hg')
            mercurial = Mercurial()

            with patch('bumpr.vcs.execute') as execute:
                execute.return_value = '?? new.py'
                mercurial.validate()
                execute.assert_called_with('hg status -mard', verbose=False)
示例#18
0
文件: test_vcs.py 项目: eight04/bumpr
    def test_validate_ko_not_clean(self):
        with workspace('mercurial'):
            os.mkdir('.hg')
            mercurial = Mercurial()

            with patch('bumpr.vcs.execute') as execute:
                execute.return_value = '\n'.join((' M modified.py', '?? new.py'))
                with self.assertRaises(BumprError):
                    mercurial.validate()
                execute.assert_called_with('hg status -mard', verbose=False)
示例#19
0
文件: test_vcs.py 项目: eight04/bumpr
    def test_validate_ko_not_clean(self):
        with workspace('bazaar'):
            os.mkdir('.bzr')
            bazaar = Bazaar()

            with patch('bumpr.vcs.execute') as execute:
                execute.return_value = '\n'.join((' M modified.py', '? new.py'))
                with self.assertRaises(BumprError):
                    bazaar.validate()
                execute.assert_called_with('bzr status --short', verbose=False)
示例#20
0
文件: test_vcs.py 项目: eight04/bumpr
    def test_validate_ko_not_clean(self):
        with workspace('git'):
            os.mkdir('.git')
            git = Git()

            with patch('bumpr.vcs.execute') as execute:
                execute.return_value = '\n'.join((' M modified.py', '?? new.py'))
                with self.assertRaises(BumprError):
                    git.validate()
                execute.assert_called_with('git status --porcelain', verbose=False)
示例#21
0
    def test_validate_ok(self):
        with workspace('git') as wksp:
            os.mkdir('.git')
            git = Git()

            with patch('bumpr.vcs.execute') as execute:
                execute.return_value = '?? new.py'
                git.validate()
                execute.assert_called_with('git status --porcelain',
                                           verbose=False)
示例#22
0
    def test_validate_ko_not_clean(self):
        with workspace('mercurial') as wksp:
            os.mkdir('.hg')
            mercurial = Mercurial()

            with patch('bumpr.vcs.execute') as execute:
                execute.return_value = '\n'.join(
                    (' M modified.py', '?? new.py'))
                with self.assertRaises(BumprError):
                    mercurial.validate()
                execute.assert_called_with('hg status -mard', verbose=False)
示例#23
0
    def test_validate_ko_not_clean(self):
        with workspace('bazaar') as wksp:
            os.mkdir('.bzr')
            bazaar = Bazaar()

            with patch('bumpr.vcs.execute') as execute:
                execute.return_value = '\n'.join(
                    (' M modified.py', '? new.py'))
                with self.assertRaises(BumprError):
                    bazaar.validate()
                execute.assert_called_with('bzr status --short', verbose=False)
示例#24
0
    def test_clean(self):
        config = Config({
            'file': 'fake.py',
            'clean': 'clean command',
        })
        with workspace('fake'):
            releaser = Releaser(config)

        with patch('bumpr.releaser.execute') as execute:
            releaser.clean()
            execute.assert_called_with('clean command', replacements=ANY, dryrun=ANY, verbose=ANY)
示例#25
0
    def test_validate_ko_not_clean(self):
        with workspace('git') as wksp:
            os.mkdir('.git')
            git = Git()

            with patch('bumpr.vcs.execute') as execute:
                execute.return_value = '\n'.join(
                    (' M modified.py', '?? new.py'))
                with self.assertRaises(BumprError):
                    git.validate()
                execute.assert_called_with('git status --porcelain',
                                           verbose=False)
示例#26
0
    def test_clean(self):
        config = Config({
            'file': 'fake.py',
            'clean': 'clean command',
        })
        with workspace('fake'):
            releaser = Releaser(config)

        with patch('bumpr.releaser.execute') as execute:
            releaser.clean()
            execute.assert_called_with('clean command',
                                       replacements=ANY,
                                       dryrun=ANY,
                                       verbose=ANY)
示例#27
0
    def test_bump(self):
        with workspace('fake', '1.2.3.dev') as wksp:
            config = Config({'file': 'fake.py', 'files': [wksp.readme]})
            releaser = Releaser(config)
            with patch.object(releaser, 'commit') as commit:
                with patch.object(releaser, 'tag') as tag:
                    releaser.bump()
                    self.assertFalse(commit.called)
                    self.assertFalse(tag.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)
示例#28
0
    def test_constructor_with_hooks(self):
        config = Config({'file': 'fake.py'})
        hooks = []
        for i in range(3):
            key = 'hook{0}'.format(i)
            config[key] = True
            mock = MagicMock()
            mock.key = key
            hooks.append(mock)

        with workspace('fake', '1.2.3.dev') as wksp:
            with patch('bumpr.releaser.HOOKS', hooks) as mock:
                releaser = Releaser(config)
                for hook in hooks:
                    hook.assert_called_with(releaser)
示例#29
0
    def test_bump(self):
        with workspace('fake', '1.2.3.dev') as wksp:
            config = Config({'file': 'fake.py', 'files': [wksp.readme]})
            releaser = Releaser(config)
            with patch.object(releaser, 'commit') as commit:
                with patch.object(releaser, 'tag') as tag:
                    releaser.bump()
                    self.assertFalse(commit.called)
                    self.assertFalse(tag.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)
示例#30
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)
示例#31
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)
示例#32
0
    def test_constructor(self):
        config = Config({'file': 'fake.py'})
        with workspace('fake', '1.2.3.dev') as wksp:
            releaser = Releaser(config)

        self.assertIsInstance(releaser.prev_version, Version)
        self.assertEqual(str(releaser.prev_version), '1.2.3.dev')

        self.assertIsInstance(releaser.version, Version)
        self.assertIsInstance(releaser.next_version, Version)

        self.assertIsNone(releaser.timestamp)

        self.assertFalse(hasattr(releaser, 'vcs'))
        self.assertFalse(hasattr(releaser, 'diffs'))

        self.assertEqual(releaser.hooks, [])
示例#33
0
    def test_constructor_with_hooks(self):
        config = Config({
            'file': 'fake.py'
        })
        hooks = []
        for i in range(3):
            key = 'hook{0}'.format(i)
            config[key] = True
            mock = MagicMock()
            mock.key = key
            hooks.append(mock)

        with workspace('fake', '1.2.3.dev') as wksp:
            with patch('bumpr.releaser.HOOKS', hooks) as mock:
                releaser = Releaser(config)
                for hook in hooks:
                    hook.assert_called_with(releaser)
示例#34
0
    def test_constructor(self):
        config = Config({
            'file': 'fake.py'
        })
        with workspace('fake', '1.2.3.dev') as wksp:
            releaser = Releaser(config)

        self.assertIsInstance(releaser.prev_version, Version)
        self.assertEqual(str(releaser.prev_version), '1.2.3.dev')

        self.assertIsInstance(releaser.version, Version)
        self.assertIsInstance(releaser.next_version, Version)

        self.assertIsNone(releaser.timestamp)

        self.assertFalse(hasattr(releaser, 'vcs'))
        self.assertFalse(hasattr(releaser, 'diffs'))

        self.assertEqual(releaser.hooks, [])
示例#35
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)
示例#36
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)
示例#37
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)
示例#38
0
    def test_prepare(self):
        with workspace('fake', '1.2.3') as wksp:
            config = Config({
                'file': 'fake.py',
                'files': [wksp.readme],
                'prepare': {
                    'part': Version.PATCH,
                    'suffix': 'dev',
                }
            })
            releaser = Releaser(config)
            with patch.object(releaser, 'commit') as commit:
                with patch.object(releaser, 'tag') as tag:
                    releaser.prepare()
                    self.assertFalse(commit.called)
                    self.assertFalse(tag.called)

            for filename in wksp.module, wksp.readme:
                with open(filename) as f:
                    content = f.read()
                    self.assertIn('1.2.4.dev', content)
                    self.assertNotIn('1.2.3', content)
示例#39
0
    def test_prepare(self):
        with workspace('fake', '1.2.3') as wksp:
            config = Config({
                'file': 'fake.py',
                'files': [wksp.readme],
                'prepare': {
                    'part': Version.PATCH,
                    'suffix': 'dev',
                }
            })
            releaser = Releaser(config)
            with patch.object(releaser, 'commit') as commit:
                with patch.object(releaser, 'tag') as tag:
                    releaser.prepare()
                    self.assertFalse(commit.called)
                    self.assertFalse(tag.called)

            for filename in wksp.module, wksp.readme:
                with open(filename) as f:
                    content = f.read()
                    self.assertIn('1.2.4.dev', content)
                    self.assertNotIn('1.2.3', content)
示例#40
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)
示例#41
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)
示例#42
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)