Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
61edad50
authored
Jun 29, 2013
by
Dudás Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
school: tests for view
parent
218965c4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
3 deletions
+34
-3
school/tests/test_views.py
+34
-3
No files found.
school/tests/test_views.py
View file @
61edad50
...
@@ -130,7 +130,7 @@ class ViewTestCase(TestCase):
...
@@ -130,7 +130,7 @@ class ViewTestCase(TestCase):
self
.
assertEqual
(
200
,
resp
.
status_code
)
self
.
assertEqual
(
200
,
resp
.
status_code
)
def
test_group_show_with_nonexistent_groupid
(
self
):
def
test_group_show_with_nonexistent_group
_
id
(
self
):
self
.
login
()
self
.
login
()
gid
=
1337
# this should be the ID of a non-existent group,
gid
=
1337
# this should be the ID of a non-existent group,
Group
.
objects
.
filter
(
id
=
gid
)
.
delete
()
# so if it exists, delete it!
Group
.
objects
.
filter
(
id
=
gid
)
.
delete
()
# so if it exists, delete it!
...
@@ -183,7 +183,7 @@ class ViewTestCase(TestCase):
...
@@ -183,7 +183,7 @@ class ViewTestCase(TestCase):
self
.
assertIn
(
new_member
,
group
.
members
.
all
())
self
.
assertIn
(
new_member
,
group
.
members
.
all
())
def
test_group_ajax_add_new_member_with_nonexistent_groupid
(
self
):
def
test_group_ajax_add_new_member_with_nonexistent_group
_
id
(
self
):
self
.
login
()
self
.
login
()
gid
=
1337
# this should be the ID of a non-existent group,
gid
=
1337
# this should be the ID of a non-existent group,
Group
.
objects
.
filter
(
id
=
gid
)
.
delete
()
# so if it exists, delete it!
Group
.
objects
.
filter
(
id
=
gid
)
.
delete
()
# so if it exists, delete it!
...
@@ -241,7 +241,7 @@ class ViewTestCase(TestCase):
...
@@ -241,7 +241,7 @@ class ViewTestCase(TestCase):
self
.
assertNotIn
(
member
,
group
.
members
.
all
())
self
.
assertNotIn
(
member
,
group
.
members
.
all
())
def
test_group_ajax_remove_member_with_nonexistent_groupid
(
self
):
def
test_group_ajax_remove_member_with_nonexistent_group
_
id
(
self
):
self
.
login
()
self
.
login
()
gid
=
1337
# this should be the ID of a non-existent group,
gid
=
1337
# this should be the ID of a non-existent group,
Group
.
objects
.
filter
(
id
=
gid
)
.
delete
()
# so if it exists, delete it!
Group
.
objects
.
filter
(
id
=
gid
)
.
delete
()
# so if it exists, delete it!
...
@@ -281,3 +281,34 @@ class ViewTestCase(TestCase):
...
@@ -281,3 +281,34 @@ class ViewTestCase(TestCase):
with
self
.
assertRaises
(
Person
.
DoesNotExist
):
with
self
.
assertRaises
(
Person
.
DoesNotExist
):
self
.
client
.
post
(
url
,
data
)
self
.
client
.
post
(
url
,
data
)
self
.
assertFalse
(
Person
.
objects
.
filter
(
code
=
member_code
)
.
exists
())
self
.
assertFalse
(
Person
.
objects
.
filter
(
code
=
member_code
)
.
exists
())
def
test_group_ajax_delete
(
self
):
self
.
login
()
group
=
Group
.
objects
.
create
(
name
=
"mytestgroup"
,
semester
=
Semester
.
get_current
())
url
=
reverse
(
'school.views.group_ajax_delete'
)
data
=
{
'gid'
:
group
.
id
}
resp
=
self
.
client
.
post
(
url
,
data
)
self
.
assertEqual
(
200
,
resp
.
status_code
)
self
.
assertFalse
(
Group
.
objects
.
filter
(
id
=
group
.
id
)
.
exists
())
def
test_group_ajax_delete_without_gid
(
self
):
self
.
login
()
url
=
reverse
(
'school.views.group_ajax_delete'
)
data
=
{}
with
self
.
assertRaises
(
MultiValueDictKeyError
):
self
.
client
.
post
(
url
,
data
)
def
test_group_ajax_delete_with_nonexistent_group_id
(
self
):
self
.
login
()
gid
=
1337
# this should be the ID of a non-existent group,
Group
.
objects
.
filter
(
id
=
gid
)
.
delete
()
# so if it exists, delete it!
url
=
reverse
(
'school.views.group_ajax_delete'
)
data
=
{
'gid'
:
gid
}
resp
=
self
.
client
.
post
(
url
,
data
)
self
.
assertEqual
(
404
,
resp
.
status_code
)
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