本文整理汇总了Python中mypartners.tests.factories.ContactRecordFactory.create_batch方法的典型用法代码示例。如果您正苦于以下问题:Python ContactRecordFactory.create_batch方法的具体用法?Python ContactRecordFactory.create_batch怎么用?Python ContactRecordFactory.create_batch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mypartners.tests.factories.ContactRecordFactory
的用法示例。
在下文中一共展示了ContactRecordFactory.create_batch方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from mypartners.tests.factories import ContactRecordFactory [as 别名]
# 或者: from mypartners.tests.factories.ContactRecordFactory import create_batch [as 别名]
def setUp(self):
super(TestDownloads, self).setUp()
self.client = TestClient(path=reverse('downloads'),
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
self.client.login_user(self.user)
ContactRecordFactory.create_batch(10, partner__owner=self.company)
示例2: test_filtering_on_foreign_key
# 需要导入模块: from mypartners.tests.factories import ContactRecordFactory [as 别名]
# 或者: from mypartners.tests.factories.ContactRecordFactory import create_batch [as 别名]
def test_filtering_on_foreign_key(self):
"""Test the ability to filter on a model's foreign key fields."""
PartnerFactory.create_batch(5, name='Test Partner', owner=self.company)
ContactRecordFactory.create_batch(
5, partner=self.partner, contact__name='Jane Doe')
self.client.path += '/partner'
filters = json.dumps({
'name': {
'icontains': 'Test Partner',
},
'contactrecord': {
'contact': {
'name': {
'icontains': 'Jane Doe'
}
}
}
})
response = self.client.post(data={'filters': filters})
output = json.loads(response.content)
self.assertEqual(response.status_code, 200)
# We look for distinct records
self.assertEqual(len(output), 1)
示例3: setUp
# 需要导入模块: from mypartners.tests.factories import ContactRecordFactory [as 别名]
# 或者: from mypartners.tests.factories.ContactRecordFactory import create_batch [as 别名]
def setUp(self):
super(ContactRecordFormTests, self).setUp()
self.contact_record = ContactRecordFactory(
contact=self.contact, partner=self.partner)
# The contact record form has a lot of required fields.
self.data = {
'contact_type': self.contact_record.contact_type,
'contact': self.contact_record.contact.pk,
'contact_email': self.contact_record.contact_email,
'length_0': "00",
'length_1': "30",
'date_time_0': "Aug",
'date_time_1': "24",
'date_time_2': "2015",
'date_time_3': "03",
'date_time_4': "10",
'date_time_5': "PM",
'notes': self.contact_record.notes,
'partner': self.contact_record.partner.pk,
'company': self.contact_record.partner.owner
}
self.form = ContactRecordForm(
instance=self.contact_record, partner=self.partner, data=self.data)
# add a few contact records so that we have some to select from
ContactRecordFactory.create_batch(3, partner=self.partner,
contact=self.contact,
contact_type='phone')
self.client.path = reverse(
"partner_edit_record") + "?partner=%s" % self.partner.pk
示例4: setUp
# 需要导入模块: from mypartners.tests.factories import ContactRecordFactory [as 别名]
# 或者: from mypartners.tests.factories.ContactRecordFactory import create_batch [as 别名]
def setUp(self):
super(TestHelpers, self).setUp()
tags = [TagFactory(name=name, company=self.company) for name in ["test", "stuff", "working"]]
# Returns a list rather than a QuerySet, which is what the helper
# functions use, so saving this to a variable isn't really helpful
ContactRecordFactory.create_batch(10, partner=self.partner, contact__name="Joe Shmoe", tags=tags)
self.records = ContactRecord.objects.all()
示例5: test_json_output
# 需要导入模块: from mypartners.tests.factories import ContactRecordFactory [as 别名]
# 或者: from mypartners.tests.factories.ContactRecordFactory import create_batch [as 别名]
def test_json_output(self):
"""Test that filtering contact records through ajax works properly."""
# records to be filtered out
ContactRecordFactory.create_batch(10, contact__name="John Doe")
self.client.path += "/contactrecord"
response = self.client.get(data={"contact__name": "Joe Shmoe"})
output = json.loads(response.content)
self.assertEqual(response.status_code, 200)
self.assertEqual(len(output), 10)
示例6: test_only_user_results_returned
# 需要导入模块: from mypartners.tests.factories import ContactRecordFactory [as 别名]
# 或者: from mypartners.tests.factories.ContactRecordFactory import create_batch [as 别名]
def test_only_user_results_returned(self):
"""Results should only contain records user has access to."""
# records not owned by user
partner = PartnerFactory(name="Wrong Partner")
ContactRecordFactory.create_batch(10, partner=partner)
self.client.path += '/contactrecord'
response = self.client.post()
output = json.loads(response.content)
self.assertEqual(response.status_code, 200)
self.assertEqual(len(output), 10)
示例7: test_filtering_on_foreign_key
# 需要导入模块: from mypartners.tests.factories import ContactRecordFactory [as 别名]
# 或者: from mypartners.tests.factories.ContactRecordFactory import create_batch [as 别名]
def test_filtering_on_foreign_key(self):
"""Test the ability to filter on a model's foreign key fields."""
PartnerFactory.create_batch(5, name="Test Partner", owner=self.company)
ContactRecordFactory.create_batch(5, partner=self.partner, contact__name="Jane Doe")
self.client.path += "/partner"
filters = json.dumps(
{"name": {"icontains": "Test Partner"}, "contactrecord": {"contact": {"name": {"icontains": "Jane Doe"}}}}
)
response = self.client.post(data={"filters": filters})
output = json.loads(response.content)
self.assertEqual(response.status_code, 200)
# We look for distinct records
self.assertEqual(len(output), 1)
示例8: test_json_output
# 需要导入模块: from mypartners.tests.factories import ContactRecordFactory [as 别名]
# 或者: from mypartners.tests.factories.ContactRecordFactory import create_batch [as 别名]
def test_json_output(self):
"""Test that filtering contact records through ajax works properly."""
# records to be filtered out
ContactRecordFactory.create_batch(10, contact__name='John Doe')
self.client.path += '/contactrecord'
filters = json.dumps({
'contact': {
'name': {
'icontains': 'Joe Shmoe'
}
}
})
response = self.client.post(data={'filters': filters})
output = json.loads(response.content)
self.assertEqual(response.status_code, 200)
self.assertEqual(len(output), 10)
示例9: setUp
# 需要导入模块: from mypartners.tests.factories import ContactRecordFactory [as 别名]
# 或者: from mypartners.tests.factories.ContactRecordFactory import create_batch [as 别名]
def setUp(self):
super(TestDownloadReport, self).setUp()
self.client = TestClient(path=reverse("download_report"))
self.client.login_user(self.user)
ContactRecordFactory.create_batch(5, partner__owner=self.company)
ContactRecordFactory.create_batch(5, contact_type="job", job_applications=1, partner__owner=self.company)
ContactRecordFactory.create_batch(5, contact_type="job", job_hires=1, partner__owner=self.company)