From 287917da3762614c66de66c10ba3cb91626d0ab7 Mon Sep 17 00:00:00 2001 From: arallaer Date: Thu, 7 Mar 2024 17:23:51 +0100 Subject: [PATCH] my first working tests --- api/tests.py | 15 --------------- api/tests/__init__.py | 0 api/tests/models/__init__.py | 0 api/tests/models/test_gebruiker.py | 16 ++++++++++++++++ api/tests/test_views.py | 5 +++-- 5 files changed, 19 insertions(+), 17 deletions(-) delete mode 100644 api/tests.py create mode 100644 api/tests/__init__.py create mode 100644 api/tests/models/__init__.py create mode 100644 api/tests/models/test_gebruiker.py diff --git a/api/tests.py b/api/tests.py deleted file mode 100644 index 5a080330..00000000 --- a/api/tests.py +++ /dev/null @@ -1,15 +0,0 @@ -from django.test import TestCase -from .models import Dummy - -class TestModels(TestCase): - - def setUp(self): - #pass - self.dummy1 = Dummy.objects.create( - name='Dummy 1', - budget=10000 - ) - - def test_dummy_model(self): - self.assertEquals(self.dummy1.slug, 'dummy-1') - #self.assertTrue(True) \ No newline at end of file diff --git a/api/tests/__init__.py b/api/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/api/tests/models/__init__.py b/api/tests/models/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/api/tests/models/test_gebruiker.py b/api/tests/models/test_gebruiker.py new file mode 100644 index 00000000..73569ec6 --- /dev/null +++ b/api/tests/models/test_gebruiker.py @@ -0,0 +1,16 @@ +from django.test import TestCase +from api.models.gebruiker import Gebruiker +from django.contrib.auth.models import User + +class GebruikerTestCase(TestCase): + def setUp(self): + user1 = User.objects.create_user(username='user1') + user2 = User.objects.create_user(username='user2') + Gebruiker.objects.create(user=user1, is_lesgever=False) + Gebruiker.objects.create(user=user2, is_lesgever=True) + + def test_gebruiker_is_lesgever(self): + user1 = Gebruiker.objects.get(user__username='user1') + user2 = Gebruiker.objects.get(user__username='user2') + self.assertEqual(user1.is_lesgever, False) + self.assertEqual(user2.is_lesgever, True) diff --git a/api/tests/test_views.py b/api/tests/test_views.py index 1d1a05de..0ff54550 100644 --- a/api/tests/test_views.py +++ b/api/tests/test_views.py @@ -1,9 +1,10 @@ -from django.test import TestCase +''' from django.test import TestCase from django.urls import reverse class TestViews(TestCase): def test_should_show_register_page(self): + print('nigger') #self.client.get(reverse('register')) #self.assertEqual(response.status_code, 200) #self.assertTemplateUsed(response, "authentication/register") - self.assertTrue(True) \ No newline at end of file + self.assertTrue(True) ''' \ No newline at end of file