Skip to content

Instantly share code, notes, and snippets.

@hynekcer
Created August 4, 2017 20:46
Show Gist options
  • Save hynekcer/22c5d9736b27aaa500e4f298f5ec3425 to your computer and use it in GitHub Desktop.
Save hynekcer/22c5d9736b27aaa500e4f298f5ec3425 to your computer and use it in GitHub Desktop.
test for django-salesforce issue 191
# == models.py ==
from salesforce import models
class RecordType(models.SalesforceModel):
sobject_type = models.CharField(max_length=40, sf_read_only=models.NOT_UPDATEABLE)
class Contact(models.Model):
last_name = models.CharField(max_length=80)
record_type = models.ForeignKey(RecordType, models.DO_NOTHING, blank=True, null=True)
# == tests.py ==
from django.test import TestCase
from .models import Contact, RecordType
class RecordTypeTest(TestCase):
def test_record_type_bulk(self):
rec_types = RecordType.objects.filter(sobject_type='Contact')[:]
assert len(rec_types) >=3
test_contacts = [Contact(last_name='record type test %d' % i, record_type=rec_types[i % 3])
for i in range(200)]
Contact.objects.bulk_create(test_contacts)
for x in Contact.objects.filter(last_name__startswith='record type test '):
x.delete()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment