Commit 10ee5e17 authored by Skia's avatar Skia 🤘
Browse files

Merge branch 'counter' into 'master'

Tests for counter

See merge request !77
parents 99ed1c0c eb510e10
Pipeline #1037 passed with stage
in 7 minutes and 2 seconds
......@@ -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="4000k", 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()
......@@ -472,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)
......
......@@ -22,6 +22,112 @@
#
#
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}))
self.assertTrue(
'class="link-button">S&#39; Kia</button>' in str(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')
response = self.client.get(response.get('location'))
self.assertTrue('<p>Richard Batsbak</p>' in str(response.content))
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',
})
response_get = self.client.get(response.get('location'))
self.assertTrue('<p>Client : Richard Batsbak - Nouveau montant : 8.30' in str(response_get.content))
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):
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>Entrez un code client : </p>' in str(response_get.content))
def test_counters_list_barmen(self):
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):
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>Merci de vous identifier</p>' in str(response_get.content))
def test_counters_list_no_barmen(self):
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]))
# Create your tests here.
self.assertFalse(
'<li><a href="/user/1/">S&#39; Kia</a></li>' in str(response_get.content))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment