Mercurial > python-hglib
diff tests/test_phase.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-phase.py@c1b966866ed7 |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test_phase.py Wed Mar 08 17:04:58 2023 +0100 @@ -0,0 +1,47 @@ +from tests import common +import hglib +from hglib.util import b + +class test_phase(common.basetest): + """test the different ways to use the phase command""" + def test_phase(self): + """test getting data from a single changeset""" + self.append('a', 'a') + rev, node0 = self.client.commit(b('first'), addremove=True) + self.assertEqual([(0, b('draft'))], self.client.phase(node0)) + ctx = self.client[rev] + self.assertEqual(b('draft'), ctx.phase()) + + def test_phase_public(self): + """test phase change from draft to public""" + self.append('a', 'a') + rev, node0 = self.client.commit(b('first'), addremove=True) + self.client.phase(node0, public=True) + self.assertEqual([(0, b('public'))], self.client.phase(node0)) + ctx = self.client[rev] + self.assertEqual(b('public'), ctx.phase()) + + def test_phase_secret(self): + """test phase change from draft to secret""" + self.append('a', 'a') + rev, node0 = self.client.commit(b('first'), addremove=True) + self.assertRaises(hglib.error.CommandError, + self.client.phase, node0, secret=True) + self.client.phase(node0, secret=True, force=True) + self.assertEqual([(0, b('secret'))], self.client.phase(node0)) + ctx = self.client[rev] + self.assertEqual(b('secret'), ctx.phase()) + + + def test_phase_multiple(self): + """test phase changes and show the phases of the different changesets""" + self.append('a', 'a') + rev, node0 = self.client.commit(b('a'), addremove=True) + self.client.phase(node0, public=True) + self.append('b', 'b') + rev, node1 = self.client.commit(b('b'), addremove=True) + self.append('c', 'c') + rev, node2 = self.client.commit(b('c'), addremove=True) + self.client.phase(node2, secret=True, force=True) + self.assertEqual([(0, b('public')), (2, b('secret')), (1, b('draft'))], + self.client.phase([node0, node2, node1]))