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
159025bc
Commit
159025bc
authored
Apr 04, 2013
by
benjaoming
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #139 from hynekcer/master
Fixed broken Preview (displaying the old article content)
parents
c3bbc377
634c3c0a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
14 deletions
+37
-14
wiki/forms.py
+1
-2
wiki/tests.py
+36
-12
No files found.
wiki/forms.py
View file @
159025bc
...
@@ -119,8 +119,7 @@ class EditForm(forms.Form, SpamProtectionMixin):
...
@@ -119,8 +119,7 @@ class EditForm(forms.Form, SpamProtectionMixin):
# is reset to match the actual current revision.
# is reset to match the actual current revision.
data
=
None
data
=
None
if
len
(
args
)
>
0
:
if
len
(
args
)
>
0
:
args
=
list
(
args
)
data
=
args
[
0
]
data
=
args
.
pop
(
0
)
if
not
data
:
if
not
data
:
data
=
kwargs
.
get
(
'data'
,
None
)
data
=
kwargs
.
get
(
'data'
,
None
)
if
data
:
if
data
:
...
...
wiki/tests.py
View file @
159025bc
"""
from
django.contrib.auth.models
import
User
This file demonstrates writing tests using the unittest module. These will pass
from
django.core.urlresolvers
import
reverse
when you run "manage.py test".
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
):
# test save
def
test_basic_addition
(
self
):
response
=
c
.
post
(
reverse
(
'wiki:edit'
,
kwargs
=
{
'path'
:
''
}),
form_data
)
"""
message
=
c
.
cookies
[
'messages'
]
.
value
if
'messages'
in
c
.
cookies
else
None
Tests that 1 + 1 always equals 2.
self
.
assertRedirects
(
response
,
reverse
(
'wiki:root'
))
"""
response
=
c
.
get
(
reverse
(
'wiki:root'
))
self
.
assertEqual
(
1
+
1
,
2
)
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