Пример #1
0
 def test_empty(self):
     d = CommitData()
     # CommitData instance has bool value False if there is no data inside
     self.assertFalse(bool(d))
     self.assertEqual(None, d['message'])
     self.assertEqual({}, d.as_dict())
     self.assertEqual([], list(d.keys()))
Пример #2
0
 def test_init_with_data(self):
     d = CommitData(data={'fixes': 'lp:123456', 'message': 'foo bar'})
     # CommitData instance has bool value True if there is some data inside
     self.assertTrue(bool(d))
     self.assertEqual('foo bar', d['message'])
     self.assertEqual({
         'message': 'foo bar',
         'fixes': 'lp:123456',
     }, d.as_dict())
     self.assertEqual(set(['message', 'fixes']), set(d.keys()))
Пример #3
0
 def test_wipe_saved_data(self):
     wt = self.make_branch_and_tree('.')
     cfg = wt.branch.get_config()
     cfg.set_user_option('commit_data', {
         'message': 'spam',
         'old_revid': 'foo',
         'new_revid': 'bar',
     })
     d = CommitData(tree=wt)
     d.wipe()
     # check branch.conf
     cfg = wt.branch.get_config()
     self.assertEqual({}, cfg.get_user_option('commit_data'))
Пример #4
0
 def test_set_data_on_uncommit_bugids(self):
     wt = self.make_branch_and_tree('.')
     self.run_bzr(
         'commit --unchanged -m foo --fixes lp:12345 --fixes lp:67890')
     revid1 = wt.last_revision()
     d = CommitData(branch=wt.branch)
     d.set_data_on_uncommit(revid1, None)
     self.assertEqual(
         {
             'message': 'foo',
             'bugs': 'lp:12345 lp:67890',
             'old_revid': revid1,
             'new_revid': b'null:',
         }, d.as_dict())
Пример #5
0
 def test_load_saved_data(self):
     wt = self.make_branch_and_tree('.')
     cfg = wt.branch.get_config()
     cfg.set_user_option('commit_data', {
         'message': 'spam',
         'old_revid': 'foo',
         'new_revid': 'bar',
     })
     d = CommitData(tree=wt)
     d.load()
     self.assertEqual(
         {
             'message': 'spam',
             'old_revid': 'foo',
             'new_revid': 'bar',
         }, d.as_dict())
Пример #6
0
 def test_compare_data(self):
     this = CommitData(data={'fixes': 'lp:123456', 'message': 'foo bar'})
     self.assertTrue(
         this.compare_data(
             CommitData(data={
                 'fixes': 'lp:123456',
                 'message': 'foo bar'
             })))
     self.assertTrue(
         this.compare_data({
             'fixes': 'lp:123456',
             'message': 'foo bar'
         }))
     other = CommitData(
         data={
             'fixes': 'lp:123456',
             'message': 'foo bar',
             'old_revid': 'xxx',
             'new_revid': 'yyy',
         })
     self.assertFalse(this.compare_data(other))
     self.assertTrue(this.compare_data(other, all_keys=False))
Пример #7
0
 def test_set_data_kw(self):
     d = CommitData()
     d.set_data(message='foo bar')
     # CommitData instance has bool value True if there is some data inside
     self.assertTrue(bool(d))
     self.assertEqual('foo bar', d['message'])
     self.assertEqual({'message': 'foo bar'}, d.as_dict())
     self.assertEqual(['message'], list(d.keys()))
Пример #8
0
 def test_save_filter_out_empty_data(self):
     wt = self.make_branch_and_tree('.')
     d = CommitData(tree=wt)
     d.set_data({'message': '', 'foo': 'bar'})
     d.save()
     # check branch.conf
     cfg = wt.branch.get_config()
     self.assertEqual({'foo': 'bar'}, cfg.get_user_option('commit_data'))
Пример #9
0
    def test_set_data_on_uncommit(self):
        wt = self.make_branch_and_tree('.')
        revid1 = wt.commit(message='1')
        # imitate uncommit in branch with only one revision
        d = CommitData(branch=wt.branch)
        d.set_data_on_uncommit(revid1, None)

        self.assertEqual(
            {
                'message': '1',
                'old_revid': revid1,
                'new_revid': b'null:',
            }, d.as_dict())
        #
        revid2 = wt.commit(message='2')
        # imitate uncommit in branch with several revisions
        d = CommitData(branch=wt.branch)
        d.set_data_on_uncommit(revid2, revid1)
        self.assertEqual(
            {
                'message': '2',
                'old_revid': revid2,
                'new_revid': revid1,
            }, d.as_dict())
Пример #10
0
 def test_set_data_dict_and_kw(self):
     d = CommitData()
     d.set_data({'fixes': 'lp:123456'}, message='foo bar')
     # CommitData instance has bool value True if there is some data inside
     self.assertTrue(bool(d))
     self.assertEqual('foo bar', d['message'])
     self.assertEqual({
         'message': 'foo bar',
         'fixes': 'lp:123456',
     }, d.as_dict())
     self.assertEqual(set(['message', 'fixes']), set(d.keys()))
Пример #11
0
 def test_save_message_with_spaces(self):
     wt = self.make_branch_and_tree('.')
     d = CommitData(tree=wt)
     d.set_data(message='spam with spaces',
                old_revid='foo',
                new_revid='bar')
     d.save()
     # check branch.conf
     cfg = wt.branch.get_config()
     self.assertEqual(
         {
             'message': 'spam with spaces',
             'old_revid': 'foo',
             'new_revid': 'bar',
         }, cfg.get_user_option('commit_data'))
Пример #12
0
 def test_load_nothing(self):
     wt = self.make_branch_and_tree('.')
     d = CommitData(tree=wt)
     d.load()
     self.assertEqual({}, d.as_dict())