Mercurial > python-hglib
comparison tests/test_summary.py @ 219:8341f2494b3f
hglib tests: migrate away from (unmaintained) nose
author | Mathias De Mare <mathias.de_mare@nokia.com> |
---|---|
date | Wed, 08 Mar 2023 17:04:58 +0100 |
parents | tests/test-summary.py@9062a6b935ad |
children | a2afbf236ca8 |
comparison
equal
deleted
inserted
replaced
218:934608d4fcba | 219:8341f2494b3f |
---|---|
1 import unittest | |
2 from tests import common | |
3 import hglib | |
4 from hglib.util import b | |
5 | |
6 class test_summary(common.basetest): | |
7 def test_empty(self): | |
8 d = {b('parent') : [(-1, b('000000000000'), b('tip'), None)], | |
9 b('branch') : b('default'), | |
10 b('commit') : True, | |
11 b('update') : 0} | |
12 | |
13 self.assertEquals(self.client.summary(), d) | |
14 | |
15 def test_basic(self): | |
16 self.append('a', 'a') | |
17 rev, node = self.client.commit(b('first'), addremove=True) | |
18 | |
19 d = {b('parent') : [(0, node[:12], b('tip'), b('first'))], | |
20 b('branch') : b('default'), | |
21 b('commit') : True, | |
22 b('update') : 0} | |
23 if self.client.version >= (3, 5): | |
24 d[b('phases')] = b('1 draft') | |
25 | |
26 self.assertEquals(self.client.summary(), d) | |
27 | |
28 def test_commit_dirty(self): | |
29 self.append('a', 'a') | |
30 rev, node = self.client.commit(b('first'), addremove=True) | |
31 self.append('a', 'a') | |
32 | |
33 d = {b('parent') : [(0, node[:12], b('tip'), b('first'))], | |
34 b('branch') : b('default'), | |
35 b('commit') : False, | |
36 b('update') : 0} | |
37 if self.client.version >= (3, 5): | |
38 d[b('phases')] = b('1 draft') | |
39 | |
40 self.assertEquals(self.client.summary(), d) | |
41 | |
42 def test_secret_commit_clean(self): | |
43 if self.client.version < (2, 1): | |
44 raise unittest.SkipTest('phase not supported') | |
45 self.append('a', 'a') | |
46 rev, node = self.client.commit(b('first'), addremove=True) | |
47 self.client.phase([b('%d') % rev], secret=True, force=True) | |
48 e = self.client.summary() | |
49 self.assertTrue(e[b('commit')]) | |
50 | |
51 def test_update(self): | |
52 self.append('a', 'a') | |
53 rev, node = self.client.commit(b('first'), addremove=True) | |
54 self.append('a', 'a') | |
55 self.client.commit(b('second')) | |
56 self.client.update(0) | |
57 | |
58 d = {b('parent') : [(0, node[:12], None, b('first'))], | |
59 b('branch') : b('default'), | |
60 b('commit') : True, | |
61 b('update') : 1} | |
62 if self.client.version >= (3, 5): | |
63 d[b('phases')] = b('2 draft') | |
64 | |
65 self.assertEquals(self.client.summary(), d) | |
66 | |
67 def test_remote(self): | |
68 self.append('a', 'a') | |
69 rev, node = self.client.commit(b('first'), addremove=True) | |
70 | |
71 self.client.clone(dest=b('other')) | |
72 other = hglib.open('other') | |
73 | |
74 d = {b('parent') : [(0, node[:12], b('tip'), b('first'))], | |
75 b('branch') : b('default'), | |
76 b('commit') : True, | |
77 b('update') : 0, | |
78 b('remote') : (0, 0, 0, 0)} | |
79 | |
80 self.assertEquals(other.summary(remote=True), d) | |
81 | |
82 self.append('a', 'a') | |
83 self.client.commit(b('second')) | |
84 | |
85 d[b('remote')] = (1, 0, 0, 0) | |
86 self.assertEquals(other.summary(remote=True), d) | |
87 | |
88 self.client.bookmark(b('bm')) | |
89 d[b('remote')] = (1, 1, 0, 0) | |
90 self.assertEquals(other.summary(remote=True), d) | |
91 | |
92 other.bookmark(b('bmother')) | |
93 d[b('remote')] = (1, 1, 0, 1) | |
94 if self.client.version < (2, 0, 0): | |
95 d[b('parent')] = [(0, node[:12], b('tip bmother'), b('first'))] | |
96 else: | |
97 d[b('bookmarks')] = b('*bmother') | |
98 self.assertEquals(other.summary(remote=True), d) | |
99 | |
100 self.append('other/a', 'a') | |
101 rev, node = other.commit(b('second in other')) | |
102 | |
103 d[b('remote')] = (1, 1, 1, 1) | |
104 if self.client.version < (2, 0, 0): | |
105 tags = b('tip bmother') | |
106 else: | |
107 tags = b('tip') | |
108 d[b('parent')] = [(1, node[:12], tags, b('second in other'))] | |
109 if self.client.version >= (3, 5): | |
110 d[b('phases')] = b('1 draft') | |
111 | |
112 self.assertEquals(other.summary(remote=True), d) | |
113 | |
114 def test_two_parents(self): | |
115 self.append('a', 'a') | |
116 rev0, node = self.client.commit(b('first'), addremove=True) | |
117 | |
118 self.append('a', 'a') | |
119 rev1, node1 = self.client.commit(b('second')) | |
120 | |
121 self.client.update(rev0) | |
122 self.append('b', 'a') | |
123 rev2, node2 = self.client.commit(b('third'), addremove=True) | |
124 | |
125 self.client.merge(rev1) | |
126 | |
127 d = {b('parent') : [(2, node2[:12], b('tip'), b('third')), | |
128 (1, node1[:12], None, b('second'))], | |
129 b('branch') : b('default'), | |
130 b('commit') : False, | |
131 b('update') : 0} | |
132 if self.client.version >= (3, 5): | |
133 d[b('phases')] = b('3 draft') | |
134 | |
135 self.assertEquals(self.client.summary(), d) |