From de89a3c39c306274a75a41b528fa14155b00f392 Mon Sep 17 00:00:00 2001 From: Leon Sandøy Date: Thu, 30 Jul 2020 12:38:31 +0200 Subject: Delete FilterList objects for tests. Now that we have a migration that adds data, we can no longer have tests that operate on the assumption that the database is going to be empty. So, we're now clearing that table before these tests run. --- pydis_site/apps/api/tests/test_filterlists.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'pydis_site') diff --git a/pydis_site/apps/api/tests/test_filterlists.py b/pydis_site/apps/api/tests/test_filterlists.py index 47aaaf31..188c0fff 100644 --- a/pydis_site/apps/api/tests/test_filterlists.py +++ b/pydis_site/apps/api/tests/test_filterlists.py @@ -28,6 +28,10 @@ class UnauthenticatedTests(APISubdomainTestCase): class EmptyDatabaseTests(APISubdomainTestCase): + @classmethod + def setUpTestData(cls): + FilterList.objects.all().delete() + def test_returns_empty_object(self): response = self.client.get(URL) @@ -38,6 +42,7 @@ class EmptyDatabaseTests(APISubdomainTestCase): class FetchTests(APISubdomainTestCase): @classmethod def setUpTestData(cls): + FilterList.objects.all().delete() cls.jpeg_format = FilterList.objects.create(**JPEG_ALLOWLIST) cls.png_format = FilterList.objects.create(**PNG_ALLOWLIST) @@ -64,6 +69,10 @@ class FetchTests(APISubdomainTestCase): class CreationTests(APISubdomainTestCase): + @classmethod + def setUpTestData(cls): + FilterList.objects.all().delete() + def test_returns_400_for_missing_params(self): no_type_json = { "allowed": True, @@ -97,6 +106,7 @@ class CreationTests(APISubdomainTestCase): class DeletionTests(APISubdomainTestCase): @classmethod def setUpTestData(cls): + FilterList.objects.all().delete() cls.jpeg_format = FilterList.objects.create(**JPEG_ALLOWLIST) cls.png_format = FilterList.objects.create(**PNG_ALLOWLIST) -- cgit v1.2.3