##// END OF EJS Templates
spelling: default
timeless@gmail.com -
r5796:4a6cb94a default
parent child Browse files
Show More
@@ -1,97 +1,97 b''
1 1
2 2 import datetime
3 3 from kallithea.lib.vcs.nodes import FileNode
4 4 from kallithea.lib.vcs.utils.compat import unittest
5 5 from kallithea.tests.vcs.base import _BackendTestMixin
6 6 from kallithea.tests.vcs.conf import SCM_TESTS
7 7
8 8
9 9 class WorkdirTestCaseMixin(_BackendTestMixin):
10 10
11 11 @classmethod
12 12 def _get_commits(cls):
13 13 commits = [
14 14 {
15 15 'message': u'Initial commit',
16 16 'author': u'Joe Doe <joe.doe@example.com>',
17 17 'date': datetime.datetime(2010, 1, 1, 20),
18 18 'added': [
19 19 FileNode('foobar', content='Foobar'),
20 20 FileNode('foobar2', content='Foobar II'),
21 21 FileNode('foo/bar/baz', content='baz here!'),
22 22 ],
23 23 },
24 24 {
25 25 'message': u'Changes...',
26 26 'author': u'Jane Doe <jane.doe@example.com>',
27 27 'date': datetime.datetime(2010, 1, 1, 21),
28 28 'added': [
29 29 FileNode('some/new.txt', content='news...'),
30 30 ],
31 31 'changed': [
32 32 FileNode('foobar', 'Foobar I'),
33 33 ],
34 34 'removed': [],
35 35 },
36 36 ]
37 37 return commits
38 38
39 39 def test_get_branch_for_default_branch(self):
40 40 self.assertEqual(self.repo.workdir.get_branch(),
41 41 self.repo.DEFAULT_BRANCH_NAME)
42 42
43 43 def test_get_branch_after_adding_one(self):
44 44 self.imc.add(FileNode('docs/index.txt',
45 45 content='Documentation\n'))
46 46 self.imc.commit(
47 47 message=u'New branch: foobar',
48 48 author=u'joe',
49 49 branch='foobar',
50 50 )
51 51 self.assertEqual(self.repo.workdir.get_branch(), self.default_branch)
52 52
53 53 def test_get_changeset(self):
54 54 old_head = self.repo.get_changeset()
55 55 self.imc.add(FileNode('docs/index.txt',
56 56 content='Documentation\n'))
57 57 head = self.imc.commit(
58 58 message=u'New branch: foobar',
59 59 author=u'joe',
60 60 branch='foobar',
61 61 )
62 62 self.assertEqual(self.repo.workdir.get_branch(), self.default_branch)
63 63 self.repo.workdir.checkout_branch('foobar')
64 64 self.assertEqual(self.repo.workdir.get_changeset(), head)
65 65
66 # Make sure that old head is still there after update to defualt branch
66 # Make sure that old head is still there after update to default branch
67 67 self.repo.workdir.checkout_branch(self.default_branch)
68 68 self.assertEqual(self.repo.workdir.get_changeset(), old_head)
69 69
70 70 def test_checkout_branch(self):
71 71 from kallithea.lib.vcs.exceptions import BranchDoesNotExistError
72 72 # first, 'foobranch' does not exist.
73 73 self.assertRaises(BranchDoesNotExistError, self.repo.workdir.checkout_branch,
74 74 branch='foobranch')
75 75 # create new branch 'foobranch'.
76 76 self.imc.add(FileNode('file1', content='blah'))
77 77 self.imc.commit(message=u'asd', author=u'john', branch='foobranch')
78 78 # go back to the default branch
79 79 self.repo.workdir.checkout_branch()
80 80 self.assertEqual(self.repo.workdir.get_branch(), self.backend_class.DEFAULT_BRANCH_NAME)
81 81 # checkout 'foobranch'
82 82 self.repo.workdir.checkout_branch('foobranch')
83 83 self.assertEqual(self.repo.workdir.get_branch(), 'foobranch')
84 84
85 85
86 86 # For each backend create test case class
87 87 for alias in SCM_TESTS:
88 88 attrs = {
89 89 'backend_alias': alias,
90 90 }
91 91 cls_name = ''.join(('%s branch test' % alias).title().split())
92 92 bases = (WorkdirTestCaseMixin, unittest.TestCase)
93 93 globals()[cls_name] = type(cls_name, bases, attrs)
94 94
95 95
96 96 if __name__ == '__main__':
97 97 unittest.main()
General Comments 0
You need to be logged in to leave comments. Login now