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
63acf588
Commit
63acf588
authored
May 20, 2017
by
Skia
🤘
Committed by
Krophil
Jun 07, 2017
Browse files
Add basic unfinished counter test
parent
e7f7c575
Changes
2
Hide whitespace changes
Inline
Side-by-side
core/management/commands/populate.py
View file @
63acf588
...
...
@@ -333,7 +333,7 @@ Welcome to the wiki page!
# Counters
Customer
(
user
=
skia
,
account_id
=
"6568j"
,
amount
=
0
).
save
()
Customer
(
user
=
r
,
account_id
=
"4000"
,
amount
=
0
).
save
()
Customer
(
user
=
r
,
account_id
=
"4000
k
"
,
amount
=
0
).
save
()
p
=
ProductType
(
name
=
"Bières bouteilles"
)
p
.
save
()
c
=
ProductType
(
name
=
"Cotisations"
)
...
...
@@ -362,6 +362,7 @@ Welcome to the wiki page!
mde
=
Counter
.
objects
.
filter
(
name
=
"MDE"
).
first
()
mde
.
products
.
add
(
barb
)
mde
.
products
.
add
(
cble
)
mde
.
sellers
.
add
(
skia
)
mde
.
save
()
eboutic
=
Counter
.
objects
.
filter
(
name
=
"Eboutic"
).
first
()
...
...
counter/tests.py
View file @
63acf588
...
...
@@ -22,6 +22,55 @@
#
#
import
re
from
pprint
import
pprint
from
django.test
import
TestCase
from
django.core.urlresolvers
import
reverse
from
django.core.management
import
call_command
from
core.models
import
User
from
counter.models
import
Counter
class
CounterTest
(
TestCase
):
def
setUp
(
self
):
call_command
(
"populate"
)
self
.
skia
=
User
.
objects
.
filter
(
username
=
"skia"
).
first
()
self
.
mde
=
Counter
.
objects
.
filter
(
name
=
"MDE"
).
first
()
def
test_full_click
(
self
):
response
=
self
.
client
.
post
(
reverse
(
"counter:login"
,
kwargs
=
{
"counter_id"
:
self
.
mde
.
id
}),
{
"username"
:
self
.
skia
.
username
,
"password"
:
"plop"
})
response
=
self
.
client
.
get
(
reverse
(
"counter:details"
,
kwargs
=
{
"counter_id"
:
self
.
mde
.
id
}))
# TODO check that barman is logged:
# self.assertTrue(mon barman est bien dans le HTML de response.content)
counter_token
=
re
.
search
(
r
'name="counter_token" value="([^"]*)"'
,
str
(
response
.
content
)).
group
(
1
)
response
=
self
.
client
.
post
(
reverse
(
"counter:details"
,
kwargs
=
{
"counter_id"
:
self
.
mde
.
id
}),
{
"code"
:
"4000k"
,
"counter_token"
:
counter_token
,
})
location
=
response
.
get
(
'location'
)
# TODO check qu'on a bien eu la bonne page, avec le bon client, etc...
# response = self.client.get(response.get('location'))
response
=
self
.
client
.
post
(
location
,
{
'action'
:
'refill'
,
'amount'
:
'10'
,
'payment_method'
:
'CASH'
,
'bank'
:
'OTHER'
,
})
response
=
self
.
client
.
post
(
location
,
{
'action'
:
'code'
,
'code'
:
'BARB'
,
})
response
=
self
.
client
.
post
(
location
,
{
'action'
:
'code'
,
'code'
:
'fin'
,
})
# TODO finir le test en vérifiant que les produits ont bien été clickés
# hint: pprint(response.__dict__)
# Create your tests here.
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