Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nuages
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etch
nuages
Commits
a751572b
Commit
a751572b
authored
Jun 22, 2013
by
Christophe Siraut
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add functional tests.
parent
ccf533c5
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
115 additions
and
31 deletions
+115
-31
.gitignore
.gitignore
+2
-0
Makefile
Makefile
+5
-0
README
README
+19
-1
meetingpoll/tests.py
meetingpoll/tests.py
+1
-22
nuages/settings.py
nuages/settings.py
+10
-7
nuages/test_factories.py
nuages/test_factories.py
+22
-0
nuages/test_functional.py
nuages/test_functional.py
+55
-0
templates/registration/login.html
templates/registration/login.html
+1
-1
No files found.
.gitignore
View file @
a751572b
...
...
@@ -4,3 +4,5 @@
fixtures
staticroot
local_settings.py
.coverage
htmlcov
Makefile
View file @
a751572b
...
...
@@ -18,3 +18,8 @@ lint:
#django-lint
pylint
--generated-members
=
objects,_meta,id meetingpoll
pylint
--generated-members
=
objects,_meta,id accounts
test
:
python-coverage run
--source
=
'.'
manage.py
test
python-coverage report
README
View file @
a751572b
Nuages - Easy poll sharing
==========================
...
...
@@ -95,6 +94,25 @@ Build database, collect static files and set permissions:
Set domain name: Point your browser to /admin/sites/site/1/ and modify the entry from "example.com" to your domain name.
Testing
=======
In order to test Nuages, you need the following dependencies:
webtest
coverage
django_webtest
django-discover-runner
On debian:
# aptitude install webtest coverage pip
# pip install django_webtest django-discover-runner
You can now validate your modifications with:
# make test
Email Service
=============
...
...
meetingpoll/tests.py
View file @
a751572b
"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".
Replace these with more appropriate tests for your application.
"""
from
django.core.urlresolvers
import
resolve
from
django.test
import
TestCase
class
SimpleTest
(
TestCase
):
def
test_basic_addition
(
self
):
"""
Tests that 1 + 1 always equals 2.
"""
self
.
failUnlessEqual
(
1
+
1
,
2
)
__test__
=
{
"doctest"
:
"""
Another way to test that 1 + 1 is equal to 2.
>>> 1 + 1 == 2
True
"""
}
nuages/settings.py
View file @
a751572b
...
...
@@ -19,16 +19,19 @@ LOGIN_REDIRECT_URL = '/'
DATABASES
=
{
'default'
:
{
'ENGINE'
:
'django.db.backends.sqlite3'
,
# Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME'
:
os
.
path
.
join
(
PROJECT_DIR
,
'nuages.sqlite'
),
# Or path to database file if using sqlite3.
'USER'
:
''
,
# Not used with sqlite3.
'PASSWORD'
:
''
,
# Not used with sqlite3.
'HOST'
:
''
,
# Set to empty string for localhost. Not used with sqlite3.
'PORT'
:
''
,
# Set to empty string for default. Not used with sqlite3.
'ENGINE'
:
'django.db.backends.sqlite3'
,
'NAME'
:
os
.
path
.
join
(
PROJECT_DIR
,
'nuages.sqlite'
),
'USER'
:
''
,
'PASSWORD'
:
''
,
'HOST'
:
''
,
'PORT'
:
''
,
},
}
ACCOUNT_ACTIVATION_DAYS
=
7
# One-week activation window
ACCOUNT_ACTIVATION_DAYS
=
7
# Activation window
#if django.VERSION[:2] < (1, 6):
TEST_RUNNER
=
'discover_runner.DiscoverRunner'
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
...
...
nuages/test_factories.py
0 → 100644
View file @
a751572b
#!/usr/bin/env python
from
django.contrib.auth.models
import
User
from
meetingpoll.models
import
Poll
def
userFactory
(
**
kwargs
):
defaults
=
{
'username'
:
'username_1'
,
'password'
:
'password_1'
}
defaults
.
update
(
kwargs
)
return
User
.
objects
.
create_user
(
**
defaults
)
def
pollFactory
(
**
kwargs
):
defaults
=
{
'title'
:
'Test poll'
,
'description'
:
'Test description'
,
'user'
:
None
}
defaults
.
update
(
kwargs
)
return
Poll
.
objects
.
create
(
**
defaults
)
nuages/test_functional.py
0 → 100644
View file @
a751572b
#!/usr/bin/environ python
from
django.core.urlresolvers
import
reverse
from
django_webtest
import
WebTest
from
meetingpoll.models
import
createId
from
test_factories
import
userFactory
,
pollFactory
class
LoginProcess
(
WebTest
):
def
setUp
(
self
):
userFactory
()
def
testLoginProcess
(
self
):
login
=
self
.
app
.
get
(
reverse
(
'auth_login'
))
login
.
form
[
'username'
]
=
'username_1'
login
.
form
[
'password'
]
=
'password_1'
response
=
login
.
form
.
submit
(
'Log in'
)
.
follow
()
self
.
assertEquals
(
'200 OK'
,
response
.
status
)
self
.
assertContains
(
response
,
'My account'
,
count
=
1
,
status_code
=
200
)
def
testLoginWithInvalidCredentials
(
self
):
login
=
self
.
app
.
get
(
reverse
(
'auth_login'
))
login
.
form
[
'username'
]
=
'foo'
login
.
form
[
'password'
]
=
'bar'
response
=
login
.
form
.
submit
(
'Log in'
)
self
.
assertContains
(
response
,
'Please enter a correct username and password.'
,
count
=
1
,
status_code
=
200
)
class
HomePage
(
WebTest
):
def
test_is_responding
(
self
):
home
=
self
.
app
.
get
(
reverse
(
'home'
))
assert
home
.
status_code
==
200
assert
'Nuages - Easy poll sharing'
in
home
.
content
class
MeetingPoll
(
WebTest
):
def
setUp
(
self
):
self
.
poll
=
pollFactory
()
def
test_is_displayed
(
self
):
response
=
self
.
app
.
get
(
self
.
poll
.
link
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertTrue
(
'form'
in
response
.
context
)
self
.
assertEqual
(
response
.
context
[
'object'
]
.
id
,
self
.
poll
.
id
)
def
test_404
(
self
):
response
=
self
.
app
.
get
(
'/
%
s/'
%
createId
(
5
),
status
=
404
)
self
.
assertEqual
(
response
.
status_code
,
404
)
templates/registration/login.html
View file @
a751572b
...
...
@@ -7,7 +7,7 @@
{% csrf_token %}
{{ form.as_p }}
<input
type=
"submit"
value=
"{% trans 'Log in' %}"
/>
<input
type=
"submit"
value=
"{% trans 'Log in' %}"
name=
"Log in"
/>
<input
type=
"hidden"
name=
"next"
value=
"{{ next }}"
/>
</form>
<br
/>
...
...
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