本文整理汇总了Python中student.tests.factories.UserFactory.get_full_name方法的典型用法代码示例。如果您正苦于以下问题:Python UserFactory.get_full_name方法的具体用法?Python UserFactory.get_full_name怎么用?Python UserFactory.get_full_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类student.tests.factories.UserFactory
的用法示例。
在下文中一共展示了UserFactory.get_full_name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CreditMessagesTests
# 需要导入模块: from student.tests.factories import UserFactory [as 别名]
# 或者: from student.tests.factories.UserFactory import get_full_name [as 别名]
class CreditMessagesTests(ModuleStoreTestCase, CreditApiTestBase):
"""
Test dashboard messages of credit course.
"""
FINAL_GRADE = 0.8
def setUp(self):
super(CreditMessagesTests, self).setUp()
self.student = UserFactory()
self.student.set_password('test') # pylint: disable=no-member
self.student.save() # pylint: disable=no-member
self.client.login(username=self.student.username, password='test')
# New Course
self.course = CourseFactory.create()
self.enrollment = CourseEnrollment.enroll(self.student, self.course.id)
def _set_creditcourse(self):
"""
Mark the course to credit
"""
# pylint: disable=attribute-defined-outside-init
self.first_provider = CreditProvider.objects.create(
provider_id="ASU",
display_name="Arizona State University",
provider_url="google.com",
enable_integration=True
) # pylint: disable=attribute-defined-outside-init
self.second_provider = CreditProvider.objects.create(
provider_id="MIT",
display_name="Massachusetts Institute of Technology",
provider_url="MIT.com",
enable_integration=True
) # pylint: disable=attribute-defined-outside-init
self.credit_course = CreditCourse.objects.create(course_key=self.course.id, enabled=True) # pylint: disable=attribute-defined-outside-init
self.credit_course.providers.add(self.first_provider)
self.credit_course.providers.add(self.second_provider)
def _set_user_eligible(self, credit_course, username):
"""
Mark the user eligible for credit for the given credit course.
"""
self.eligibility = CreditEligibility.objects.create(username=username, course=credit_course) # pylint: disable=attribute-defined-outside-init
def test_user_request_status(self):
request_status = api.get_credit_request_status(self.student.username, self.course.id)
self.assertEqual(len(request_status), 0)
def test_credit_messages(self):
self._set_creditcourse()
requirement = CreditRequirement.objects.create(
course=self.credit_course,
namespace="grade",
name="grade",
active=True
)
status = CreditRequirementStatus.objects.create(
username=self.student.username,
requirement=requirement,
)
status.status = "satisfied"
status.reason = {"final_grade": self.FINAL_GRADE}
status.save()
self._set_user_eligible(self.credit_course, self.student.username)
response = self.client.get(reverse("dashboard"))
self.assertContains(
response,
"<b>Congratulations</b> {}, You have meet requirements for credit.".format(
self.student.get_full_name() # pylint: disable=no-member
)
)
api.create_credit_request(self.course.id, self.first_provider.provider_id, self.student.username)
response = self.client.get(reverse("dashboard"))
self.assertContains(
response,
'Thank you, your payment is complete, your credit is processing. '
'Please see {provider_link} for more information.'.format(
provider_link='<a href="#" target="_blank">{provider_name}</a>'.format(
provider_name=self.first_provider.display_name
)
)
)
def test_query_counts(self):
# This check the number of queries executed while rendering the
# credit message to display on the dashboard.
# - 1 query: Check the user's eligibility.
# - 1 query: Get the user credit requests.
self._set_creditcourse()
requirement = CreditRequirement.objects.create(
course=self.credit_course,
#.........这里部分代码省略.........