本文整理汇总了Python中mypartners.tests.factories.ContactFactory.create_batch方法的典型用法代码示例。如果您正苦于以下问题:Python ContactFactory.create_batch方法的具体用法?Python ContactFactory.create_batch怎么用?Python ContactFactory.create_batch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mypartners.tests.factories.ContactFactory
的用法示例。
在下文中一共展示了ContactFactory.create_batch方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_filter_by_city
# 需要导入模块: from mypartners.tests.factories import ContactFactory [as 别名]
# 或者: from mypartners.tests.factories.ContactFactory import create_batch [as 别名]
def test_filter_by_city(self):
"""Tests that filtering by city works."""
indianapolis = LocationFactory(city="Indianapolis")
ContactFactory.create_batch(10, name="Jen Doe", partner=self.partner, locations=[indianapolis])
self.client.path += "/contact"
response = self.client.get(data={"city": "indianapolis"})
output = json.loads(response.content)
self.assertEqual(len(output), 10)
示例2: test_filter_by_state
# 需要导入模块: from mypartners.tests.factories import ContactFactory [as 别名]
# 或者: from mypartners.tests.factories.ContactFactory import create_batch [as 别名]
def test_filter_by_state(self):
"""Tests that filtering by state works."""
indiana = LocationFactory(state="IN")
ContactFactory.create_batch(10, name="Jen Doe", partner=self.partner, locations=[indiana])
self.client.path += "/contact"
response = self.client.get(data={"state": "IN"})
output = json.loads(response.content)
self.assertEqual(len(output), 10)
示例3: test_filtering_on_contact
# 需要导入模块: from mypartners.tests.factories import ContactFactory [as 别名]
# 或者: from mypartners.tests.factories.ContactFactory import create_batch [as 别名]
def test_filtering_on_contact(self):
"""Test the ability to filter by contact."""
ContactFactory.create_batch(10, name="Jen Doe", partner=self.partner)
# contacts with the wrong name
ContactFactory.create_batch(10, name="Jen Smith", partner=self.partner)
self.client.path += "/contact"
response = self.client.get(data={"name": "Jen Doe"})
output = json.loads(response.content)
self.assertEqual(response.status_code, 200)
self.assertEqual(len(output), 10)
示例4: test_contact_record_counts_vs_list
# 需要导入模块: from mypartners.tests.factories import ContactFactory [as 别名]
# 或者: from mypartners.tests.factories.ContactFactory import create_batch [as 别名]
def test_contact_record_counts_vs_list(self):
"""
ContactRecord counts for Communication Records and Referals
should match summed counts from contacts.
"""
contacts = ContactFactory.create_batch(4)
contacts[0].name = 'Other name'
contacts[1].email = '[email protected]'
contacts[2].partner = PartnerFactory(name='Other Partner')
for contact in contacts:
ContactRecordFactory.create(contact_type="job",
contact=contact,
partner=contact.partner)
ContactRecordFactory.create(contact_type = 'email',
contact=contact,
partner=contact.partner)
contacts[0].email = '[email protected]'
ContactRecordFactory.create(contact_type = 'email',
contact=contacts[0],
partner=contact.partner)
queryset = ContactRecord.objects.all()
self.assertEqual(queryset.count(), 9)
contacts = list(queryset.contacts)
sum_referrals = sum([contact['referrals'] for contact in contacts])
sum_records = sum([contact['records'] for contact in contacts])
self.assertEqual(sum_referrals, queryset.referrals)
self.assertEqual(sum_records, queryset.communication_activity.count())
示例5: test_list_query_params
# 需要导入模块: from mypartners.tests.factories import ContactFactory [as 别名]
# 或者: from mypartners.tests.factories.ContactFactory import create_batch [as 别名]
def test_list_query_params(self):
"""Test that query parameters that are lists are parsed correctly."""
contacts = ContactFactory.create_batch(10, partner__owner=self.company)
pks = [contact.pk for contact in contacts[:5]]
self.client.path += "/partner"
response = self.client.get(data={"contact": pks})
output = json.loads(response.content)
self.assertEqual(response.status_code, 200)
self.assertEqual(len(output), 5)
示例6: test_contact_locations
# 需要导入模块: from mypartners.tests.factories import ContactFactory [as 别名]
# 或者: from mypartners.tests.factories.ContactFactory import create_batch [as 别名]
def test_contact_locations(self):
"""
Test that `get_contact_locations` returns a properly formatted string.
"""
ny = LocationFactory.create_batch(2, city="Albany", state="NY")
il = LocationFactory.create(city="Chicago", state="IL")
mo = LocationFactory.create(city="St. Louis", state="MO")
contacts = ContactFactory.create_batch(4, partner=self.partner)
for contact, location in zip(contacts, ny + [il, mo]):
contact.locations.add(location)
self.assertEqual("Chicago, IL; St. Louis, MO; Albany, NY",
"; ".join(self.partner.get_contact_locations()))