From d2bd6ba200dfb986e72b047d4cd02c9bba318e08 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 4 Aug 2020 12:41:15 +0200 Subject: [PATCH] [test] update for uncloud_net --- uncloud_net/tests.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/uncloud_net/tests.py b/uncloud_net/tests.py index 7ed6f1f..b6700cd 100644 --- a/uncloud_net/tests.py +++ b/uncloud_net/tests.py @@ -13,7 +13,11 @@ from uncloud_pay.models import BillingAddress, Order class VPNTests(TestCase): def setUp(self): self.user = get_user_model().objects.create_user('django-test-user', 'noreply@ungleich.ch') - self.admin_user = get_user_model().objects.create_user('django-test-adminuser', 'noreply-admin@ungleich.ch') + self.admin_user = get_user_model().objects.create_user('django-test-adminuser', + 'noreply-admin@ungleich.ch') + + + self.admin_user.is_staff = True self.admin_user.save() @@ -62,11 +66,20 @@ class VPNTests(TestCase): }) force_authenticate(request, user=self.user) - # we don't have a billing address -> raises error + # we don't have a billing address -> should raise an error with self.assertRaises(ValidationError): response = view(request) - ba = BillingAddress.objects.create(owner=self.user) + addr = BillingAddress.objects.get_or_create( + owner=self.user, + active=True, + defaults={'organization': 'ungleich', + 'name': 'Nico Schottelius', + 'street': 'Hauptstrasse 14', + 'city': 'Luchsingen', + 'postal_code': '8775', + 'country': 'CH' } + ) # This should work now response = view(request) @@ -76,7 +89,6 @@ class VPNTests(TestCase): order = Order.objects.get(owner=self.user) - def tearDown(self): self.user.delete() self.admin_user.delete()