forked from City-of-Helsinki/respa
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #180 from andersinno/tre-varaamo-qa
Changes for release r41
- Loading branch information
Showing
14 changed files
with
230 additions
and
11 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
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Generated by Django 2.2.11 on 2024-08-17 13:04 | ||
|
||
from decimal import Decimal | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('payments', '0007_add_invoice_model'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='orderline', | ||
name='tax_percentage', | ||
field=models.DecimalField(choices=[(Decimal('0.00'), '0.00'), (Decimal('10.00'), '10.00'), (Decimal('14.00'), '14.00'), (Decimal('24.00'), '24.00'), (Decimal('25.50'), '25.50')], decimal_places=2, default=Decimal('25.50'), max_digits=5, verbose_name='tax percentage'), | ||
), | ||
migrations.AlterField( | ||
model_name='sapmaterialcode', | ||
name='tax_percentage', | ||
field=models.DecimalField(choices=[(Decimal('0.00'), '0.00'), (Decimal('10.00'), '10.00'), (Decimal('14.00'), '14.00'), (Decimal('24.00'), '24.00'), (Decimal('25.50'), '25.50')], decimal_places=2, default=Decimal('25.50'), max_digits=5, verbose_name='tax percentage'), | ||
), | ||
] |
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
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Generated by Django 2.2.11 on 2024-08-17 15:15 | ||
|
||
from decimal import Decimal | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('respa_pricing', '0007_auto_20231218_1250'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='eventtype', | ||
name='tax_percentage', | ||
field=models.DecimalField(choices=[(Decimal('0.00'), '0.00'), (Decimal('10.00'), '10.00'), (Decimal('14.00'), '14.00'), (Decimal('24.00'), '24.00'), (Decimal('25.50'), '25.50')], decimal_places=2, default=Decimal('25.50'), max_digits=5, verbose_name='tax percentage'), | ||
), | ||
migrations.AlterField( | ||
model_name='usergroup', | ||
name='tax_percentage', | ||
field=models.DecimalField(choices=[(Decimal('0.00'), '0.00'), (Decimal('10.00'), '10.00'), (Decimal('14.00'), '14.00'), (Decimal('24.00'), '24.00'), (Decimal('25.50'), '25.50')], decimal_places=2, default=Decimal('25.50'), max_digits=5, verbose_name='tax percentage'), | ||
), | ||
] |
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 was deleted.
Oops, something went wrong.
Empty file.
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,76 @@ | ||
from allauth.account.models import EmailAddress | ||
from django.contrib.auth import get_user_model | ||
from django.urls import reverse | ||
from rest_framework import status | ||
from rest_framework.test import APIClient, APITestCase | ||
|
||
User = get_user_model() | ||
|
||
|
||
class SetUserEmailTests(APITestCase): | ||
def setUp(self): | ||
# Create a test user | ||
self.user = User.objects.create_user( | ||
username="testuser", password="testpassword", email="" | ||
) | ||
self.client = APIClient() | ||
self.client.force_authenticate(user=self.user) | ||
EmailAddress.objects.create(user=self.user, email="") | ||
|
||
# Create another user | ||
self.other_user = User.objects.create_user( | ||
username="otheruser", password="otherpassword", email="[email protected]" | ||
) | ||
EmailAddress.objects.create(user=self.other_user, email="[email protected]") | ||
|
||
def test_set_email_success(self): | ||
url = reverse("user-set-email", kwargs={"pk": self.user.pk}) | ||
data = {"email": "[email protected]"} | ||
|
||
response = self.client.post(url, data, format="json") | ||
|
||
self.user.refresh_from_db() | ||
self.assertEqual(response.status_code, status.HTTP_200_OK) | ||
self.assertEqual(response.data, {"detail": "Email set successfully."}) | ||
self.assertEqual(self.user.email, "[email protected]") | ||
self.assertTrue( | ||
EmailAddress.objects.filter( | ||
user=self.user, email="[email protected]" | ||
).exists() | ||
) | ||
|
||
def test_set_email_already_set(self): | ||
# Set an email for the user first | ||
self.user.email = "[email protected]" | ||
self.user.save() | ||
|
||
url = reverse("user-set-email", kwargs={"pk": self.user.pk}) | ||
data = {"email": "[email protected]"} | ||
|
||
response = self.client.post(url, data, format="json") | ||
|
||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) | ||
self.assertEqual(response.data, {"detail": "User already has an email set."}) | ||
self.assertEqual(self.user.email, "[email protected]") | ||
|
||
def test_set_email_not_provided(self): | ||
url = reverse("user-set-email", kwargs={"pk": self.user.pk}) | ||
data = {"email": ""} # No email in the data | ||
|
||
response = self.client.post(url, data, format="json") | ||
|
||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) | ||
self.assertEqual(response.data, {"detail": "Email address is required."}) | ||
self.assertEqual(self.user.email, "") | ||
|
||
def test_set_email_already_in_use(self): | ||
url = reverse("user-set-email", kwargs={"pk": self.user.pk}) | ||
data = {"email": "[email protected]"} # Email already used by other_user | ||
|
||
response = self.client.post(url, data, format="json") | ||
|
||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) | ||
self.assertEqual( | ||
response.data, {"detail": "The email address is already in use."} | ||
) | ||
self.assertEqual(self.user.email, "") |