本文整理汇总了Python中dashboard.factories.ProgramEnrollmentFactory.build方法的典型用法代码示例。如果您正苦于以下问题:Python ProgramEnrollmentFactory.build方法的具体用法?Python ProgramEnrollmentFactory.build怎么用?Python ProgramEnrollmentFactory.build使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dashboard.factories.ProgramEnrollmentFactory
的用法示例。
在下文中一共展示了ProgramEnrollmentFactory.build方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_index_program_enrolled_users_missing_profiles
# 需要导入模块: from dashboard.factories import ProgramEnrollmentFactory [as 别名]
# 或者: from dashboard.factories.ProgramEnrollmentFactory import build [as 别名]
def test_index_program_enrolled_users_missing_profiles(self, mock_on_commit):
"""
Test that index_program_enrolled_users doesn't index users missing profiles
"""
with mute_signals(post_save):
program_enrollments = [ProgramEnrollmentFactory.build() for _ in range(10)]
with patch(
'search.indexing_api._index_chunk', autospec=True, return_value=0
) as index_chunk, patch(
'search.indexing_api.serialize_program_enrolled_user',
autospec=True,
side_effect=lambda x: None # simulate a missing profile
) as serialize_mock, patch(
'search.indexing_api.serialize_public_enrolled_user', autospec=True, side_effect=lambda x: x
) as serialize_public_mock:
index_program_enrolled_users(program_enrollments)
assert index_chunk.call_count == 0
assert serialize_public_mock.call_count == 0
assert serialize_mock.call_count == len(program_enrollments)