Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Jelle van der Waa
Archweb
Commits
eeb07d7b
Commit
eeb07d7b
authored
Aug 12, 2018
by
Jelle van der Waa
🚧
Browse files
todolists: test delete/edit/add
parent
d1e272d1
Changes
1
Hide whitespace changes
Inline
Side-by-side
todolists/tests/test_views.py
View file @
eeb07d7b
...
...
@@ -2,7 +2,7 @@
from
django.test
import
TestCase
from
todolists.models
import
Todolist
from
todolists.models
import
Todolist
,
TodolistPackage
class
TestTodolist
(
TestCase
):
...
...
@@ -33,3 +33,71 @@ def test_todolist_json(self):
self
.
assertEqual
(
response
.
status_code
,
200
)
data
=
response
.
json
()
self
.
assertEqual
(
data
[
'name'
],
self
.
todolist
.
name
)
class
TestTodolistAdmin
(
TestCase
):
fixtures
=
[
'main/fixtures/arches.json'
,
'main/fixtures/repos.json'
,
'main/fixtures/package.json'
]
def
setUp
(
self
):
password
=
'test'
self
.
user
=
User
.
objects
.
create_superuser
(
"admin"
,
"admin@archlinux.org"
,
password
)
self
.
client
.
post
(
'/login/'
,
{
'username'
:
self
.
user
.
username
,
'password'
:
password
})
def
tearDown
(
self
):
Todolist
.
objects
.
all
().
delete
()
self
.
user
.
delete
()
def
create_todo
(
self
):
return
self
.
client
.
post
(
'/todo/add/'
,
{
'name'
:
'Foo rebuild'
,
'description'
:
'The Foo Rebuild, please read the instructions'
,
'raw'
:
'linux'
,
})
def
test_create_todolist
(
self
):
response
=
self
.
create_todo
()
self
.
assertEqual
(
response
.
status_code
,
302
)
self
.
assertEqual
(
len
(
Todolist
.
objects
.
all
()),
1
)
def
test_flag_pkg
(
self
):
response
=
self
.
create_todo
()
self
.
assertEqual
(
response
.
status_code
,
302
)
todolist
=
Todolist
.
objects
.
first
()
package
=
todolist
.
packages
().
first
()
self
.
assertEqual
(
package
.
status
,
TodolistPackage
.
INCOMPLETE
)
response
=
self
.
client
.
get
(
'/todo/{}/flag/{}/'
.
format
(
todolist
.
slug
,
package
.
id
))
self
.
assertEqual
(
response
.
status_code
,
302
)
package
=
todolist
.
packages
().
first
()
self
.
assertEqual
(
package
.
status
,
TodolistPackage
.
COMPLETE
)
def
test_edit
(
self
):
response
=
self
.
create_todo
()
self
.
assertEqual
(
response
.
status_code
,
302
)
todolist
=
Todolist
.
objects
.
first
()
self
.
assertEqual
(
len
(
todolist
.
packages
().
all
()),
1
)
response
=
self
.
client
.
post
(
'/todo/{}/edit/'
.
format
(
todolist
.
slug
),
{
'name'
:
'Foo rebuild'
,
'description'
:
'The Foo Rebuild, please read the instructions'
,
'raw'
:
'linux
\n
glibc'
,
})
self
.
assertEqual
(
response
.
status_code
,
302
)
todolist
=
Todolist
.
objects
.
first
()
self
.
assertEqual
(
len
(
todolist
.
packages
().
all
()),
2
)
def
test_delete
(
self
):
response
=
self
.
create_todo
()
self
.
assertEqual
(
response
.
status_code
,
302
)
todolist
=
Todolist
.
objects
.
first
()
response
=
self
.
client
.
post
(
'/todo/{}/delete'
.
format
(
todolist
.
slug
))
self
.
assertEqual
(
response
.
status_code
,
301
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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