Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-wiki
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
django-wiki
Commits
1bba4ecc
Commit
1bba4ecc
authored
Apr 04, 2013
by
Hynek Cernoch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added recursion test for the current bug in preview.
parent
c3bbc377
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
12 deletions
+36
-12
wiki/tests.py
+36
-12
No files found.
wiki/tests.py
View file @
1bba4ecc
"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".
from
django.contrib.auth.models
import
User
from
django.core.urlresolvers
import
reverse
from
django.test
import
TestCase
from
django.test.client
import
Client
Replace this with more appropriate tests for your application.
"""
class
WebClientTest
(
TestCase
):
def
test_preview_save
(
self
):
"""Test the basic operations (create, preview and save the article) by web client."""
c
=
Client
()
User
.
objects
.
create_superuser
(
'admin'
,
'nobody@example.com'
,
'secret'
)
c
.
login
(
username
=
'admin'
,
password
=
'secret'
)
response
=
c
.
get
(
reverse
(
'wiki:root'
))
# url '/'
self
.
assertRedirects
(
response
,
reverse
(
'wiki:root_create'
))
# url '/create-root/'
from
django.test
import
TestCase
# test create the root article
response
=
c
.
post
(
reverse
(
'wiki:root_create'
),
{
'content'
:
'test heading h1
\n
====
\n
'
,
'save_changes'
:
'Create root...'
,
'title'
:
'wiki test'
})
self
.
assertRedirects
(
response
,
reverse
(
'wiki:root'
))
response
=
c
.
get
(
reverse
(
'wiki:root'
))
self
.
assertContains
(
response
,
'test heading h1</h1>'
)
# test preview
form_data
=
{
'content'
:
'The modified text'
,
'current_revision'
:
'1'
,
'preview'
:
'1'
,
'save'
:
'1'
,
'summary'
:
'any summary'
,
'title'
:
'wiki test'
}
response
=
c
.
post
(
reverse
(
'wiki:preview'
,
kwargs
=
{
'path'
:
''
}),
form_data
)
# url: '/_preview/'
self
.
assertContains
(
response
,
'The modified text'
)
# preview failed
class
SimpleTest
(
TestCase
):
def
test_basic_addition
(
self
):
"""
Tests that 1 + 1 always equals 2.
"""
self
.
assertEqual
(
1
+
1
,
2
)
# test save
response
=
c
.
post
(
reverse
(
'wiki:edit'
,
kwargs
=
{
'path'
:
''
}),
form_data
)
message
=
c
.
cookies
[
'messages'
]
.
value
if
'messages'
in
c
.
cookies
else
None
self
.
assertRedirects
(
response
,
reverse
(
'wiki:root'
))
response
=
c
.
get
(
reverse
(
'wiki:root'
))
self
.
assertContains
(
response
,
'The modified text'
)
# test messages
self
.
assertTrue
(
'succesfully added'
in
message
)
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