annotate tests/test-status.py @ 180:ff6efc1ab9e4

protocol: allow hglib user to get call backs for prompts, output and errors setcbout(cbout), setcberr(cberr) and setcbprompt(cbprompt) are used to set the call back function used by the hgclient class. cb stands for call back. cbout is a function that will be called with the stdout data of the command as it runs. cbout is called with output as it is made available, which can be as partial lines or multiple lines. cberr is a function that will be called with the stderr data of the command as it runs. cberr is called with output as it is made available, which can be as partial lines or multiple lines. Command that make remote connects can prompt for username and password for HTTP/HTTPS connections. cbprompt is called when hgclient need a response to a prompt from the server. It receives the max number of bytes to return and the contents of stdout received so far. The last text sent to either cbout or cberr will contain the prompt text itself.
author Barry A. Scott <barry@barrys-emacs.org>
date Fri, 28 Oct 2016 11:33:20 +0100
parents c1b966866ed7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
148
c1b966866ed7 hglib: make all imports absolute (issue4520)
Brett Cannon <brett@python.org>
parents: 143
diff changeset
1 import os
c1b966866ed7 hglib: make all imports absolute (issue4520)
Brett Cannon <brett@python.org>
parents: 143
diff changeset
2 from tests import common
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 35
diff changeset
3 from hglib.util import b
33
d74a5891d9d1 client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
4
d74a5891d9d1 client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
5 class test_status(common.basetest):
d74a5891d9d1 client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
6 def test_empty(self):
34
f6e1d9a6e0cd client: change return value of status() to a list of (code, file path)
Idan Kamara <idankk86@gmail.com>
parents: 33
diff changeset
7 self.assertEquals(self.client.status(), [])
33
d74a5891d9d1 client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
8
d74a5891d9d1 client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
9 def test_one_of_each(self):
d74a5891d9d1 client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
10 self.append('.hgignore', 'ignored')
d74a5891d9d1 client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
11 self.append('ignored', 'a')
d74a5891d9d1 client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
12 self.append('clean', 'a')
d74a5891d9d1 client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
13 self.append('modified', 'a')
d74a5891d9d1 client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
14 self.append('removed', 'a')
d74a5891d9d1 client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
15 self.append('missing', 'a')
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 35
diff changeset
16 self.client.commit(b('first'), addremove=True)
33
d74a5891d9d1 client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
17 self.append('modified', 'a')
d74a5891d9d1 client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
18 self.append('added', 'a')
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 35
diff changeset
19 self.client.add([b('added')])
33
d74a5891d9d1 client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
20 os.remove('missing')
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 35
diff changeset
21 self.client.remove([b('removed')])
33
d74a5891d9d1 client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
22 self.append('untracked')
d74a5891d9d1 client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
23
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 35
diff changeset
24 l = [(b('M'), b('modified')),
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 35
diff changeset
25 (b('A'), b('added')),
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 35
diff changeset
26 (b('R'), b('removed')),
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 35
diff changeset
27 (b('C'), b('.hgignore')),
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 35
diff changeset
28 (b('C'), b('clean')),
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 35
diff changeset
29 (b('!'), b('missing')),
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 35
diff changeset
30 (b('?'), b('untracked')),
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 35
diff changeset
31 (b('I'), b('ignored'))]
33
d74a5891d9d1 client: add missing options to status
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
32
34
f6e1d9a6e0cd client: change return value of status() to a list of (code, file path)
Idan Kamara <idankk86@gmail.com>
parents: 33
diff changeset
33 st = self.client.status(all=True)
f6e1d9a6e0cd client: change return value of status() to a list of (code, file path)
Idan Kamara <idankk86@gmail.com>
parents: 33
diff changeset
34
f6e1d9a6e0cd client: change return value of status() to a list of (code, file path)
Idan Kamara <idankk86@gmail.com>
parents: 33
diff changeset
35 for i in l:
f6e1d9a6e0cd client: change return value of status() to a list of (code, file path)
Idan Kamara <idankk86@gmail.com>
parents: 33
diff changeset
36 self.assertTrue(i in st)
f6e1d9a6e0cd client: change return value of status() to a list of (code, file path)
Idan Kamara <idankk86@gmail.com>
parents: 33
diff changeset
37
f6e1d9a6e0cd client: change return value of status() to a list of (code, file path)
Idan Kamara <idankk86@gmail.com>
parents: 33
diff changeset
38 def test_copy(self):
f6e1d9a6e0cd client: change return value of status() to a list of (code, file path)
Idan Kamara <idankk86@gmail.com>
parents: 33
diff changeset
39 self.append('source', 'a')
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 35
diff changeset
40 self.client.commit(b('first'), addremove=True)
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 35
diff changeset
41 self.client.copy(b('source'), b('dest'))
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 35
diff changeset
42 l = [(b('A'), b('dest')), (b(' '), b('source'))]
34
f6e1d9a6e0cd client: change return value of status() to a list of (code, file path)
Idan Kamara <idankk86@gmail.com>
parents: 33
diff changeset
43 self.assertEquals(self.client.status(copies=True), l)
35
1e33bbea23e5 client: handle spaces correctly in status()
Idan Kamara <idankk86@gmail.com>
parents: 34
diff changeset
44
1e33bbea23e5 client: handle spaces correctly in status()
Idan Kamara <idankk86@gmail.com>
parents: 34
diff changeset
45 def test_copy_origin_space(self):
1e33bbea23e5 client: handle spaces correctly in status()
Idan Kamara <idankk86@gmail.com>
parents: 34
diff changeset
46 self.append('s ource', 'a')
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 35
diff changeset
47 self.client.commit(b('first'), addremove=True)
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 35
diff changeset
48 self.client.copy(b('s ource'), b('dest'))
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 35
diff changeset
49 l = [(b('A'), b('dest')), (b(' '), b('s ource'))]
35
1e33bbea23e5 client: handle spaces correctly in status()
Idan Kamara <idankk86@gmail.com>
parents: 34
diff changeset
50 self.assertEquals(self.client.status(copies=True), l)