本文整理汇总了Python中tests.functional.actions.login函数的典型用法代码示例。如果您正苦于以下问题:Python login函数的具体用法?Python login怎么用?Python login使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了login函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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',
])
示例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)
示例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)
示例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), [])
示例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'])
示例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)
示例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))
示例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)
示例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'])
示例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)
示例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)
示例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
示例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
示例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))
示例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()