Fix test_bulk to skip all parts that require a custom field
It depends on settings.SF_CUSTOM_INSTALLED
@@ -10,6 +10,8 @@ from salesforce.backend import DJANGO_22_PLUS
from salesforce.backend.test_helpers import skipUnless
from salesforce.testrunner.example.models import Campaign, CampaignMember, Contact
+SF_CUSTOM_INSTALLED = getattr(settings, 'SF_CUSTOM_INSTALLED', False)
+
class BulkUpdateTest(TestCase):
"""The method queryset.bulk_update() is tested by a Contact with a unique custom field"""
@@ -19,11 +21,11 @@ class BulkUpdateTest(TestCase):
@classmethod
def setUpClass(cls) -> None:
super().setUpClass()
- if not Contact.objects.update(vs=None) >= 9:
+ if SF_CUSTOM_INSTALLED and not Contact.objects.update(vs=None) >= 9:
Contact.objects.bulk_create([Contact(last_name='sf_test {}'.format(i)) for i in range(9)])
- @skipUnless(DJANGO_22_PLUS, "bulk_update() does not exist before Django 2.2.")
- @skipUnless(getattr(settings, 'SF_CUSTOM_INSTALLED', False), "requires Salesforce customization")
+ @skipUnless(DJANGO_22_PLUS and SF_CUSTOM_INSTALLED,
+ "bulk_update() does not exist before Django 2.2. and Salesforce customization is required")
def setUp(self) -> None:
pass
@@ -70,9 +72,10 @@ class QuerysetUpdateTest(TestCase):
@classmethod
def setUpClass(cls) -> None:
super().setUpClass()
+ if SF_CUSTOM_INSTALLED:
assert Contact.objects.update(vs=None) >= 2
- @skipUnless(getattr(settings, 'SF_CUSTOM_INSTALLED', False), "requires Salesforce customization")
+ @skipUnless(SF_CUSTOM_INSTALLED, "requires Salesforce customization")
def setUp(self) -> None:
pass
