class BundleTestBase(TestCase):
- fixtures = ['default_states']
-
def setUp(self, count=3):
self.user = create_user()
self.client.login(username=self.user.username,
class PatchChecksTest(TransactionTestCase):
- fixtures = ['default_tags', 'default_states']
def setUp(self):
self.patch = create_patches()[0]
class CoverLetterViewTest(TestCase):
- fixtures = ['default_states']
def test_redirect(self):
patches = create_patches()
class PatchViewTest(TestCase):
- fixtures = ['default_states']
def test_redirect(self):
covers = create_covers()
class UTF8PatchViewTest(TestCase):
- fixtures = ['default_states']
-
def setUp(self):
patch_content = read_patch('0002-utf-8.patch', encoding='utf-8')
self.patch = create_patch(diff=patch_content)
class UTF8HeaderPatchViewTest(UTF8PatchViewTest):
- fixtures = ['default_states']
-
def setUp(self):
author = create_person(name=u'P\xe4tch Author')
patch_content = read_patch('0002-utf-8.patch', encoding='utf-8')
class TestRegistrationExpiry(TestCase):
- fixtures = ['default_states']
-
def register(self, date):
user = create_user()
user.is_active = False
class PatchOrderTest(TestCase):
- fixtures = ['default_states']
-
d = datetime.datetime
patchmeta = [
('AlCMyjOsx', 'AlxMyjOsx@nRbqkQV.wBw',
"""Test that the mbox view appends the Acked-by from a patch comment."""
- fixtures = ['default_states']
-
def setUp(self):
project = create_project()
self.person = create_person()
"""Test that the mbox view appends the Acked-by from a patch comment,
and places it before an '---' update line."""
- fixtures = ['default_states']
-
def setUp(self):
project = create_project()
self.person = create_person()
"""Test the passthrough and generation of various headers."""
- fixtures = ['default_states']
-
def test_header_passthrough_cc(self):
"""Validate passthrough of 'Cc' header."""
header = 'Cc: CC Person <cc@example.com>'
class MboxCommentPostcriptUnchangedTest(TestCase):
- fixtures = ['default_states']
-
def test_comment_unchanged(self):
"""Validate postscript part of mail is unchanged.
from patchwork.models import EmailOptout
from patchwork.models import PatchChangeNotification
-from patchwork.models import State
from patchwork.tests.utils import create_patch
from patchwork.tests.utils import create_patches
from patchwork.tests.utils import create_project
+from patchwork.tests.utils import create_state
from patchwork.utils import send_notifications
"""Tests for the creation and update of the PatchChangeNotifications."""
- fixtures = ['default_states']
-
def setUp(self):
self.project = create_project(send_notifications=True)
"""Ensure we get a notification for interesting patch changes"""
patch = create_patch(project=self.project)
oldstate = patch.state
- state = State.objects.exclude(pk=oldstate.pk)[0]
+ state = create_state()
patch.state = state
patch.save()
"""Ensure we cancel notifications that are no longer valid"""
patch = create_patch(project=self.project)
oldstate = patch.state
- state = State.objects.exclude(pk=oldstate.pk)[0]
+ state = create_state()
patch.state = state
patch.save()
but keep the original patch details"""
patch = create_patch(project=self.project)
oldstate = patch.state
- newstates = State.objects.exclude(pk=oldstate.pk)[:2]
+ newstates = [create_state(), create_state()]
patch.state = newstates[0]
patch.save()
"""Ensure we don't see notifications created when a project is
configured not to send them"""
patch = create_patch() # don't use self.project
- oldstate = patch.state
- state = State.objects.exclude(pk=oldstate.pk)[0]
+ state = create_state()
patch.state = state
patch.save()
class PatchNotificationEmailTest(TestCase):
- fixtures = ['default_states']
-
def setUp(self):
self.project = create_project(send_notifications=True)
patch.save()
PatchChangeNotification(patch=patch, orig_state=patch.state).save()
+ state = create_state()
+
self.assertEqual(PatchChangeNotification.objects.count(), len(patches))
self._expire_notifications()
# update one notification, to bring it out of the notification delay
- patches[0].state = State.objects.exclude(pk=patches[0].state.pk)[0]
+
+ patches[0].state = state
patches[0].save()
# the updated notification should prevent the other from being sent
from patchwork.bin.parsemail import find_content
from patchwork.bin.parsemail import find_project_by_header
from patchwork.bin.parsemail import find_pull_request
-from patchwork.bin.parsemail import parse_mail
+from patchwork.bin.parsemail import parse_mail as _parse_mail
from patchwork.bin.parsemail import parse_series_marker
from patchwork.bin.parsemail import split_prefixes
from patchwork.models import Comment
-from patchwork.models import get_default_initial_patch_state
from patchwork.models import Patch
from patchwork.models import Person
from patchwork.models import State
from patchwork.tests.utils import create_project
+from patchwork.tests.utils import create_state
from patchwork.tests.utils import create_user
from patchwork.tests.utils import read_patch
from patchwork.tests.utils import SAMPLE_DIFF
return _create_email(msg, msgid, sender, listid)
-class PatchTest(TestCase):
+def parse_mail(*args, **kwargs):
+ create_state()
+ return _parse_mail(*args, **kwargs)
+
- fixtures = ['default_states']
+class PatchTest(TestCase):
def setUp(self):
self.project = create_project()
"""Test that patches sent to multiple patchwork projects are
handled correctly."""
- fixtures = ['default_states']
orig_content = 'Test Comment'
patch_filename = '0001-add-line.patch'
msgid = '<1@example.com>'
class DelegateRequestTest(TestCase):
- fixtures = ['default_states']
patch_filename = '0001-add-line.patch'
msgid = '<1@example.com>'
invalid_delegate_email = "nobody"
class InitialPatchStateTest(TestCase):
- fixtures = ['default_states']
patch_filename = '0001-add-line.patch'
msgid = '<1@example.com>'
invalid_state_name = "Nonexistent Test State"
def setUp(self):
+ self.default_state = create_state()
+ self.nondefault_state = create_state()
+
self.patch = read_patch(self.patch_filename)
self.user = create_user()
self.project = create_project()
- self.default_state = get_default_initial_patch_state()
- self.nondefault_state = State.objects.get(name="Accepted")
def _get_email(self):
email = create_email(
class ParseInitialTagsTest(PatchTest):
- fixtures = ['default_tags', 'default_states']
+ fixtures = ['default_tags']
patch_filename = '0001-add-line.patch'
orig_content = ('test comment\n\n' +
'Tested-by: Test User <test@example.com>\n' +
@unittest.skipUnless(settings.ENABLE_REST_API, 'requires ENABLE_REST_API')
class TestProjectAPI(APITestCase):
- fixtures = ['default_states']
@staticmethod
def api_url(item=None):
@unittest.skipUnless(settings.ENABLE_REST_API, 'requires ENABLE_REST_API')
class TestPersonAPI(APITestCase):
- fixtures = ['default_states']
@staticmethod
def api_url(item=None):
@unittest.skipUnless(settings.ENABLE_REST_API, 'requires ENABLE_REST_API')
class TestUserAPI(APITestCase):
- fixtures = ['default_states']
@staticmethod
def api_url(item=None):
@unittest.skipUnless(settings.ENABLE_REST_API, 'requires ENABLE_REST_API')
class TestPatchAPI(APITestCase):
- fixtures = ['default_states', 'default_tags']
+ fixtures = ['default_tags']
@staticmethod
def api_url(item=None):
@unittest.skipUnless(settings.ENABLE_REST_API, 'requires ENABLE_REST_API')
class TestCheckAPI(APITestCase):
- fixtures = ['default_states', 'default_tags']
+ fixtures = ['default_tags']
def setUp(self):
super(TestCheckAPI, self).setUp()
class ExtractTagsTest(TestCase):
- fixtures = ['default_tags', 'default_states']
+ fixtures = ['default_tags']
email = 'test@example.com'
name_email = 'test name <' + email + '>'
class PatchTagsTest(TransactionTestCase):
- fixtures = ['default_tags', 'default_states']
+ fixtures = ['default_tags']
ACK = 1
REVIEW = 2
TEST = 3
from patchwork.models import State
from patchwork.tests.utils import create_patches
from patchwork.tests.utils import create_project
+from patchwork.tests.utils import create_state
from patchwork.tests.utils import create_maintainer
class MultipleUpdateTest(TestCase):
- fixtures = ['default_states']
properties_form_id = 'patchform-properties'
def setUp(self):
return response
def test_state_change_valid(self):
- states = [patch.state.pk for patch in self.patches]
- state = State.objects.exclude(pk__in=states)[0]
+ state = create_state()
self._test_state_change(state.pk)
class UserProfileTest(_UserTestCase):
- fixtures = ['default_states']
-
def test_user_profile(self):
response = self.client.get(reverse('user-profile'))
self.assertContains(response, 'Your Profile')
'setting)')
class XMLRPCTest(LiveServerTestCase):
- fixtures = ['default_states']
-
def setUp(self):
self.url = self.live_server_url + reverse('xmlrpc')
self.rpc = xmlrpc_client.Server(self.url)
from patchwork.models import Patch
from patchwork.models import Person
from patchwork.models import Project
+from patchwork.models import State
SAMPLE_DIFF = """--- /dev/null 2011-01-01 00:00:00.000000000 +0800
+++ a 2011-01-01 00:00:00.000000000 +0800
return user
+def create_state(**kwargs):
+ """Create 'State' object."""
+ num = State.objects.count()
+
+ values = {
+ 'name': 'state_%d' % num,
+ 'ordering': num,
+ 'action_required': True,
+ }
+ values.update(kwargs)
+
+ state = State(**values)
+ state.save()
+
+ return state
+
+
def create_bundle(**kwargs):
"""Create 'Bundle' object."""
num = Bundle.objects.count()
'delegate': None,
'project': create_project(),
'msgid': make_msgid(),
+ 'state': create_state(),
'name': 'testpatch%d' % num,
'headers': '',
'content': '',
count (int): Number of patches to create
kwargs (dict): Overrides for various patch fields
"""
- return _create_submissions(create_patch, count, **kwargs)
+ values = {'state': create_state()}
+ values.update(kwargs)
+
+ return _create_submissions(create_patch, count, **values)
def create_covers(count=1, **kwargs):