annotate rhodecode/tests/models/test_repos_groups.py @ 3937:2f5e6f1c5bdc beta

Bumped mercurial version
author Marcin Kuzminski <marcin@python-works.com>
date Mon, 03 Jun 2013 14:18:07 +0200
parents 5067d6e826a5
children 5293d4bbb1ea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
1 import os
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
2 from sqlalchemy.exc import IntegrityError
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
3
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
4 from rhodecode.tests import *
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
5 from rhodecode.tests.fixture import Fixture
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
6
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
7 from rhodecode.model.repos_group import ReposGroupModel
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
8 from rhodecode.model.repo import RepoModel
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
9 from rhodecode.model.db import RepoGroup
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
10 from rhodecode.model.meta import Session
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
11
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
12
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
13 fixture = Fixture()
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
14
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
15
3459
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
16 def _update_group(id_, group_name, desc='desc', parent_id=None):
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
17 form_data = fixture._get_group_create_params(group_name=group_name,
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
18 group_desc=desc,
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
19 group_parent_id=parent_id)
3459
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
20 gr = ReposGroupModel().update(id_, form_data)
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
21 return gr
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
22
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
23
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
24 def _update_repo(name, **kwargs):
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
25 form_data = fixture._get_repo_create_params(**kwargs)
3459
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
26 if not 'repo_name' in kwargs:
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
27 form_data['repo_name'] = name
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
28 if not 'perms_new' in kwargs:
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
29 form_data['perms_new'] = []
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
30 if not 'perms_updates' in kwargs:
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
31 form_data['perms_updates'] = []
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
32 r = RepoModel().update(name, **form_data)
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
33 return r
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
34
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
35
3829
5067d6e826a5 created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents: 3647
diff changeset
36 class TestReposGroups(BaseTestCase):
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
37
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
38 def setUp(self):
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
39 self.g1 = fixture.create_group('test1', skip_if_exists=True)
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
40 self.g2 = fixture.create_group('test2', skip_if_exists=True)
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
41 self.g3 = fixture.create_group('test3', skip_if_exists=True)
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
42
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
43 def tearDown(self):
3459
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
44 Session.remove()
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
45
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
46 def __check_path(self, *path):
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
47 """
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
48 Checks the path for existance !
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
49 """
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
50 path = [TESTS_TMP_PATH] + list(path)
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
51 path = os.path.join(*path)
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
52 return os.path.isdir(path)
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
53
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
54 def _check_folders(self):
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
55 print os.listdir(TESTS_TMP_PATH)
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
56
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
57 def __delete_group(self, id_):
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
58 ReposGroupModel().delete(id_)
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
59
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
60 def test_create_group(self):
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
61 g = fixture.create_group('newGroup')
3459
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
62 Session().commit()
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
63 self.assertEqual(g.full_path, 'newGroup')
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
64
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
65 self.assertTrue(self.__check_path('newGroup'))
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
66
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
67 def test_create_same_name_group(self):
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
68 self.assertRaises(IntegrityError, lambda: fixture.create_group('newGroup'))
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
69 Session().rollback()
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
70
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
71 def test_same_subgroup(self):
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
72 sg1 = fixture.create_group('sub1', group_parent_id=self.g1.group_id)
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
73 self.assertEqual(sg1.parent_group, self.g1)
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
74 self.assertEqual(sg1.full_path, 'test1/sub1')
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
75 self.assertTrue(self.__check_path('test1', 'sub1'))
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
76
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
77 ssg1 = fixture.create_group('subsub1', group_parent_id=sg1.group_id)
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
78 self.assertEqual(ssg1.parent_group, sg1)
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
79 self.assertEqual(ssg1.full_path, 'test1/sub1/subsub1')
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
80 self.assertTrue(self.__check_path('test1', 'sub1', 'subsub1'))
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
81
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
82 def test_remove_group(self):
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
83 sg1 = fixture.create_group('deleteme')
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
84 self.__delete_group(sg1.group_id)
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
85
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
86 self.assertEqual(RepoGroup.get(sg1.group_id), None)
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
87 self.assertFalse(self.__check_path('deteteme'))
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
88
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
89 sg1 = fixture.create_group('deleteme', group_parent_id=self.g1.group_id)
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
90 self.__delete_group(sg1.group_id)
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
91
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
92 self.assertEqual(RepoGroup.get(sg1.group_id), None)
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
93 self.assertFalse(self.__check_path('test1', 'deteteme'))
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
94
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
95 def test_rename_single_group(self):
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
96 sg1 = fixture.create_group('initial')
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
97
3459
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
98 new_sg1 = _update_group(sg1.group_id, 'after')
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
99 self.assertTrue(self.__check_path('after'))
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
100 self.assertEqual(RepoGroup.get_by_group_name('initial'), None)
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
101
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
102 def test_update_group_parent(self):
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
103
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
104 sg1 = fixture.create_group('initial', group_parent_id=self.g1.group_id)
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
105
3459
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
106 new_sg1 = _update_group(sg1.group_id, 'after', parent_id=self.g1.group_id)
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
107 self.assertTrue(self.__check_path('test1', 'after'))
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
108 self.assertEqual(RepoGroup.get_by_group_name('test1/initial'), None)
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
109
3459
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
110 new_sg1 = _update_group(sg1.group_id, 'after', parent_id=self.g3.group_id)
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
111 self.assertTrue(self.__check_path('test3', 'after'))
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
112 self.assertEqual(RepoGroup.get_by_group_name('test3/initial'), None)
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
113
3459
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
114 new_sg1 = _update_group(sg1.group_id, 'hello')
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
115 self.assertTrue(self.__check_path('hello'))
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
116
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
117 self.assertEqual(RepoGroup.get_by_group_name('hello'), new_sg1)
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
118
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
119 def test_subgrouping_with_repo(self):
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
120
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
121 g1 = fixture.create_group('g1')
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
122 g2 = fixture.create_group('g2')
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
123 # create new repo
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
124 r = fixture.create_repo('john')
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
125
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
126 self.assertEqual(r.repo_name, 'john')
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
127 # put repo into group
3459
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
128 r = _update_repo('john', repo_group=g1.group_id)
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
129 Session().commit()
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
130 self.assertEqual(r.repo_name, 'g1/john')
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
131
3459
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
132 _update_group(g1.group_id, 'g1', parent_id=g2.group_id)
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
133 self.assertTrue(self.__check_path('g2', 'g1'))
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
134
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
135 # test repo
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
136 self.assertEqual(r.repo_name, RepoGroup.url_sep().join(['g2', 'g1',
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
137 r.just_name]))
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
138
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
139 def test_move_to_root(self):
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
140 g1 = fixture.create_group('t11')
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
141 g2 = fixture.create_group('t22', group_parent_id=g1.group_id)
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
142
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
143 self.assertEqual(g2.full_path, 't11/t22')
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
144 self.assertTrue(self.__check_path('t11', 't22'))
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
145
3459
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
146 g2 = _update_group(g2.group_id, 'g22', parent_id=None)
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
147 Session().commit()
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
148
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
149 self.assertEqual(g2.group_name, 'g22')
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
150 # we moved out group from t1 to '' so it's full path should be 'g2'
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
151 self.assertEqual(g2.full_path, 'g22')
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
152 self.assertFalse(self.__check_path('t11', 't22'))
2673
d5e42c00f3c1 white space cleanup
Marcin Kuzminski <marcin@python-works.com>
parents: 2527
diff changeset
153 self.assertTrue(self.__check_path('g22'))
3459
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
154
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
155 def test_rename_top_level_group_in_nested_setup(self):
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
156 g1 = fixture.create_group('L1')
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
157 g2 = fixture.create_group('L2', group_parent_id=g1.group_id)
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
158 g3 = fixture.create_group('L3', group_parent_id=g2.group_id)
3459
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
159
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
160 r = fixture.create_repo('L1/L2/L3/L3_REPO', repo_group=g3.group_id)
3459
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
161
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
162 ##rename L1 all groups should be now changed
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
163 _update_group(g1.group_id, 'L1_NEW')
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
164 Session().commit()
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
165 self.assertEqual(g1.full_path, 'L1_NEW')
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
166 self.assertEqual(g2.full_path, 'L1_NEW/L2')
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
167 self.assertEqual(g3.full_path, 'L1_NEW/L2/L3')
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
168 self.assertEqual(r.repo_name, 'L1_NEW/L2/L3/L3_REPO')
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
169
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
170 def test_change_parent_of_top_level_group_in_nested_setup(self):
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
171 g1 = fixture.create_group('R1')
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
172 g2 = fixture.create_group('R2', group_parent_id=g1.group_id)
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
173 g3 = fixture.create_group('R3', group_parent_id=g2.group_id)
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
174 g4 = fixture.create_group('R1_NEW')
3459
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
175
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
176 r = fixture.create_repo('R1/R2/R3/R3_REPO', repo_group=g3.group_id)
3459
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
177 ##rename L1 all groups should be now changed
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
178 _update_group(g1.group_id, 'R1', parent_id=g4.group_id)
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
179 Session().commit()
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
180 self.assertEqual(g1.full_path, 'R1_NEW/R1')
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
181 self.assertEqual(g2.full_path, 'R1_NEW/R1/R2')
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
182 self.assertEqual(g3.full_path, 'R1_NEW/R1/R2/R3')
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
183 self.assertEqual(r.repo_name, 'R1_NEW/R1/R2/R3/R3_REPO')
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
184
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
185 def test_change_parent_of_top_level_group_in_nested_setup_with_rename(self):
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
186 g1 = fixture.create_group('X1')
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
187 g2 = fixture.create_group('X2', group_parent_id=g1.group_id)
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
188 g3 = fixture.create_group('X3', group_parent_id=g2.group_id)
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
189 g4 = fixture.create_group('X1_NEW')
3459
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
190
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
191 r = fixture.create_repo('X1/X2/X3/X3_REPO', repo_group=g3.group_id)
3459
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
192
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
193 ##rename L1 all groups should be now changed
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
194 _update_group(g1.group_id, 'X1_PRIM', parent_id=g4.group_id)
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
195 Session().commit()
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
196 self.assertEqual(g1.full_path, 'X1_NEW/X1_PRIM')
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
197 self.assertEqual(g2.full_path, 'X1_NEW/X1_PRIM/X2')
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
198 self.assertEqual(g3.full_path, 'X1_NEW/X1_PRIM/X2/X3')
94f251fda314 fixed issue with renaming repos group together with changing parents with multiple nested trees
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
199 self.assertEqual(r.repo_name, 'X1_NEW/X1_PRIM/X2/X3/X3_REPO')