bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
1 |
# Copyright (C) 2005, 2006, 2008, 2009, 2011, 2016 Canonical Ltd
|
|
1886.1.4
by John Arbash Meinel
Move the revprops test to test against each Repository format. |
2 |
#
|
3 |
# This program is free software; you can redistribute it and/or modify
|
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
1185.16.35
by Martin Pool
- stub for revision properties |
16 |
|
17 |
"""Tests for revision properties."""
|
|
18 |
||
|
6852.2.1
by Jelmer Vernooij
Allow formats to not support custom revision properties. |
19 |
from breezy.tests import TestNotApplicable |
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
20 |
from breezy.tests.per_repository import ( |
|
1886.1.4
by John Arbash Meinel
Move the revprops test to test against each Repository format. |
21 |
TestCaseWithRepository, |
22 |
)
|
|
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
23 |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
24 |
|
|
1886.1.4
by John Arbash Meinel
Move the revprops test to test against each Repository format. |
25 |
class TestRevProps(TestCaseWithRepository): |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
26 |
|
|
1185.16.35
by Martin Pool
- stub for revision properties |
27 |
def test_simple_revprops(self): |
28 |
"""Simple revision properties""" |
|
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
29 |
wt = self.make_branch_and_tree('.') |
30 |
b = wt.branch |
|
|
1185.35.16
by Aaron Bentley
Fixed tests |
31 |
b.nick = 'Nicholas' |
|
6852.2.1
by Jelmer Vernooij
Allow formats to not support custom revision properties. |
32 |
if b.repository._format.supports_custom_revision_properties: |
|
6973.12.9
by Jelmer Vernooij
More fixes. |
33 |
props = {u'flavor': 'choc-mint', |
34 |
u'condiment': 'orange\n mint\n\tcandy', |
|
35 |
u'empty': '', |
|
36 |
u'non_ascii': u'\xb5'} |
|
|
6852.2.1
by Jelmer Vernooij
Allow formats to not support custom revision properties. |
37 |
else: |
38 |
props = {} |
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
39 |
rev1 = wt.commit(message='initial null commit', |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
40 |
revprops=props, |
41 |
allow_pointless=True) |
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
42 |
rev = b.repository.get_revision(rev1) |
|
6852.2.1
by Jelmer Vernooij
Allow formats to not support custom revision properties. |
43 |
if b.repository._format.supports_custom_revision_properties: |
|
6973.12.5
by Jelmer Vernooij
Add some u's for revision property names. |
44 |
self.assertTrue(u'flavor' in rev.properties) |
45 |
self.assertEqual(rev.properties[u'flavor'], 'choc-mint') |
|
|
6852.2.1
by Jelmer Vernooij
Allow formats to not support custom revision properties. |
46 |
expected_revprops = { |
|
6973.12.5
by Jelmer Vernooij
Add some u's for revision property names. |
47 |
u'condiment': 'orange\n mint\n\tcandy', |
48 |
u'empty': '', |
|
49 |
u'flavor': 'choc-mint', |
|
50 |
u'non_ascii': u'\xb5', |
|
|
6852.2.1
by Jelmer Vernooij
Allow formats to not support custom revision properties. |
51 |
}
|
52 |
else: |
|
53 |
expected_revprops = {} |
|
|
6820.1.1
by Jelmer Vernooij
add RepositoryFormat.supports_storing_branch_nick. |
54 |
if b.repository._format.supports_storing_branch_nick: |
|
6973.12.5
by Jelmer Vernooij
Add some u's for revision property names. |
55 |
expected_revprops[u'branch-nick'] = 'Nicholas' |
|
6852.2.1
by Jelmer Vernooij
Allow formats to not support custom revision properties. |
56 |
for name, value in expected_revprops.items(): |
57 |
self.assertEqual(rev.properties[name], value) |
|
|
1185.16.37
by Martin Pool
- properties are retrieved when revisions are loaded |
58 |
|
|
1185.16.39
by Martin Pool
- constraints on revprops |
59 |
def test_invalid_revprops(self): |
60 |
"""Invalid revision properties""" |
|
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
61 |
wt = self.make_branch_and_tree('.') |
62 |
b = wt.branch |
|
|
6852.2.1
by Jelmer Vernooij
Allow formats to not support custom revision properties. |
63 |
if not b.repository._format.supports_custom_revision_properties: |
64 |
raise TestNotApplicable( |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
65 |
'format does not support custom revision properties') |
|
1185.16.39
by Martin Pool
- constraints on revprops |
66 |
self.assertRaises(ValueError, |
|
3831.1.5
by John Arbash Meinel
It seems we have some direct tests that don't use strings and expect a value error as well. |
67 |
wt.commit, |
|
1185.16.39
by Martin Pool
- constraints on revprops |
68 |
message='invalid', |
69 |
revprops={'what a silly property': 'fine'}) |
|
70 |
self.assertRaises(ValueError, |
|
|
3831.1.5
by John Arbash Meinel
It seems we have some direct tests that don't use strings and expect a value error as well. |
71 |
wt.commit, |
|
1185.16.39
by Martin Pool
- constraints on revprops |
72 |
message='invalid', |
73 |
revprops=dict(number=13)) |
|
|
1913.1.1
by John Arbash Meinel
Fix bug #55783 |
74 |
|
75 |
||
76 |
class TestRevisionAttributes(TestCaseWithRepository): |
|
77 |
"""Test that revision attributes are correct.""" |
|
78 |
||
79 |
def test_revision_accessors(self): |
|
|
3831.1.5
by John Arbash Meinel
It seems we have some direct tests that don't use strings and expect a value error as well. |
80 |
"""Make sure the values that come out of a revision are the |
|
1913.1.1
by John Arbash Meinel
Fix bug #55783 |
81 |
same as the ones that go in.
|
82 |
"""
|
|
83 |
tree1 = self.make_branch_and_tree("br1") |
|
|
6852.2.1
by Jelmer Vernooij
Allow formats to not support custom revision properties. |
84 |
if tree1.branch.repository._format.supports_custom_revision_properties: |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
85 |
revprops = {u'empty': '', |
86 |
u'value': 'one', |
|
87 |
u'unicode': u'\xb5', |
|
88 |
u'multiline': 'foo\nbar\n\n' |
|
89 |
}
|
|
|
6852.2.1
by Jelmer Vernooij
Allow formats to not support custom revision properties. |
90 |
else: |
91 |
revprops = {} |
|
92 |
# create a revision
|
|
93 |
rev1 = tree1.commit(message="quux", allow_pointless=True, |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
94 |
committer="jaq", revprops=revprops) |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
95 |
self.assertEqual(tree1.branch.last_revision(), rev1) |
|
1913.1.1
by John Arbash Meinel
Fix bug #55783 |
96 |
rev_a = tree1.branch.repository.get_revision( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
97 |
tree1.branch.last_revision()) |
|
1913.1.1
by John Arbash Meinel
Fix bug #55783 |
98 |
|
99 |
tree2 = self.make_branch_and_tree("br2") |
|
100 |
tree2.commit(message=rev_a.message, |
|
101 |
timestamp=rev_a.timestamp, |
|
102 |
timezone=rev_a.timezone, |
|
103 |
committer=rev_a.committer, |
|
|
6819.1.2
by Jelmer Vernooij
Fix two revid-less tests. |
104 |
rev_id=(rev_a.revision_id |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
105 |
if tree2.branch.repository._format.supports_setting_revision_ids |
106 |
else None), |
|
|
1913.1.1
by John Arbash Meinel
Fix bug #55783 |
107 |
revprops=rev_a.properties, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
108 |
allow_pointless=True, # there's nothing in this commit |
|
1913.1.1
by John Arbash Meinel
Fix bug #55783 |
109 |
strict=True, |
110 |
verbose=True) |
|
111 |
rev_b = tree2.branch.repository.get_revision( |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
112 |
tree2.branch.last_revision()) |
|
3831.1.5
by John Arbash Meinel
It seems we have some direct tests that don't use strings and expect a value error as well. |
113 |
|
|
1913.1.1
by John Arbash Meinel
Fix bug #55783 |
114 |
self.assertEqual(rev_a.message, rev_b.message) |
115 |
self.assertEqual(rev_a.timestamp, rev_b.timestamp) |
|
116 |
self.assertEqual(rev_a.timezone, rev_b.timezone) |
|
117 |
self.assertEqual(rev_a.committer, rev_b.committer) |
|
118 |
self.assertEqual(rev_a.revision_id, rev_b.revision_id) |
|
119 |
self.assertEqual(rev_a.properties, rev_b.properties) |
|
120 |
||
|
1913.1.5
by John Arbash Meinel
fix test name |
121 |
def test_zero_timezone(self): |
|
1913.1.1
by John Arbash Meinel
Fix bug #55783 |
122 |
tree1 = self.make_branch_and_tree("br1") |
123 |
||
124 |
# create a revision
|
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
125 |
r1 = tree1.commit(message="quux", timezone=0) |
126 |
rev_a = tree1.branch.repository.get_revision(r1) |
|
|
1913.1.1
by John Arbash Meinel
Fix bug #55783 |
127 |
self.assertEqual(0, rev_a.timezone) |