Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
5f0eb5e1
Commit
5f0eb5e1
authored
Apr 25, 2016
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup user setup in API tests
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
acf5e120
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
10 deletions
+14
-10
weblate/api/tests.py
weblate/api/tests.py
+14
-10
No files found.
weblate/api/tests.py
View file @
5f0eb5e1
...
...
@@ -47,6 +47,13 @@ class APIBaseTest(APITestCase, RepoTestMixin):
'slug'
:
'test'
}
self
.
tearDown
()
self
.
user
=
User
.
objects
.
create_user
(
'apitest'
,
'apitest@example.org'
,
'x'
,
)
group
=
Group
.
objects
.
get
(
name
=
'Users'
)
self
.
user
.
groups
.
add
(
group
)
def
tearDown
(
self
):
cache
.
delete
(
get_acl_cache_key
(
None
))
...
...
@@ -65,16 +72,13 @@ class APIBaseTest(APITestCase, RepoTestMixin):
)
def
authenticate
(
self
,
superuser
=
False
):
user
,
dummy
=
User
.
objects
.
get_or_create
(
username
=
'test'
)
group
=
Group
.
objects
.
get
(
name
=
'Users'
)
user
.
groups
.
add
(
group
)
user
.
is_superuser
=
superuser
user
.
save
()
cache
.
delete
(
get_acl_cache_key
(
user
))
if
self
.
user
.
is_superuser
!=
superuser
:
self
.
user
.
is_superuser
=
superuser
self
.
user
.
save
()
cache
.
delete
(
get_acl_cache_key
(
self
.
user
))
self
.
client
.
credentials
(
HTTP_AUTHORIZATION
=
'Token '
+
user
.
auth_token
.
key
HTTP_AUTHORIZATION
=
'Token '
+
self
.
user
.
auth_token
.
key
)
return
user
def
do_request
(
self
,
name
,
kwargs
,
data
=
None
,
code
=
200
,
superuser
=
False
,
get
=
True
,
request
=
None
):
...
...
@@ -376,9 +380,9 @@ class TranslationAPITest(APIBaseTest):
)
def
test_upload_denied
(
self
):
user
=
self
.
authenticate
()
self
.
authenticate
()
# Remove all permissions
user
.
groups
.
all
()[
0
].
permissions
.
clear
()
self
.
user
.
groups
.
all
()[
0
].
permissions
.
clear
()
response
=
self
.
client
.
put
(
reverse
(
'api:translation-file'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment