annotate tests/test-phase.py @ 141:ea80bd2775f6

hglib: introduce util.b() (issue4520) The util.b() function will be used to mark all string literals in the code base which should be treated as bytes instead of text. This is to help with supporting Python 3.
author Brett Cannon <brett@python.org>
date Sat, 07 Mar 2015 10:08:52 -0500
parents b6f601ba7f3c
children 4359cabcb0cc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
125
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
1 import common, hglib
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
2
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
3 class test_phase(common.basetest):
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
4 """test the different ways to use the phase command"""
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
5 def test_phase(self):
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
6 """test getting data from a single changeset"""
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
7 self.append('a', 'a')
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
8 rev, node0 = self.client.commit('first', addremove=True)
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
9 self.assertEqual([(0, 'draft')], self.client.phase(node0))
126
a7fe976b1931 context: add 'phase' getter
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 125
diff changeset
10 ctx = self.client[rev]
a7fe976b1931 context: add 'phase' getter
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 125
diff changeset
11 self.assertEqual('draft', ctx.phase())
125
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
12
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
13 def test_phase_public(self):
126
a7fe976b1931 context: add 'phase' getter
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 125
diff changeset
14 """test phase change from draft to public"""
125
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
15 self.append('a', 'a')
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
16 rev, node0 = self.client.commit('first', addremove=True)
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
17 self.client.phase(node0, public=True)
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
18 self.assertEqual([(0, 'public')], self.client.phase(node0))
126
a7fe976b1931 context: add 'phase' getter
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 125
diff changeset
19 ctx = self.client[rev]
a7fe976b1931 context: add 'phase' getter
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 125
diff changeset
20 self.assertEqual('public', ctx.phase())
125
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
21
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
22 def test_phase_secret(self):
126
a7fe976b1931 context: add 'phase' getter
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 125
diff changeset
23 """test phase change from draft to secret"""
125
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
24 self.append('a', 'a')
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
25 rev, node0 = self.client.commit('first', addremove=True)
129
bcc8390d7819 tests: remove "with" usage for 2.4 compatibility
Matt Mackall <mpm@selenic.com>
parents: 126
diff changeset
26 self.assertRaises(hglib.error.CommandError,
bcc8390d7819 tests: remove "with" usage for 2.4 compatibility
Matt Mackall <mpm@selenic.com>
parents: 126
diff changeset
27 self.client.phase, node0, secret=True)
125
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
28 self.client.phase(node0, secret=True, force=True)
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
29 self.assertEqual([(0, 'secret')], self.client.phase(node0))
126
a7fe976b1931 context: add 'phase' getter
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 125
diff changeset
30 ctx = self.client[rev]
a7fe976b1931 context: add 'phase' getter
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 125
diff changeset
31 self.assertEqual('secret', ctx.phase())
a7fe976b1931 context: add 'phase' getter
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 125
diff changeset
32
125
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
33
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
34 def test_phase_multiple(self):
126
a7fe976b1931 context: add 'phase' getter
Paul Tonelli <paul.tonelli@logilab.fr>
parents: 125
diff changeset
35 """test phase changes and show the phases of the different changesets"""
125
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
36 self.append('a', 'a')
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
37 rev, node0 = self.client.commit('a', addremove=True)
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
38 self.client.phase(node0, public=True)
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
39 self.append('b', 'b')
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
40 rev, node1 = self.client.commit('b', addremove=True)
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
41 self.append('c', 'c')
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
42 rev, node2 = self.client.commit('c', addremove=True)
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
43 self.client.phase(node2, secret=True, force=True)
8d9a9da3e7b4 client: add 'phase' method to set or get the phase of a changeset
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
44 self.assertEqual([(0, 'public'), (2, 'secret'), (1, 'draft')],
133
b6f601ba7f3c style: fixup whitespace
Matt Mackall <mpm@selenic.com>
parents: 129
diff changeset
45 self.client.phase([node0, node2, node1]))