|
@@ -15,12 +15,12 @@ class BillingInvoiceCreationTests(TestCase):
|
|
|
def setUp(self):
|
|
|
# Créé une offre
|
|
|
self.offer = Offer(name='Offre', billing_period=3, period_fees=30,
|
|
|
- initial_fees=50, type='dsl')
|
|
|
+ initial_fees=50)
|
|
|
self.offer.save()
|
|
|
# Créé un membre
|
|
|
- self.ldap_cn = MemberTestsUtils.get_random_ldap_cn()
|
|
|
+ self.username = MemberTestsUtils.get_random_username()
|
|
|
self.member = Member(first_name='Balthazar', last_name='Picsou',
|
|
|
- ldap_cn=self.ldap_cn)
|
|
|
+ username=self.username)
|
|
|
self.member.save()
|
|
|
# Créé un abonnement
|
|
|
self.subscription = OfferSubscription(
|
|
@@ -31,7 +31,7 @@ class BillingInvoiceCreationTests(TestCase):
|
|
|
|
|
|
def tearDown(self):
|
|
|
# Supprime l'utilisateur LDAP créé
|
|
|
- LdapUser.objects.get(pk=self.ldap_cn).delete()
|
|
|
+ LdapUser.objects.get(pk=self.username).delete()
|
|
|
|
|
|
def test_first_subscription_invoice_has_initial_fees(self):
|
|
|
"""
|
|
@@ -117,11 +117,11 @@ class BillingPDFTests(TestCase):
|
|
|
pdf
|
|
|
"""
|
|
|
# Créé un membre
|
|
|
- ldap_cn = MemberTestsUtils.get_random_ldap_cn()
|
|
|
+ username = MemberTestsUtils.get_random_username()
|
|
|
member = Member(first_name='A', last_name='A',
|
|
|
- ldap_cn=ldap_cn)
|
|
|
+ username=username)
|
|
|
+ member.set_password('1234')
|
|
|
member.save()
|
|
|
- member.change_password('1234')
|
|
|
|
|
|
# Créé une facture
|
|
|
invoice = Invoice(member=member)
|
|
@@ -129,12 +129,12 @@ class BillingPDFTests(TestCase):
|
|
|
|
|
|
# Se connect en tant que le membre
|
|
|
client = Client()
|
|
|
- client.login(username=ldap_cn, password='1234')
|
|
|
+ client.login(username=username, password='1234')
|
|
|
# Tente de télécharger la facture
|
|
|
response = client.get('/billing/invoice/%i/pdf' % invoice.id)
|
|
|
# Vérifie return code 200 et contient chaine %PDF-1.
|
|
|
self.assertContains(response, '%PDF-1.', status_code=200, html=False)
|
|
|
- LdapUser.objects.get(pk=ldap_cn).delete()
|
|
|
+ member.delete()
|
|
|
|
|
|
def test_that_only_owner_of_invoice_can_download_it_as_pdf(self):
|
|
|
"""
|
|
@@ -144,20 +144,20 @@ class BillingPDFTests(TestCase):
|
|
|
infructueuse
|
|
|
"""
|
|
|
# Créé un membre A
|
|
|
- member_a_login = MemberTestsUtils.get_random_ldap_cn()
|
|
|
+ member_a_login = MemberTestsUtils.get_random_username()
|
|
|
member_a_pwd = '1234'
|
|
|
- member_a = Member(first_name='A', last_name='A',
|
|
|
- ldap_cn=member_a_login)
|
|
|
+ member_a = Member(first_name='A', last_name='A', email='a@a.com',
|
|
|
+ username=member_a_login)
|
|
|
+ member_a.set_password(member_a_pwd)
|
|
|
member_a.save()
|
|
|
- member_a.change_password(member_a_pwd)
|
|
|
|
|
|
# Créé un membre B
|
|
|
- member_b_login = MemberTestsUtils.get_random_ldap_cn()
|
|
|
+ member_b_login = MemberTestsUtils.get_random_username()
|
|
|
member_b_pwd = '1234'
|
|
|
- member_b = Member(first_name='B', last_name='B',
|
|
|
- ldap_cn=member_b_login)
|
|
|
+ member_b = Member(first_name='B', last_name='B', email='b@b.com',
|
|
|
+ username=member_b_login)
|
|
|
+ member_b.set_password(member_b_pwd)
|
|
|
member_b.save()
|
|
|
- member_b.change_password(member_b_pwd)
|
|
|
|
|
|
# Créé une facture pour le membre A
|
|
|
invoice_a = Invoice(member=member_a)
|
|
@@ -179,5 +179,5 @@ class BillingPDFTests(TestCase):
|
|
|
# Vérifie que B a reçu retour Forbidden 403
|
|
|
self.assertEqual(response.status_code, 403)
|
|
|
|
|
|
- LdapUser.objects.get(pk=member_a_login).delete()
|
|
|
- LdapUser.objects.get(pk=member_b_login).delete()
|
|
|
+ member_a.delete()
|
|
|
+ member_b.delete()
|