diff tests/test-branch.py @ 11:0549d00a617d

client: add missing options to branch() and add some more tests
author Idan Kamara <idankk86@gmail.com>
date Wed, 10 Aug 2011 00:21:05 +0300
parents eac8be119d81
children c2a9b716cd80
line wrap: on
line diff
--- a/tests/test-branch.py	Tue Aug 09 23:24:40 2011 +0300
+++ b/tests/test-branch.py	Wed Aug 10 00:21:05 2011 +0300
@@ -2,10 +2,38 @@
 import hglib
 
 class test_branch(common.basetest):
+    def test_empty(self):
+        self.assertEquals(self.client.branch(), 'default')
+
     def test_basic(self):
-        self.assertEquals(self.client.branch(), 'default')
+        self.assertEquals(self.client.branch('foo'), 'foo')
         self.append('a', 'a')
         rev = self.client.commit('first', addremove=True)
-        branches = self.client.branches()
+
+        self.assertEquals(rev.branch, 'foo')
+        self.assertEquals(self.client.branches()[rev.branch], rev)
+
+    def test_reset_with_name(self):
+        self.assertRaises(ValueError, self.client.branch, 'foo', clean=True)
+
+    def test_reset(self):
+        self.client.branch('foo')
+        self.assertEquals(self.client.branch(clean=True), 'default')
 
-        self.assertEquals(rev, branches[rev.branch])
+    def test_exists(self):
+        self.append('a', 'a')
+        self.client.commit('first', addremove=True)
+        self.client.branch('foo')
+        self.append('a', 'a')
+        self.client.commit('second')
+        self.assertRaises(hglib.error.CommandError, self.client.branch, 'default')
+
+    def test_force(self):
+        self.append('a', 'a')
+        self.client.commit('first', addremove=True)
+        self.client.branch('foo')
+        self.append('a', 'a')
+        self.client.commit('second')
+
+        self.assertRaises(hglib.error.CommandError, self.client.branch, 'default')
+        self.assertEquals(self.client.branch('default', force=True), 'default')