From 46e4ad955a2a7ba4f32b76a74b350140a1e3d761 Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Fri, 5 Jun 2015 14:32:26 +0800 Subject: patchwork: Explicitly load states fixtures Apps with migrations will no longer load the initial_data fixtures by default. In order to prepare to add migrations to patchwork, rename the initial_data fixture to default_states (to match the default_tags fixture), and explicitly load them in tests that require them. Also, include this step in the INSTALL document. Signed-off-by: Jeremy Kerr --- patchwork/tests/test_bundles.py | 1 + patchwork/tests/test_encodings.py | 2 ++ patchwork/tests/test_expiry.py | 1 + patchwork/tests/test_list.py | 1 + patchwork/tests/test_mboxviews.py | 12 ++++++++++++ patchwork/tests/test_notifications.py | 3 +++ patchwork/tests/test_patchparser.py | 6 +++++- patchwork/tests/test_tags.py | 4 ++-- patchwork/tests/test_updates.py | 2 ++ 9 files changed, 29 insertions(+), 3 deletions(-) (limited to 'patchwork/tests') diff --git a/patchwork/tests/test_bundles.py b/patchwork/tests/test_bundles.py index 38f3a2c..a9ee8dd 100644 --- a/patchwork/tests/test_bundles.py +++ b/patchwork/tests/test_bundles.py @@ -54,6 +54,7 @@ class BundleListTest(TestCase): self.user.delete() class BundleTestBase(TestCase): + fixtures = ['default_states'] def setUp(self, patch_count=3): patch_names = ['testpatch%d' % (i) for i in range(1, patch_count+1)] self.user = create_user() diff --git a/patchwork/tests/test_encodings.py b/patchwork/tests/test_encodings.py index b9032bb..b639078 100644 --- a/patchwork/tests/test_encodings.py +++ b/patchwork/tests/test_encodings.py @@ -26,6 +26,7 @@ from django.test import TestCase from django.test.client import Client class UTF8PatchViewTest(TestCase): + fixtures = ['default_states'] patch_filename = '0002-utf-8.patch' patch_encoding = 'utf-8' @@ -63,6 +64,7 @@ class UTF8PatchViewTest(TestCase): defaults.project.delete() class UTF8HeaderPatchViewTest(UTF8PatchViewTest): + fixtures = ['default_states'] patch_filename = '0002-utf-8.patch' patch_encoding = 'utf-8' patch_author_name = u'P\xe4tch Author' diff --git a/patchwork/tests/test_expiry.py b/patchwork/tests/test_expiry.py index 844ed4b..ca22970 100644 --- a/patchwork/tests/test_expiry.py +++ b/patchwork/tests/test_expiry.py @@ -26,6 +26,7 @@ from patchwork.tests.utils import create_user, defaults from patchwork.utils import do_expiry class TestRegistrationExpiry(TestCase): + fixtures = ['default_states'] def register(self, date): user = create_user() diff --git a/patchwork/tests/test_list.py b/patchwork/tests/test_list.py index a795a5f..c7fbbea 100644 --- a/patchwork/tests/test_list.py +++ b/patchwork/tests/test_list.py @@ -42,6 +42,7 @@ class EmptyPatchListTest(TestCase): self.assertNotContains(response, 'tbody') class PatchOrderTest(TestCase): + fixtures = ['default_states'] d = datetime.datetime patchmeta = [ diff --git a/patchwork/tests/test_mboxviews.py b/patchwork/tests/test_mboxviews.py index 0e57f42..02d04cb 100644 --- a/patchwork/tests/test_mboxviews.py +++ b/patchwork/tests/test_mboxviews.py @@ -29,6 +29,8 @@ from patchwork.models import Patch, Comment, Person from patchwork.tests.utils import defaults, create_user, find_in_context class MboxPatchResponseTest(TestCase): + fixtures = ['default_states'] + """ Test that the mbox view appends the Acked-by from a patch comment """ def setUp(self): defaults.project.save() @@ -56,6 +58,8 @@ class MboxPatchResponseTest(TestCase): 'Acked-by: 1\nAcked-by: 2\n') class MboxPatchSplitResponseTest(TestCase): + fixtures = ['default_states'] + """ Test that the mbox view appends the Acked-by from a patch comment, and places it before an '---' update line. """ def setUp(self): @@ -84,6 +88,8 @@ class MboxPatchSplitResponseTest(TestCase): 'Acked-by: 1\nAcked-by: 2\n') class MboxPassThroughHeaderTest(TestCase): + fixtures = ['default_states'] + """ Test that we see 'Cc' and 'To' headers passed through from original message to mbox view """ @@ -122,6 +128,8 @@ class MboxPassThroughHeaderTest(TestCase): self.assertContains(response, self.date_header) class MboxBrokenFromHeaderTest(TestCase): + fixtures = ['default_states'] + """ Test that a person with characters outside ASCII in his name do produce correct From header. As RFC 2822 state we must retain the format for the mail while the name part may be coded @@ -145,6 +153,8 @@ class MboxBrokenFromHeaderTest(TestCase): self.assertContains(response, from_email) class MboxDateHeaderTest(TestCase): + fixtures = ['default_states'] + """ Test that the date provided in the patch mail view is correct """ def setUp(self): @@ -181,6 +191,8 @@ class MboxDateHeaderTest(TestCase): self.assertEqual(mail_date, date) class MboxCommentPostcriptUnchangedTest(TestCase): + fixtures = ['default_states'] + """ Test that the mbox view doesn't change the postscript part of a mail. There where always a missing blank right after the postscript delimiter '---' and an additional newline right before. """ diff --git a/patchwork/tests/test_notifications.py b/patchwork/tests/test_notifications.py index ed35140..c46af61 100644 --- a/patchwork/tests/test_notifications.py +++ b/patchwork/tests/test_notifications.py @@ -28,6 +28,8 @@ from patchwork.tests.utils import defaults, create_maintainer from patchwork.utils import send_notifications class PatchNotificationModelTest(TestCase): + fixtures = ['default_states'] + """Tests for the creation & update of the PatchChangeNotification model""" def setUp(self): @@ -120,6 +122,7 @@ class PatchNotificationModelTest(TestCase): self.assertEqual(PatchChangeNotification.objects.count(), 0) class PatchNotificationEmailTest(TestCase): + fixtures = ['default_states'] def setUp(self): self.project = defaults.project diff --git a/patchwork/tests/test_patchparser.py b/patchwork/tests/test_patchparser.py index da2b07a..58689bb 100644 --- a/patchwork/tests/test_patchparser.py +++ b/patchwork/tests/test_patchparser.py @@ -32,6 +32,7 @@ except ImportError: from email.MIMEText import MIMEText class PatchTest(TestCase): + fixtures = ['default_states'] default_sender = defaults.sender default_subject = defaults.subject project = defaults.project @@ -246,6 +247,7 @@ class MultipleProjectPatchTest(TestCase): """ Test that patches sent to multiple patchwork projects are handled correctly """ + fixtures = ['default_states'] test_comment = 'Test Comment' patch_filename = '0001-add-line.patch' msgid = '<1@example.com>' @@ -449,6 +451,7 @@ class NoNewlineAtEndOfFilePatchTest(MBoxPatchTest): self.assertEqual(2, patch.content.count('\ No newline at end of file')) class DelegateRequestTest(TestCase): + fixtures = ['default_states'] patch_filename = '0001-add-line.patch' msgid = '<1@example.com>' invalid_delegate_email = "nobody" @@ -494,6 +497,7 @@ class DelegateRequestTest(TestCase): self.user.delete() class InitialPatchStateTest(TestCase): + fixtures = ['default_states'] patch_filename = '0001-add-line.patch' msgid = '<1@example.com>' invalid_state_name = "Nonexistent Test State" @@ -558,7 +562,7 @@ class ParseInitialTagsTest(PatchTest): test_comment = ('test comment\n\n' + 'Tested-by: Test User \n' + 'Reviewed-by: Test User \n') - fixtures = ['default_tags'] + fixtures = ['default_tags', 'default_states'] def setUp(self): project = defaults.project diff --git a/patchwork/tests/test_tags.py b/patchwork/tests/test_tags.py index f1196e7..a1e03f5 100644 --- a/patchwork/tests/test_tags.py +++ b/patchwork/tests/test_tags.py @@ -31,7 +31,7 @@ class ExtractTagsTest(TestCase): email = 'test@exmaple.com' name_email = 'test name <' + email + '>' - fixtures = ['default_tags'] + fixtures = ['default_tags', 'default_states'] def assertTagsEqual(self, str, acks, reviews, tests): counts = extract_tags(str, Tag.objects.all()) @@ -83,7 +83,7 @@ class PatchTagsTest(TransactionTestCase): ACK = 1 REVIEW = 2 TEST = 3 - fixtures = ['default_tags'] + fixtures = ['default_tags', 'default_states'] def assertTagsEqual(self, patch, acks, reviews, tests): patch = Patch.objects.get(pk=patch.pk) diff --git a/patchwork/tests/test_updates.py b/patchwork/tests/test_updates.py index 177ee78..d2f4126 100644 --- a/patchwork/tests/test_updates.py +++ b/patchwork/tests/test_updates.py @@ -23,6 +23,8 @@ from patchwork.models import Patch, Person, State from patchwork.tests.utils import defaults, create_maintainer class MultipleUpdateTest(TestCase): + fixtures = ['default_states'] + def setUp(self): defaults.project.save() self.user = create_maintainer(defaults.project) -- cgit v1.2.3