本文整理汇总了Python中tests.functional.actions.login函数的典型用法代码示例。如果您正苦于以下问题:Python login函数的具体用法?Python login怎么用?Python login使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了login函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_parameters_can_be_omitted_if_using_source_context
def test_parameters_can_be_omitted_if_using_source_context(self):
email = '[email protected]'
actions.login(email, is_admin=True)
response = transforms.loads(self.get(
'/rest/data/character/items?filter=rank>=5&ordering=rank'
'&chunk_size=3&page_number=1').body)
source_context = response['source_context']
self._verify_data([self.characters[4], self.characters[6]],
response['data'])
# This should load identical items, without having to respecify
# filters, ordering, chunk_size.
response = transforms.loads(self.get(
'/rest/data/character/items?page_number=1'
'&source_context=%s' % source_context).body)
self.assertEquals(1, response['page_number'])
self._verify_data([self.characters[4], self.characters[6]],
response['data'])
self._assert_have_only_logs(response, [
'Continuing use of existing context',
'fetch page 1 start cursor present; end cursor missing',
'fetch page 1 using limit 3',
'fetch page 1 is partial; not saving end cursor',
])
开发者ID:FilterKaapi,项目名称:course-builder,代码行数:25,代码来源:model_data_sources.py
示例2: test_announcements
def test_announcements(self):
email = '[email protected]'
actions.login(email, is_admin=True)
self._add_announcement({
'title': 'My Test Title',
'date': '2015-02-03 00:00',
'is_draft': False,
'html': 'Four score and seven years ago, our founding fathers'
})
self._add_announcement({
'title': 'My Test Title',
'date': '2015-02-03 00:00',
'is_draft': True,
'html': 'Standing beneath this serene sky, overlooking these',
})
response = self.get('dashboard?action=settings_search')
index_token = self.get_xsrf_token(response.body, 'gcb-index-course')
response = self.post('dashboard?action=index_course',
{'xsrf_token': index_token})
self.execute_all_deferred_tasks()
# This matches an announcement in the Power Searching course
response = self.get(
'search?query=Four%20score%20seven%20years')
self.assertIn('gcb-search-result', response.body)
self.assertIn('announcements#', response.body)
# The draft announcement in Power Searching should not be indexed
response = self.get('search?query=Standing%20beneath%20serene')
self.assertNotIn('gcb-search-result', response.body)
self.assertNotIn('announcements#', response.body)
开发者ID:2023SS,项目名称:coursebuilder-core,代码行数:33,代码来源:search_tests.py
示例3: test_notifications_succeed
def test_notifications_succeed(self):
actions.login(self.STUDENT_EMAIL)
user_id = None
actions.register(self, self.STUDENT_EMAIL)
self.assertIsNone(self._user_id)
self.execute_all_deferred_tasks(
models.StudentLifecycleObserver.QUEUE_NAME)
self.assertIsNotNone(self._user_id)
user_id = self._user_id
self.assertEquals(1, self._num_add_calls)
self.assertEquals(0, self._num_unenroll_calls)
self.assertEquals(0, self._num_reenroll_calls)
actions.unregister(self)
self.execute_all_deferred_tasks(
models.StudentLifecycleObserver.QUEUE_NAME)
self.assertEquals(1, self._num_add_calls)
self.assertEquals(1, self._num_unenroll_calls)
self.assertEquals(0, self._num_reenroll_calls)
with common_utils.Namespace(self.NAMESPACE):
models.StudentProfileDAO.update(
user_id, self.STUDENT_EMAIL, is_enrolled=True)
self.execute_all_deferred_tasks(
models.StudentLifecycleObserver.QUEUE_NAME)
self.assertEquals(1, self._num_add_calls)
self.assertEquals(1, self._num_unenroll_calls)
self.assertEquals(1, self._num_reenroll_calls)
开发者ID:kingctan,项目名称:course-builder,代码行数:30,代码来源:model_models.py
示例4: test_delete_labels_deletes
def test_delete_labels_deletes(self):
actions.login(REGISTERED_STUDENT_EMAIL)
self._verify_labels(
self.put(STUDENT_LABELS_URL,
{'labels': '%d,%d' % (self.foo_id, self.bar_id)}),
[self.foo_id, self.bar_id])
self._verify_labels(self.delete(STUDENT_LABELS_URL), [])
开发者ID:barkinet,项目名称:course-builder,代码行数:7,代码来源:student_labels.py
示例5: test_analytics
def test_analytics(self):
actions.login(REGISTERED_STUDENT_EMAIL)
self.put(STUDENT_LABELS_URL,
{'labels': '%d,%d' % (
self.foo_id, self.quux_id)})
actions.login(ADMIN_EMAIL)
response = self.get(ANALYTICS_URL)
self.submit(response.forms['gcb-run-visualization-labels_on_students'],
response)
self.execute_all_deferred_tasks()
rest_url = (
'/%s/rest/data/labels_on_students/items' % COURSE_NAME +
'?data_source_token=%s&page_number=0&chunk_size=0' %
crypto.XsrfTokenManager.create_xsrf_token('data_source_access'))
label_counts = transforms.loads(self.get(rest_url).body)
self.assertEquals(
[{'title': 'Quux',
'count': 1,
'type': 'General',
'description': ''},
{'title': 'Bar',
'count': 0,
'type': 'Course Track',
'description': ''},
{'title': 'Baz',
'count': 0,
'type': 'Course Track',
'description': ''},
{'title': 'Foo',
'count': 1,
'type': 'Course Track',
'description': ''}],
label_counts['data'])
开发者ID:barkinet,项目名称:course-builder,代码行数:35,代码来源:student_labels.py
示例6: test_get_current_user_delegates_to_gae_users_service
def test_get_current_user_delegates_to_gae_users_service(self):
actions.login(self.email)
users_result = users.get_current_user()
gae_users_result = gae_users.get_current_user()
self.assert_service_results_equal_and_not_none(
users_result, gae_users_result)
开发者ID:barkinet,项目名称:course-builder,代码行数:7,代码来源:common_users.py
示例7: test_multiple_courses
def test_multiple_courses(self):
user = self.make_test_user(self.STUDENT_EMAIL)
COURSE_TWO = 'course_two'
COURSE_TWO_NS = 'ns_' + COURSE_TWO
actions.simple_add_course(
COURSE_TWO, self.ADMIN_EMAIL, 'Data Removal Test Two')
actions.login(user.email())
actions.register(self, user.email(), course=self.COURSE)
actions.register(self, user.email(), course=COURSE_TWO)
actions.unregister(self, self.COURSE, do_data_removal=True)
self.execute_all_deferred_tasks(
models.StudentLifecycleObserver.QUEUE_NAME)
self.get(
data_removal.DataRemovalCronHandler.URL,
headers={'X-AppEngine-Cron': 'True'})
self.execute_all_deferred_tasks()
with common_utils.Namespace(self.NAMESPACE):
self.assertIsNone(models.Student.get_by_user(user))
with common_utils.Namespace(COURSE_TWO_NS):
self.assertIsNotNone(
models.Student.get_by_user(user))
开发者ID:kingctan,项目名称:course-builder,代码行数:26,代码来源:modules_data_removal.py
示例8: test_delete_link_when_registered_then_cancel_deletion
def test_delete_link_when_registered_then_cancel_deletion(self):
actions.login(self.STUDENT_EMAIL)
actions.register(self, self.STUDENT_EMAIL)
response = self.get('course')
response = self.click(response, 'Delete My Data')
self._unregister_flow(response, with_deletion_checked=True,
cancel_on_deletion=True)
开发者ID:mmoylan,项目名称:course-builder,代码行数:7,代码来源:modules_data_removal.py
示例9: test_non_admin_permissions_failures
def test_non_admin_permissions_failures(self):
actions.login(STUDENT_EMAIL)
student_xsrf_token = crypto.XsrfTokenManager.create_xsrf_token(
settings.HtmlHookRESTHandler.XSRF_ACTION)
response = self.get(ADMIN_SETTINGS_URL)
self.assertEquals(200, response.status_int)
payload = transforms.loads(response.body)
self.assertEquals(401, payload['status'])
self.assertEquals('Access denied.', payload['message'])
response = self.put(ADMIN_SETTINGS_URL, {'request': transforms.dumps({
'key': 'base:after_body_tag_begins',
'xsrf_token': cgi.escape(student_xsrf_token),
'payload': '{}'})})
payload = transforms.loads(response.body)
self.assertEquals(401, payload['status'])
self.assertEquals('Access denied.', payload['message'])
response = self.delete(ADMIN_SETTINGS_URL + '?xsrf_token=' +
cgi.escape(student_xsrf_token))
self.assertEquals(200, response.status_int)
payload = transforms.loads(response.body)
self.assertEquals(401, payload['status'])
self.assertEquals('Access denied.', payload['message'])
开发者ID:mmoylan,项目名称:course-builder,代码行数:25,代码来源:admin_settings.py
示例10: test_enrollment
def test_enrollment(self):
actions.logout()
response = self.get_response(
'{course(id: "%s") {enrollment {email enrolled}}}' % (
self.course_id))
enrollment = response['data']['course']['enrollment']
self.assertEquals({'enrolled': False, 'email': None}, enrollment)
actions.login(STUDENT_EMAIL)
response = self.get_response(
'{course(id: "%s") {enrollment {email enrolled}}}' % (
self.course_id))
enrollment = response['data']['course']['enrollment']
self.assertEquals({'enrolled': False, 'email': None}, enrollment)
actions.register(self, STUDENT_NAME)
response = self.get_response(
'{course (id: "%s") { enrollment { email enrolled}}}' % (
self.course_id))
enrollment = response['data']['course']['enrollment']
self.assertEquals(
{'enrolled': True, 'email': STUDENT_EMAIL}, enrollment)
开发者ID:google,项目名称:coursebuilder-core,代码行数:25,代码来源:gql_tests.py
示例11: test_multiple_students
def test_multiple_students(self):
# Register two students
user = actions.login(self.STUDENT_EMAIL)
actions.register(self, user.email(), course=self.COURSE)
other_user = actions.login('[email protected]')
actions.register(self, other_user.email(), course=self.COURSE)
# Get IDs of those students; make an event for each.
with common_utils.Namespace(self.NAMESPACE):
student1_id = (
models.Student.get_by_user(user).user_id)
student2_id = (
models.Student.get_by_user(other_user).user_id)
models.EventEntity(user_id=student1_id, source='test').put()
models.EventEntity(user_id=student2_id, source='test').put()
# Unregister one of them.
actions.login(self.STUDENT_EMAIL)
self._unregister_and_request_data_removal(self.COURSE)
self._complete_removal()
# Unregistered student and his data are gone; still-registered
# student's data is still present.
with common_utils.Namespace(self.NAMESPACE):
self.assertIsNone(models.Student.get_by_user(user))
self.assertIsNotNone(models.Student.get_by_user(other_user))
entities = list(models.EventEntity.all().run())
self.assertEquals(1, len(entities))
self.assertEquals(student2_id, entities[0].user_id)
开发者ID:mmoylan,项目名称:course-builder,代码行数:30,代码来源:modules_data_removal.py
示例12: setUp
def setUp(self):
super(CourseCachingTest, self).setUp()
self.app_context = actions.simple_add_course(
self.COURSE_NAME, self.ADMIN_EMAIL, 'Test Course')
self.course = courses.Course(handler=None, app_context=self.app_context)
actions.login(self.ADMIN_EMAIL)
config.Registry.test_overrides[models.CAN_USE_MEMCACHE.name] = True
开发者ID:danieldalonzo,项目名称:coursebuilder-core,代码行数:7,代码来源:model_courses.py
示例13: setUp
def setUp(self):
super(RolesTest, self).setUp()
actions.login(COURSE_ADMIN_EMAIL, is_admin=True)
payload_dict = {
'name': COURSE_NAME,
'title': 'Roles Test',
'admin_email': COURSE_ADMIN_EMAIL}
request = {
'payload': transforms.dumps(payload_dict),
'xsrf_token': crypto.XsrfTokenManager.create_xsrf_token(
'add-course-put')}
response = self.testapp.put('/rest/courses/item?%s' % urllib.urlencode(
{'request': transforms.dumps(request)}), {})
self.assertEquals(response.status_int, 200)
sites.setup_courses('course:/%s::ns_%s, course:/:/' % (
COURSE_NAME, COURSE_NAME))
actions.logout()
config.Registry.test_overrides[roles.GCB_ADMIN_LIST.name] = (
'[%s]' % SITE_ADMIN_EMAIL)
# pylint: disable-msg=protected-access
self.old_registered_permission = roles.Roles._REGISTERED_PERMISSIONS
roles.Roles._REGISTERED_PERMISSIONS = {}
config.Registry.test_overrides[models.CAN_USE_MEMCACHE.name] = True
开发者ID:CSCI1200Course,项目名称:csci1200OnlineCourse,代码行数:27,代码来源:roles.py
示例14: test_is_user_allowed_assigned_permission
def test_is_user_allowed_assigned_permission(self):
self.assertFalse(roles.Roles.is_user_allowed(
self._get_course(), PERMISSION_MODULE, PERMISSION))
self._create_role()
actions.login(STUDENT_EMAIL)
self.assertTrue(roles.Roles.is_user_allowed(
self._get_course(), PERMISSION_MODULE, PERMISSION))
开发者ID:CSCI1200Course,项目名称:csci1200OnlineCourse,代码行数:7,代码来源:roles.py
示例15: setUp
def setUp(self):
super(MathTagTests, self).setUp()
actions.login(ADMIN_EMAIL, is_admin=True)
self.base = '/' + COURSE_NAME
test_course = actions.simple_add_course(COURSE_NAME, ADMIN_EMAIL,
'Test Course')
self.course = courses.Course(None, test_course)
math_unit = self.course.add_unit()
math_unit.title = 'math_test_unit'
no_math_unit = self.course.add_unit()
no_math_unit.title = 'no_math_test_unit'
self.math_unit_id = math_unit.unit_id
self.no_math_unit_id = no_math_unit.unit_id
no_math_lesson = self.course.add_lesson(no_math_unit)
no_math_lesson.title = 'Lesson without any mathematical formula.'
no_math_lesson.objectives = 'This lesson does not contain a math tag.'
math_lesson = self.course.add_lesson(math_unit)
math_lesson.title = 'First lesson with mathematical formula'
math_lesson.objectives = (
'<gcb-math input_type="TeX" instanceid="X99HibNGBIX4">'
'x^2+2x+1'
'</gcb-math><br>')
self.course.save()
开发者ID:2023SS,项目名称:coursebuilder-core,代码行数:29,代码来源:modules_math.py
示例16: setUp
def setUp(self):
super(ExtraTabsTests, self).setUp()
self.base = '/' + COURSE_NAME
app_context = actions.simple_add_course(
COURSE_NAME, ADMIN_EMAIL, 'Extra Tabs Course')
self.old_namespace = namespace_manager.get_namespace()
namespace_manager.set_namespace('ns_%s' % COURSE_NAME)
self.course = courses.Course(None, app_context)
courses.Course.ENVIRON_TEST_OVERRIDES = {
'course': {
'extra_tabs': [
{
'label': 'FAQ',
'position': 'left',
'visibility': 'all',
'url': '',
'content': 'Frequently asked questions'},
{
'label': 'Resources',
'position': 'right',
'visibility': 'student',
'url': 'http://www.example.com',
'content': 'Links to resources'}]
}
}
self.faq_url = 'modules/extra_tabs/render?index=0'
actions.login(STUDENT_EMAIL, is_admin=False)
actions.register(self, STUDENT_NAME)
开发者ID:2023SS,项目名称:coursebuilder-core,代码行数:32,代码来源:extra_tabs_tests.py
示例17: test_is_current_user_admin_delegates_to_gae_users_service
def test_is_current_user_admin_delegates_to_gae_users_service(self):
actions.login(self.email, is_admin=True)
users_result = users.is_current_user_admin()
gae_users_result = users.is_current_user_admin()
self.assertTrue(users_result)
self.assertTrue(gae_users_result)
开发者ID:barkinet,项目名称:course-builder,代码行数:7,代码来源:common_users.py
示例18: setUp
def setUp(self):
super(ExampleEmbedAndHandlerV1ChildCoursesTest, self).setUp()
self.student_email = "[email protected]"
actions.login(self.student_email)
actions.simple_add_course("parent", self.admin_email, "Parent")
actions.simple_add_course("child1", self.admin_email, "Child1")
actions.simple_add_course("child2", self.admin_email, "Child2")
开发者ID:jumasheff,项目名称:coursebuilder-core,代码行数:7,代码来源:embed_tests.py
示例19: test_descriptions
def test_descriptions(self):
context = actions.simple_add_course(
COURSE_NAME, ADMIN_EMAIL, COURSE_TITLE)
course = courses.Course(None, context)
unit = course.add_unit()
unit.title = 'The Unit'
unit.availability = courses.AVAILABILITY_AVAILABLE
unit.description = UNIT_DESCRIPTION
assessment = course.add_assessment()
assessment.title = 'The Assessment'
assessment.availability = courses.AVAILABILITY_AVAILABLE
assessment.description = ASSESSMENT_DESCRIPTION
link = course.add_link()
link.title = 'The Link'
link.availability = courses.AVAILABILITY_AVAILABLE
link.description = LINK_DESCRIPTION
course.save()
actions.login(ADMIN_EMAIL)
response = self.get(BASE_URL)
self.assertIn(unit.description, response)
self.assertIn(assessment.description, response)
self.assertIn(link.description, response)
开发者ID:2023SS,项目名称:coursebuilder-core,代码行数:26,代码来源:unit_description.py
示例20: test_oeditor_returns_state
def test_oeditor_returns_state(self):
actions.login('[email protected]', is_admin=True)
xsrf_token = crypto.XsrfTokenManager.create_xsrf_token(
oeditor.EditorPrefsRestHandler.XSRF_TOKEN)
self._post(xsrf_token=xsrf_token)
response = self.get('dashboard?action=edit_lesson&key=%s' % (
self.lesson.lesson_id))
expected = {
'xsrf_token': xsrf_token,
'location': self.location,
'key': str(self.key),
'prefs': self.EDITOR_STATE
}
expected = transforms.loads(transforms.dumps(expected))
match = re.search(
r'cb_global.editor_prefs = JSON.parse\((.*)\);', response.body)
actual = match.group(1)
actual = transforms.loads('"%s"' % actual)
actual = transforms.loads(actual[1:-1])
self.assertEquals(expected, actual)
开发者ID:danieldalonzo,项目名称:coursebuilder-core,代码行数:25,代码来源:modules_oeditor.py
注:本文中的tests.functional.actions.login函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论