-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bae1c83
commit f2fb181
Showing
8 changed files
with
153 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Generated by Django 3.2.4 on 2024-09-15 18:45 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("bartenders", "0002_ballotlink_poll"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="bartender", | ||
name="email", | ||
field=models.CharField( | ||
blank=True, | ||
help_text="En post.au mail fungerer ikke", | ||
max_length=255, | ||
unique=True, | ||
verbose_name="E-mail", | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="bartenderapplication", | ||
name="email", | ||
field=models.CharField( | ||
blank=True, | ||
help_text="En post.au mail fungerer ikke", | ||
max_length=255, | ||
unique=True, | ||
verbose_name="E-mail", | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,77 @@ | ||
import datetime | ||
import os | ||
|
||
import pytz | ||
from django.core import mail | ||
from django.test import TestCase | ||
|
||
from udlejning.models import Udlejning, UdlejningApplication | ||
|
||
|
||
# Create your tests here. | ||
class UdlejningApplicationTests(TestCase): | ||
def setUp(self): | ||
os.environ["RECAPTCHA_TESTING"] = "True" | ||
|
||
def tearDown(self): | ||
os.environ["RECAPTCHA_TESTING"] = "False" | ||
|
||
def test_accepting_application(self): | ||
d = dict( | ||
dateFrom=datetime.datetime(2024, 9, 16, 16, 0, tzinfo=pytz.UTC), | ||
dateTo=None, | ||
whoReserved="Abekat", | ||
contactEmail="kat@mail.dk", | ||
contactPhone=42345123, | ||
whoPays="AU", | ||
paymentType="EAN", | ||
EANnumber=1234567890123, | ||
where="Nygaard-02", | ||
expectedConsummation="Alt for meget", | ||
comments="Igen kommentar", | ||
) | ||
ap = UdlejningApplication.objects.create(**d) | ||
ap.accept() | ||
|
||
# Test that an application has been created with the correct data | ||
self.assertTrue(Udlejning.objects.exists()) | ||
|
||
def test_sending_application(self): | ||
data = dict( | ||
dateFrom=datetime.datetime(2024, 9, 16, 16, 0, tzinfo=pytz.UTC), | ||
dateTo=datetime.datetime(2024, 9, 16, 22, 0, tzinfo=pytz.UTC), | ||
whoReserved="Abekat", | ||
contactEmail="kat@mail.dk", | ||
contactPhone=42345123, | ||
whoPays="AU", | ||
paymentType="card", | ||
where="Nygaard-02", | ||
expectedConsummation="Alt for meget", | ||
comments="Igen kommentar", | ||
) | ||
|
||
data["g-recaptcha-response"] = "PASSED" | ||
response = self.client.post("/da/udlejning/#rentingform", data=data) | ||
# self.assertRedirects(response, "/da/udlejning/") | ||
|
||
# Test that application was made | ||
self.assertTrue(UdlejningApplication.objects.exists()) | ||
# And mail was sent | ||
self.assertEqual(len(mail.outbox), 1) | ||
|
||
def test_invalid_application(self): | ||
# Missing payment info | ||
data = dict( | ||
dateFrom=datetime.datetime(2024, 9, 16, 16, 0, tzinfo=pytz.UTC), | ||
dateTo=datetime.datetime(2024, 9, 16, 22, 0, tzinfo=pytz.UTC), | ||
whoReserved="Abekat", | ||
contactEmail="kat@mail.dk", | ||
contactPhone=42345123, | ||
where="Nygaard-02", | ||
expectedConsummation="Alt for meget", | ||
comments="Igen kommentar", | ||
) | ||
|
||
self.client.post("/da/udlejning/", data=data) | ||
self.assertFalse(UdlejningApplication.objects.exists()) | ||
self.assertEqual(len(mail.outbox), 0) |