##// END OF EJS Templates
tests: api add_user tests for personal groups
marcink -
r1096:aaf802d5 default
parent child Browse files
Show More
@@ -28,6 +28,7 b' from rhodecode.tests import ('
28 28 from rhodecode.api.tests.utils import (
29 29 build_data, api_call, assert_ok, assert_error, jsonify, crash)
30 30 from rhodecode.tests.fixture import Fixture
31 from rhodecode.model.db import RepoGroup
31 32
32 33
33 34 # TODO: mikhail: remove fixture from here
@@ -145,6 +146,36 b' class TestCreateUser(object):'
145 146 finally:
146 147 fixture.destroy_user(usr.user_id)
147 148
149 def test_api_create_user_with_personal_repo_group(self):
150 username = 'test_new_api_user_personal_group'
151 email = username + "@foo.com"
152
153 id_, params = build_data(
154 self.apikey, 'create_user',
155 username=username,
156 email=email, extern_name='rhodecode',
157 create_personal_repo_group=True)
158 response = api_call(self.app, params)
159
160 usr = UserModel().get_by_username(username)
161 ret = {
162 'msg': 'created new user `%s`' % (username,),
163 'user': jsonify(usr.get_api_data(include_secrets=True)),
164 }
165
166 personal_group = RepoGroup.get_by_group_name(username)
167 assert personal_group
168 assert personal_group.personal == True
169 assert personal_group.user.username == username
170
171 try:
172 expected = ret
173 assert_ok(id_, expected, given=response.body)
174 finally:
175 fixture.destroy_repo_group(username)
176 fixture.destroy_user(usr.user_id)
177
178
148 179 @mock.patch.object(UserModel, 'create_or_update', crash)
149 180 def test_api_create_user_when_exception_happened(self):
150 181
General Comments 0
You need to be logged in to leave comments. Login now