Add some tests on counter

This commit is contained in:
Pierre Brunet 2017-05-14 12:54:26 +02:00
parent 63acf588ca
commit 0af72500c6
2 changed files with 51 additions and 0 deletions

View File

@ -473,6 +473,11 @@ Welcome to the wiki page!
start=s.subscription_start) start=s.subscription_start)
s.save() 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 # Create an election
public_group = Group.objects.get(id=settings.SITH_GROUP_PUBLIC_ID) public_group = Group.objects.get(id=settings.SITH_GROUP_PUBLIC_ID)
subscriber_group = Group.objects.get(name=settings.SITH_MAIN_MEMBERS_GROUP) subscriber_group = Group.objects.get(name=settings.SITH_MAIN_MEMBERS_GROUP)

View File

@ -22,6 +22,7 @@
# #
# #
<<<<<<< 52a643878a10b52d9d7a17cd6c2854112c0a65d0
import re import re
from pprint import pprint 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 # TODO finir le test en vérifiant que les produits ont bien été clickés
# hint: pprint(response.__dict__) # 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&#39;</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&#39; Kia</a></li>' in str(response_get.content))