Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
AE UTBM
Sith
Commits
6cc78514
Commit
6cc78514
authored
Dec 07, 2015
by
Skia
Browse files
Repair all tests and update requirements.txt
parent
185b35ed
Changes
3
Hide whitespace changes
Inline
Side-by-side
core/tests.py
View file @
6cc78514
...
...
@@ -2,7 +2,7 @@ from django.test import SimpleTestCase, Client, TestCase
from
django.core.urlresolvers
import
reverse
from
django.contrib.auth.models
import
Group
from
core.models
import
User
from
core.models
import
User
,
Group
#from core.views.forms import RegisteringForm, LoginForm
"""
...
...
@@ -167,6 +167,13 @@ class PageHandlingTest(TestCase):
def
setUp
(
self
):
try
:
Group
.
objects
.
create
(
name
=
"root"
)
u
=
User
(
username
=
'root'
,
last_name
=
""
,
first_name
=
"Bibou"
,
email
=
"ae.info@utbm.fr"
,
date_of_birth
=
"1942-06-12T00:00:00+01:00"
,
is_superuser
=
True
,
is_staff
=
True
)
u
.
set_password
(
"plop"
)
u
.
save
()
self
.
client
.
login
(
username
=
'root'
,
password
=
'plop'
)
except
:
pass
...
...
@@ -174,56 +181,54 @@ class PageHandlingTest(TestCase):
"""
Should create a page correctly
"""
c
=
Client
()
response
=
c
.
post
(
reverse
(
'core:page_prop'
,
kwargs
=
{
'page_name'
:
'guy'
}),
{
'parent'
:
'
'
,
'name
'
:
'
guy
'
,
'owner_group'
:
'1'
,
})
self
.
client
.
post
(
reverse
(
'core:page_prop'
,
kwargs
=
{
'page_name'
:
'guy'
}),
{
'parent'
:
''
,
'name'
:
'guy
'
,
'owner_group
'
:
'
1
'
,
})
response
=
self
.
client
.
get
(
reverse
(
'core:page'
,
kwargs
=
{
'page_name'
:
'guy'
})
)
self
.
assertTrue
(
response
.
status_code
==
200
)
self
.
assertTrue
(
'PAGE_SAVED'
in
str
(
response
.
content
))
self
.
assertTrue
(
"<strong>guy</strong>"
in
str
(
response
.
content
))
def
test_create_child_page_ok
(
self
):
"""
Should create a page correctly
"""
c
=
Client
()
c
.
post
(
reverse
(
'core:page_prop'
,
kwargs
=
{
'page_name'
:
'guy'
}),
{
'parent'
:
''
,
self
.
client
.
post
(
reverse
(
'core:page_prop'
,
kwargs
=
{
'page_name'
:
'guy'
}),
{
'parent'
:
''
,
'name'
:
'guy'
,
'owner_group'
:
1
,
'owner_group'
:
'1'
,
})
response
=
c
.
post
(
reverse
(
'core:page_prop'
,
kwargs
=
{
'page_name'
:
'guy/bibou'
}),
{
'parent'
:
'1'
,
response
=
self
.
client
.
post
(
reverse
(
'core:page_prop'
,
kwargs
=
{
'page_name'
:
'guy/bibou'
}),
{
'parent'
:
'1'
,
'name'
:
'bibou'
,
'owner_group'
:
1
,
'owner_group'
:
'1'
,
})
response
=
self
.
client
.
get
(
reverse
(
'core:page'
,
kwargs
=
{
'page_name'
:
'guy/bibou'
}))
self
.
assertTrue
(
response
.
status_code
==
200
)
self
.
assertTrue
(
'PAGE_SAVED'
in
str
(
response
.
content
))
self
.
assertTrue
(
"<strong>guy/bibou</strong>"
in
str
(
response
.
content
))
def
test_access_child_page_ok
(
self
):
"""
Should display a page correctly
"""
c
=
Client
()
c
.
post
(
reverse
(
'core:page_prop'
,
kwargs
=
{
'page_name'
:
'guy'
}),
{
'parent'
:
''
,
self
.
client
.
post
(
reverse
(
'core:page_prop'
,
kwargs
=
{
'page_name'
:
'guy'
}),
{
'parent'
:
''
,
'name'
:
'guy'
,
'title'
:
'Guy'
,
'Content'
:
'Guyéuyuyé'
,
})
c
.
post
(
reverse
(
'core:page_prop'
,
kwargs
=
{
'page_name'
:
'guy/bibou'
}),
{
'parent'
:
'1'
,
self
.
client
.
post
(
reverse
(
'core:page_prop'
,
kwargs
=
{
'page_name'
:
'guy/bibou'
}),
{
'parent'
:
'1'
,
'name'
:
'bibou'
,
'title'
:
'Bibou'
,
'Content'
:
'Bibibibiblblblblblbouuuuuuuuu'
,
})
response
=
c
.
get
(
reverse
(
'core:page'
,
kwargs
=
{
'page_name'
:
'guy/bibou'
}))
response
=
self
.
client
.
get
(
reverse
(
'core:page'
,
kwargs
=
{
'page_name'
:
'guy/bibou'
}))
self
.
assertTrue
(
response
.
status_code
==
200
)
self
.
assertTrue
(
'PAGE_FOUND : Bibou'
in
str
(
response
.
content
))
#
self.assertTrue('PAGE_FOUND : Bibou' in str(response.content))
def
test_access_page_not_found
(
self
):
"""
Should not display a page correctly
"""
c
=
Client
()
response
=
c
.
get
(
reverse
(
'core:page'
,
kwargs
=
{
'page_name'
:
'swagg'
}))
response
=
self
.
client
.
get
(
reverse
(
'core:page'
,
kwargs
=
{
'page_name'
:
'swagg'
}))
self
.
assertTrue
(
response
.
status_code
==
200
)
self
.
assertTrue
(
'<a href="/page/swagg/prop">Create it?</a>'
in
str
(
response
.
content
))
...
...
core/views/__init__.py
View file @
6cc78514
...
...
@@ -3,6 +3,8 @@ from django.http import HttpResponseForbidden
from
django.core.exceptions
import
PermissionDenied
from
django.views.generic.base
import
View
from
core.models
import
Group
# TODO: see models.py's TODO!
class
CanEditPropMixin
(
View
):
"""
...
...
requirements.txt
View file @
6cc78514
django
# Django 1.8 LTS is required, version 1.9 is not supported
Django
>=1.8,<1.9
Write
Preview
Supports
Markdown
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