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
0af72500
Commit
0af72500
authored
May 14, 2017
by
Krophil
Browse files
Add some tests on counter
parent
63acf588
Changes
2
Hide whitespace changes
Inline
Side-by-side
core/management/commands/populate.py
View file @
0af72500
...
...
@@ -473,6 +473,11 @@ Welcome to the wiki page!
start
=
s
.
subscription_start
)
s
.
save
()
# Add barman to counter
c
=
Counter
.
objects
.
get
(
id
=
2
)
c
.
sellers
.
add
(
User
.
objects
.
get
(
pk
=
krophil
.
pk
))
c
.
save
()
# Create an election
public_group
=
Group
.
objects
.
get
(
id
=
settings
.
SITH_GROUP_PUBLIC_ID
)
subscriber_group
=
Group
.
objects
.
get
(
name
=
settings
.
SITH_MAIN_MEMBERS_GROUP
)
...
...
counter/tests.py
View file @
0af72500
...
...
@@ -22,6 +22,7 @@
#
#
<<<<<<<
52
a643878a10b52d9d7a17cd6c2854112c0a65d0
import
re
from
pprint
import
pprint
...
...
@@ -74,3 +75,48 @@ class CounterTest(TestCase):
# TODO finir le test en vérifiant que les produits ont bien été clickés
# hint: pprint(response.__dict__)
class
BarmanConnectionTest
(
TestCase
):
def
setUp
(
self
):
call_command
(
"populate"
)
self
.
krophil
=
User
.
objects
.
get
(
username
=
"krophil"
)
self
.
skia
=
User
.
objects
.
get
(
username
=
"skia"
)
self
.
skia
.
customer
.
account
=
800
self
.
krophil
.
customer
.
save
()
self
.
skia
.
customer
.
save
()
self
.
counter
=
Counter
.
objects
.
filter
(
id
=
2
).
first
()
def
test_barman_granted
(
self
):
response_post
=
self
.
client
.
post
(
reverse
(
'counter:login'
,
args
=
[
self
.
counter
.
id
]),
{
'username'
:
"krophil"
,
'password'
:
"plop"
})
response_get
=
self
.
client
.
get
(
reverse
(
"counter:details"
,
args
=
[
self
.
counter
.
id
]))
self
.
assertTrue
(
'<p>Enter client code:</p>'
in
str
(
response_get
.
content
))
def
test_counters_list_barmen
(
self
):
response_post
=
self
.
client
.
post
(
reverse
(
'counter:login'
,
args
=
[
self
.
counter
.
id
]),
{
'username'
:
"krophil"
,
'password'
:
"plop"
})
response_get
=
self
.
client
.
get
(
reverse
(
"counter:activity"
,
args
=
[
self
.
counter
.
id
]))
self
.
assertTrue
(
'<li><a href="/user/10/">Kro Phil'</a></li>'
in
str
(
response_get
.
content
))
def
test_barman_denied
(
self
):
response_post
=
self
.
client
.
post
(
reverse
(
'counter:login'
,
args
=
[
self
.
counter
.
id
]),
{
'username'
:
"skia"
,
'password'
:
"plop"
})
response_get
=
self
.
client
.
get
(
reverse
(
"counter:details"
,
args
=
[
self
.
counter
.
id
]))
self
.
assertTrue
(
'<p>Please, login</p>'
in
str
(
response_get
.
content
))
def
test_counters_list_no_barmen
(
self
):
response_post
=
self
.
client
.
post
(
reverse
(
'counter:login'
,
args
=
[
self
.
counter
.
id
]),
{
'username'
:
"krophil"
,
'password'
:
"plop"
})
response_get
=
self
.
client
.
get
(
reverse
(
"counter:activity"
,
args
=
[
self
.
counter
.
id
]))
self
.
assertFalse
(
'<li><a href="/user/1/">S' Kia</a></li>'
in
str
(
response_get
.
content
))
\ No newline at end of file
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