Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
4d7140f3
authored
Apr 04, 2014
by
Oláh István Gergely
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: group tests
parent
1fb0eca9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
8 deletions
+59
-8
circle/dashboard/tests/test_views.py
+54
-1
circle/dashboard/views.py
+5
-7
No files found.
circle/dashboard/tests/test_views.py
View file @
4d7140f3
...
@@ -533,6 +533,9 @@ class GroupDetailTest(LoginMixin, TestCase):
...
@@ -533,6 +533,9 @@ class GroupDetailTest(LoginMixin, TestCase):
self
.
u2
=
User
.
objects
.
create
(
username
=
'user2'
,
is_staff
=
True
)
self
.
u2
=
User
.
objects
.
create
(
username
=
'user2'
,
is_staff
=
True
)
self
.
u2
.
set_password
(
'password'
)
self
.
u2
.
set_password
(
'password'
)
self
.
u2
.
save
()
self
.
u2
.
save
()
self
.
u3
=
User
.
objects
.
create
(
username
=
'user3'
)
self
.
u3
.
set_password
(
'password'
)
self
.
u3
.
save
()
self
.
us
=
User
.
objects
.
create
(
username
=
'superuser'
,
is_superuser
=
True
)
self
.
us
=
User
.
objects
.
create
(
username
=
'superuser'
,
is_superuser
=
True
)
self
.
us
.
set_password
(
'password'
)
self
.
us
.
set_password
(
'password'
)
self
.
us
.
save
()
self
.
us
.
save
()
...
@@ -567,6 +570,47 @@ class GroupDetailTest(LoginMixin, TestCase):
...
@@ -567,6 +570,47 @@ class GroupDetailTest(LoginMixin, TestCase):
response
=
c
.
get
(
'/dashboard/group/1/'
)
response
=
c
.
get
(
'/dashboard/group/1/'
)
self
.
assertEqual
(
response
.
status_code
,
302
)
self
.
assertEqual
(
response
.
status_code
,
302
)
def
test_superuser_group_page
(
self
):
c
=
Client
()
self
.
login
(
c
,
'superuser'
)
response
=
c
.
get
(
'/dashboard/group/1/'
)
self
.
assertEqual
(
response
.
status_code
,
200
)
def
test_acluser_group_page
(
self
):
Group
.
objects
.
get
(
pk
=
1
)
.
profile
.
set_user_level
(
self
.
u1
,
'operator'
)
c
=
Client
()
self
.
login
(
c
,
'user1'
)
response
=
c
.
get
(
'/dashboard/group/1/'
)
self
.
assertEqual
(
response
.
status_code
,
200
)
def
test_acluser2_group_page
(
self
):
Group
.
objects
.
get
(
pk
=
1
)
.
profile
.
set_user_level
(
self
.
u1
,
'owner'
)
c
=
Client
()
self
.
login
(
c
,
'user1'
)
response
=
c
.
get
(
'/dashboard/group/1/'
)
self
.
assertEqual
(
response
.
status_code
,
200
)
def
test_unpermitted_user_group_page
(
self
):
c
=
Client
()
self
.
login
(
c
,
'user1'
)
response
=
c
.
get
(
'/dashboard/group/1/'
)
self
.
assertEqual
(
response
.
status_code
,
403
)
def
test_user_in_userlist_group_page
(
self
):
Group
.
objects
.
get
(
pk
=
1
)
.
user_set
.
add
(
self
.
u1
)
c
=
Client
()
self
.
login
(
c
,
'user1'
)
response
=
c
.
get
(
'/dashboard/group/1/'
)
self
.
assertEqual
(
response
.
status_code
,
403
)
def
test_groupmember_group_page
(
self
):
# user1 is member of g1 - setUp
Group
.
objects
.
get
(
pk
=
1
)
.
profile
.
set_group_level
(
self
.
g1
,
'owner'
)
c
=
Client
()
self
.
login
(
c
,
'user1'
)
response
=
c
.
get
(
'/dashboard/group/1/'
)
self
.
assertEqual
(
response
.
status_code
,
200
)
def
test_permitted_group_delete
(
self
):
def
test_permitted_group_delete
(
self
):
num_of_groups
=
Group
.
objects
.
count
()
num_of_groups
=
Group
.
objects
.
count
()
c
=
Client
()
c
=
Client
()
...
@@ -578,11 +622,20 @@ class GroupDetailTest(LoginMixin, TestCase):
...
@@ -578,11 +622,20 @@ class GroupDetailTest(LoginMixin, TestCase):
def
test_unpermitted_group_delete
(
self
):
def
test_unpermitted_group_delete
(
self
):
num_of_groups
=
Group
.
objects
.
count
()
num_of_groups
=
Group
.
objects
.
count
()
c
=
Client
()
c
=
Client
()
self
.
login
(
c
,
'user
1
'
)
self
.
login
(
c
,
'user
3
'
)
response
=
c
.
post
(
'/dashboard/group/delete/1/'
)
response
=
c
.
post
(
'/dashboard/group/delete/1/'
)
self
.
assertEqual
(
response
.
status_code
,
302
)
self
.
assertEqual
(
response
.
status_code
,
302
)
self
.
assertEqual
(
Group
.
objects
.
count
(),
num_of_groups
)
self
.
assertEqual
(
Group
.
objects
.
count
(),
num_of_groups
)
def
test_acl_group_delete
(
self
):
num_of_groups
=
Group
.
objects
.
count
()
Group
.
objects
.
get
(
pk
=
1
)
.
profile
.
set_user_level
(
self
.
u1
,
'owner'
)
c
=
Client
()
self
.
login
(
c
,
'user1'
)
response
=
c
.
post
(
'/dashboard/group/delete/1/'
)
self
.
assertEqual
(
response
.
status_code
,
302
)
self
.
assertEqual
(
Group
.
objects
.
count
(),
num_of_groups
-
1
)
def
test_anon_group_delete
(
self
):
def
test_anon_group_delete
(
self
):
num_of_groups
=
Group
.
objects
.
count
()
num_of_groups
=
Group
.
objects
.
count
()
c
=
Client
()
c
=
Client
()
...
...
circle/dashboard/views.py
View file @
4d7140f3
...
@@ -1082,12 +1082,16 @@ class GroupRemoveAclGroupView(GroupRemoveUserView):
...
@@ -1082,12 +1082,16 @@ class GroupRemoveAclGroupView(GroupRemoveUserView):
return
_
(
"Acl group successfully removed from group!"
)
return
_
(
"Acl group successfully removed from group!"
)
class
GroupDelete
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
DeleteView
):
class
GroupDelete
(
CheckedDetailView
,
DeleteView
):
"""This stuff deletes the group.
"""This stuff deletes the group.
"""
"""
model
=
Group
model
=
Group
template_name
=
"dashboard/confirm/base-delete.html"
template_name
=
"dashboard/confirm/base-delete.html"
read_level
=
'operator'
def
get_has_level
(
self
):
return
self
.
object
.
profile
.
has_level
def
get_template_names
(
self
):
def
get_template_names
(
self
):
if
self
.
request
.
is_ajax
():
if
self
.
request
.
is_ajax
():
...
@@ -1095,12 +1099,6 @@ class GroupDelete(LoginRequiredMixin, SuperuserRequiredMixin, DeleteView):
...
@@ -1095,12 +1099,6 @@ class GroupDelete(LoginRequiredMixin, SuperuserRequiredMixin, DeleteView):
else
:
else
:
return
[
'dashboard/confirm/base-delete.html'
]
return
[
'dashboard/confirm/base-delete.html'
]
def
get_context_data
(
self
,
**
kwargs
):
# this is redundant now, but if we wanna add more to print
# we'll need this
context
=
super
(
GroupDelete
,
self
)
.
get_context_data
(
**
kwargs
)
return
context
# github.com/django/django/blob/master/django/views/generic/edit.py#L245
# github.com/django/django/blob/master/django/views/generic/edit.py#L245
def
delete
(
self
,
request
,
*
args
,
**
kwargs
):
def
delete
(
self
,
request
,
*
args
,
**
kwargs
):
object
=
self
.
get_object
()
object
=
self
.
get_object
()
...
...
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