Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
Commit
67121f2f
authored
Apr 10, 2014
by
Oláh István Gergely
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: add group deleting tests
parent
33c336cb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
85 additions
and
0 deletions
+85
-0
circle/dashboard/tests/test_views.py
+85
-0
No files found.
circle/dashboard/tests/test_views.py
View file @
67121f2f
...
...
@@ -624,6 +624,91 @@ class GroupCreateTest(LoginMixin, TestCase):
self
.
assertTrue
(
newgroup
.
profile
.
has_level
(
self
.
u0
,
'owner'
))
class
GroupDeleteTest
(
LoginMixin
,
TestCase
):
fixtures
=
[
'test-vm-fixture.json'
,
'node.json'
]
def
setUp
(
self
):
# u0 - user with creating group permissions
self
.
u0
=
User
.
objects
.
create
(
username
=
'user0'
)
self
.
u0
.
set_password
(
'password'
)
self
.
u0
.
save
()
permlist
=
Permission
.
objects
.
all
()
self
.
u0
.
user_permissions
.
add
(
filter
(
lambda
element
:
'group'
in
element
.
name
and
'delete'
in
element
.
name
,
permlist
)[
0
])
# u1 simple user without permissions
self
.
u1
=
User
.
objects
.
create
(
username
=
'user1'
)
self
.
u1
.
set_password
(
'password'
)
self
.
u1
.
save
()
self
.
us
=
User
.
objects
.
create
(
username
=
'superuser'
,
is_superuser
=
True
)
self
.
us
.
set_password
(
'password'
)
self
.
us
.
save
()
self
.
g1
=
Group
.
objects
.
create
(
name
=
'group1'
)
self
.
g1
.
profile
.
set_user_level
(
self
.
u0
,
'owner'
)
self
.
g1
.
save
()
def
tearDown
(
self
):
super
(
GroupDeleteTest
,
self
)
.
tearDown
()
self
.
g1
.
delete
()
self
.
u0
.
delete
()
self
.
u1
.
delete
()
self
.
us
.
delete
()
def
test_anon_group_page
(
self
):
c
=
Client
()
response
=
c
.
get
(
'/dashboard/group/delete/'
+
str
(
self
.
g1
.
pk
)
+
'/'
)
self
.
assertEqual
(
response
.
status_code
,
302
)
def
test_superuser_group_page
(
self
):
c
=
Client
()
self
.
login
(
c
,
'superuser'
)
response
=
c
.
get
(
'/dashboard/group/delete/'
+
str
(
self
.
g1
.
pk
)
+
'/'
)
self
.
assertEqual
(
response
.
status_code
,
200
)
def
test_permitted_group_page
(
self
):
c
=
Client
()
self
.
login
(
c
,
'user0'
)
response
=
c
.
get
(
'/dashboard/group/delete/'
+
str
(
self
.
g1
.
pk
)
+
'/'
)
self
.
assertEqual
(
response
.
status_code
,
200
)
def
test_unpermitted_group_page
(
self
):
c
=
Client
()
self
.
login
(
c
,
'user1'
)
response
=
c
.
get
(
'/dashboard/group/delete/'
+
str
(
self
.
g1
.
pk
)
+
'/'
)
self
.
assertEqual
(
response
.
status_code
,
403
)
def
test_anon_group_delete
(
self
):
c
=
Client
()
groupnum
=
Group
.
objects
.
count
()
response
=
c
.
post
(
'/dashboard/group/delete/'
+
str
(
self
.
g1
.
pk
)
+
'/'
)
self
.
assertEqual
(
response
.
status_code
,
302
)
self
.
assertEqual
(
Group
.
objects
.
count
(),
groupnum
)
def
test_unpermitted_group_delete
(
self
):
c
=
Client
()
groupnum
=
Group
.
objects
.
count
()
self
.
login
(
c
,
'user1'
)
response
=
c
.
post
(
'/dashboard/group/delete/'
+
str
(
self
.
g1
.
pk
)
+
'/'
)
self
.
assertEqual
(
response
.
status_code
,
403
)
self
.
assertEqual
(
Group
.
objects
.
count
(),
groupnum
)
def
test_permitted_group_delete
(
self
):
c
=
Client
()
groupnum
=
Group
.
objects
.
count
()
self
.
login
(
c
,
'user0'
)
response
=
c
.
post
(
'/dashboard/group/delete/'
+
str
(
self
.
g1
.
pk
)
+
'/'
)
self
.
assertEqual
(
response
.
status_code
,
302
)
self
.
assertEqual
(
Group
.
objects
.
count
(),
groupnum
-
1
)
def
test_superuser_group_delete
(
self
):
c
=
Client
()
groupnum
=
Group
.
objects
.
count
()
self
.
login
(
c
,
'superuser'
)
response
=
c
.
post
(
'/dashboard/group/delete/'
+
str
(
self
.
g1
.
pk
)
+
'/'
)
self
.
assertEqual
(
response
.
status_code
,
302
)
self
.
assertEqual
(
Group
.
objects
.
count
(),
groupnum
-
1
)
class
GroupDetailTest
(
LoginMixin
,
TestCase
):
fixtures
=
[
'test-vm-fixture.json'
,
'node.json'
]
...
...
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