本文整理汇总了Python中ecommerce.courses.tests.factories.CourseFactory.create方法的典型用法代码示例。如果您正苦于以下问题:Python CourseFactory.create方法的具体用法?Python CourseFactory.create怎么用?Python CourseFactory.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ecommerce.courses.tests.factories.CourseFactory
的用法示例。
在下文中一共展示了CourseFactory.create方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_course_publish_successfully
# 需要导入模块: from ecommerce.courses.tests.factories import CourseFactory [as 别名]
# 或者: from ecommerce.courses.tests.factories.CourseFactory import create [as 别名]
def test_course_publish_successfully(self):
""" Verify all courses are successfully published."""
second_course = CourseFactory.create()
self.create_course_ids_file(self.tmp_file_path, [self.course.id, second_course.id])
expected = (
(
LOGGER_NAME,
"INFO",
"Publishing 2 courses."
),
(
LOGGER_NAME,
"INFO",
u"(1/2) Successfully published {}.".format(self.course.id)
),
(
LOGGER_NAME,
"INFO",
u"(2/2) Successfully published {}.".format(second_course.id)),
(
LOGGER_NAME,
"INFO",
"All 2 courses successfully published."
)
)
with mock.patch.object(Course, 'publish_to_lms', autospec=True) as mock_publish:
mock_publish.return_value = None
with LogCapture(LOGGER_NAME) as lc:
call_command('publish_to_lms', course_ids_file=self.tmp_file_path)
lc.check(*expected)
# Check that the mocked function was called twice.
self.assertListEqual(mock_publish.call_args_list, [call(self.course), call(second_course)])