本文整理匯總了Python中profiles.factories.ProfileFactory.create_batch方法的典型用法代碼示例。如果您正苦於以下問題:Python ProfileFactory.create_batch方法的具體用法?Python ProfileFactory.create_batch怎麽用?Python ProfileFactory.create_batch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類profiles.factories.ProfileFactory
的用法示例。
在下文中一共展示了ProfileFactory.create_batch方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_view_with_search
# 需要導入模塊: from profiles.factories import ProfileFactory [as 別名]
# 或者: from profiles.factories.ProfileFactory import create_batch [as 別名]
def test_view_with_search(self, staff_client, program_data):
"""
Tests that ReviewFinancialAidView returns the expected results with search
"""
fin_aid_status = FinancialAidStatus.AUTO_APPROVED
profiles = ProfileFactory.create_batch(
4,
first_name=factory.Iterator(['match_name', 'x', 'y', 'z']),
last_name=factory.Iterator(['x', 'y', 'z', 'match_name']),
)
FinancialAidFactory.create_batch(
4,
tier_program=program_data.tier_programs["0k"],
status=fin_aid_status,
user=factory.Iterator([p.user for p in profiles])
)
name_query = 'match_name'
url = self.review_url(program_data.program.id, status=fin_aid_status, search_param=name_query)
resp = staff_client.get(url)
assert resp.status_code == status.HTTP_200_OK
financial_aid_objects = resp.context_data["financial_aid_objects"]
# Two users should match the search term - one for first_name, one for last_name
assert len(financial_aid_objects) == 2
assert all(
fin_aid.user.profile.first_name == name_query or fin_aid.user.profile.last_name == name_query
for fin_aid in financial_aid_objects
)