annotate rhodecode/tests/models/test_repos_groups.py @ 3647:8a86836fad64 beta

more usage of fixture tools in tests
author Marcin Kuzminski <marcin@python-works.com>
date Mon, 01 Apr 2013 23:45:25 +0200
parents 94f251fda314
children 3563bb7b4b82 5067d6e826a5
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
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
2 import unittest
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
3 from sqlalchemy.exc import IntegrityError
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
4
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
5 from rhodecode.tests import *
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
6 from rhodecode.tests.fixture import Fixture
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
7
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
8 from rhodecode.model.repos_group import ReposGroupModel
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
9 from rhodecode.model.repo import RepoModel
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
10 from rhodecode.model.db import RepoGroup
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
11 from rhodecode.model.meta import Session
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
12
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
13
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
14 fixture = Fixture()
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
15
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
16
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
17 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
18 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
19 group_desc=desc,
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
20 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
21 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
22 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
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
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
25 def _update_repo(name, **kwargs):
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
26 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
27 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
28 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
29 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
30 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
31 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
32 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
33 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
34 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
35
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
36
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
37 class TestReposGroups(unittest.TestCase):
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
38
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
39 def setUp(self):
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
40 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
41 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
42 self.g3 = fixture.create_group('test3', skip_if_exists=True)
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
43
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
44 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
45 Session.remove()
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
46
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
47 def __check_path(self, *path):
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
48 """
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
49 Checks the path for existance !
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
50 """
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
51 path = [TESTS_TMP_PATH] + list(path)
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
52 path = os.path.join(*path)
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
53 return os.path.isdir(path)
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
54
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
55 def _check_folders(self):
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
56 print os.listdir(TESTS_TMP_PATH)
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
57
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
58 def __delete_group(self, id_):
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
59 ReposGroupModel().delete(id_)
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
60
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
61 def test_create_group(self):
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
62 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
63 Session().commit()
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
64 self.assertEqual(g.full_path, 'newGroup')
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
65
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
66 self.assertTrue(self.__check_path('newGroup'))
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
67
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
68 def test_create_same_name_group(self):
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
69 self.assertRaises(IntegrityError, lambda: fixture.create_group('newGroup'))
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
70 Session().rollback()
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
71
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
72 def test_same_subgroup(self):
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
73 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
74 self.assertEqual(sg1.parent_group, self.g1)
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
75 self.assertEqual(sg1.full_path, 'test1/sub1')
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
76 self.assertTrue(self.__check_path('test1', 'sub1'))
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
77
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
78 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
79 self.assertEqual(ssg1.parent_group, sg1)
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
80 self.assertEqual(ssg1.full_path, 'test1/sub1/subsub1')
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
81 self.assertTrue(self.__check_path('test1', 'sub1', 'subsub1'))
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
82
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
83 def test_remove_group(self):
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
84 sg1 = fixture.create_group('deleteme')
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
85 self.__delete_group(sg1.group_id)
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
86
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
87 self.assertEqual(RepoGroup.get(sg1.group_id), None)
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
88 self.assertFalse(self.__check_path('deteteme'))
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
89
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
90 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
91 self.__delete_group(sg1.group_id)
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
92
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
93 self.assertEqual(RepoGroup.get(sg1.group_id), None)
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
94 self.assertFalse(self.__check_path('test1', 'deteteme'))
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
95
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
96 def test_rename_single_group(self):
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
97 sg1 = fixture.create_group('initial')
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
98
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
99 new_sg1 = _update_group(sg1.group_id, 'after')
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
100 self.assertTrue(self.__check_path('after'))
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
101 self.assertEqual(RepoGroup.get_by_group_name('initial'), None)
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
102
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
103 def test_update_group_parent(self):
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
104
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
105 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
106
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
107 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
108 self.assertTrue(self.__check_path('test1', 'after'))
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
109 self.assertEqual(RepoGroup.get_by_group_name('test1/initial'), None)
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
110
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
111 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
112 self.assertTrue(self.__check_path('test3', 'after'))
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
113 self.assertEqual(RepoGroup.get_by_group_name('test3/initial'), None)
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
114
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
115 new_sg1 = _update_group(sg1.group_id, 'hello')
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
116 self.assertTrue(self.__check_path('hello'))
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
117
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
118 self.assertEqual(RepoGroup.get_by_group_name('hello'), new_sg1)
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
119
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
120 def test_subgrouping_with_repo(self):
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
121
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
122 g1 = fixture.create_group('g1')
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
123 g2 = fixture.create_group('g2')
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
124 # create new repo
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
125 r = fixture.create_repo('john')
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
126
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
127 self.assertEqual(r.repo_name, 'john')
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
128 # 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
129 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
130 Session().commit()
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
131 self.assertEqual(r.repo_name, 'g1/john')
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
132
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
133 _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
134 self.assertTrue(self.__check_path('g2', 'g1'))
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
135
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
136 # test repo
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
137 self.assertEqual(r.repo_name, RepoGroup.url_sep().join(['g2', 'g1',
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
138 r.just_name]))
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
139
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
140 def test_move_to_root(self):
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
141 g1 = fixture.create_group('t11')
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
142 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
143
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
144 self.assertEqual(g2.full_path, 't11/t22')
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
145 self.assertTrue(self.__check_path('t11', 't22'))
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
146
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
147 g2 = _update_group(g2.group_id, 'g22', parent_id=None)
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
148 Session().commit()
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
149
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
150 self.assertEqual(g2.group_name, 'g22')
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
151 # 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
152 self.assertEqual(g2.full_path, 'g22')
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
153 self.assertFalse(self.__check_path('t11', 't22'))
2673
d5e42c00f3c1 white space cleanup
Marcin Kuzminski <marcin@python-works.com>
parents: 2527
diff changeset
154 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
155
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
156 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
157 g1 = fixture.create_group('L1')
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
158 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
159 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
160
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
161 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
162
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 ##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
164 _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
165 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
166 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
167 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
168 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
169 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
170
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
171 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
172 g1 = fixture.create_group('R1')
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
173 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
174 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
175 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
176
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
177 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
178 ##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
179 _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
180 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
181 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
182 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
183 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
184 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
185
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
186 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
187 g1 = fixture.create_group('X1')
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
188 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
189 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
190 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
191
3647
8a86836fad64 more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
192 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
193
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 ##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
195 _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
196 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
197 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
198 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
199 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
200 self.assertEqual(r.repo_name, 'X1_NEW/X1_PRIM/X2/X3/X3_REPO')