Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
nopaque
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SFB 1288 - INF
nopaque
Commits
30e82088
Commit
30e82088
authored
5 years ago
by
Stephan Porada
Browse files
Options
Downloads
Patches
Plain Diff
Add testing for register
parent
bc9f64ba
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_client.py
+46
-0
46 additions, 0 deletions
tests/test_client.py
with
46 additions
and
0 deletions
tests/test_client.py
0 → 100644
+
46
−
0
View file @
30e82088
import
re
import
unittest
from
app
import
create_app
,
db
from
app.models
import
User
,
Role
class
FlaskClientTestCase
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
app
=
create_app
(
'
testing
'
)
self
.
app_context
=
self
.
app
.
app_context
()
self
.
app_context
.
push
()
db
.
create_all
()
# Role.insert_roles()
self
.
client
=
self
.
app
.
test_client
(
use_cookies
=
True
)
def
tearDown
(
self
):
db
.
session
.
remove
()
db
.
drop_all
()
self
.
app_context
.
pop
()
def
test_home_page
(
self
):
response
=
self
.
client
.
get
(
'
/
'
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertTrue
(
'
Stranger
'
in
response
.
get_data
(
as_text
=
True
))
def
test_register_and_login
(
self
):
# register a new account
response
=
self
.
client
.
post
(
'
/auth/register
'
,
data
=
{
'
email
'
:
'
john@example.com
'
,
'
username
'
:
'
john
'
,
'
password
'
:
'
cat
'
,
'
password2
'
:
'
cat
'
})
self
.
assertEqual
(
response
.
status_code
,
302
)
# login with the new account
response
=
self
.
client
.
post
(
'
/auth/login
'
,
data
=
{
'
email
'
:
'
john@example.com
'
,
'
password
'
:
'
cat
'
},
follow_redirects
=
True
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertTrue
(
re
.
search
(
r
'
Hello,\sjohn!
'
,
response
.
get_data
(
as_text
=
True
)))
self
.
assertTrue
(
'
You have not confirmed your account yet
'
in
response
.
get_data
(
as_text
=
True
))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment