当前位置: 首页>>代码示例>>Python>>正文


Python tests.make_request函数代码示例

本文整理汇总了Python中treemap.tests.make_request函数的典型用法代码示例。如果您正苦于以下问题:Python make_request函数的具体用法?Python make_request怎么用?Python make_request使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了make_request函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_can_change_admin_without_feature

    def test_can_change_admin_without_feature(self):
        iuser = InstanceUser(user=self.user2, instance=self.instance,
                             role=self.instance.default_role)
        iuser.save_with_user(self.commander)

        body = {'users':
                {iuser.pk: {'admin': False}}}

        update_user_roles(
            make_request(method='POST',
                         body=json.dumps(body),
                         user=self.commander),
            self.instance)

        #requery iuser
        iuser = InstanceUser.objects.get(pk=iuser.pk)
        self.assertEqual(iuser.admin, False)

        body = {'users':
                {iuser.pk: {'admin': True}}}

        update_user_roles(
            make_request(method='POST',
                         body=json.dumps(body),
                         user=self.commander),
            self.instance)

        #requery iuser
        iuser = InstanceUser.objects.get(pk=iuser.pk)
        self.assertEqual(iuser.admin, True)
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:30,代码来源:test_roles.py

示例2: test_export_users_json_make_info_public

    def test_export_users_json_make_info_public(self):
        self.user1.make_info_public = True
        self.user1.save()

        resp = users_json(make_request(), self.instance)

        data = json.loads(resp.content)

        commander, user1data, user2data = data

        self.assertEquals(commander['username'], self.commander.username)
        self.assertEquals(user1data.get('email'), None)
        self.assertUserJSON(user1data,
                            {'username': self.user1.username,
                             'email_hash': self.user1.email_hash,
                             'first_name': self.user1.first_name,
                             'last_name': self.user1.last_name,
                             'organization': self.user1.organization,
                             'allow_email_contact': 'False',
                             'role': 'commander',
                             'created': str(self.user1.created)})

        self.assertUserJSON(user2data,
                            {'last_edit_model': 'Tree',
                             'last_edit_model_id': str(self.tree.pk),
                             'last_edit_instance_id': str(self.instance.pk),
                             'last_edit_user_id': str(self.user2.pk),
                             'email': '[email protected]',
                             'email_hash': self.user2.email_hash})
开发者ID:RickMohr,项目名称:otm-core,代码行数:29,代码来源:tests.py

示例3: get_csv_data_with_base_assertions

    def get_csv_data_with_base_assertions(self):
        resp = users_csv(make_request(), self.instance)
        reader = csv.reader(resp)

        # Skip BOM and entry line
        reader.next()
        reader.next()

        header = reader.next()

        data = [dict(zip(header, [x.decode('utf8') for x in row]))
                for row in reader]

        commander, user1data, user2data = data
        self.assertEquals(commander['username'], self.commander.username)
        self.assertUserJSON(user1data,
                            {'username': self.user1.username,
                             'email': '',
                             'email_hash': self.user1.email_hash,
                             'allow_email_contact': 'False',
                             'role': 'commander',
                             'created': str(self.user1.created),
                             'last_edit_model': 'Plot',
                             'last_edit_model_id': str(self.plot.pk),
                             'last_edit_instance_id': str(self.instance.pk),
                             'last_edit_user_id': str(self.user1.pk)})

        self.assertUserJSON(user2data,
                            {'email': '[email protected]',
                             'email_hash': self.user2.email_hash,
                             'last_edit_model': 'Tree',
                             'last_edit_model_id': str(self.tree.pk),
                             'last_edit_instance_id': str(self.instance.pk),
                             'last_edit_user_id': str(self.user2.pk)})
        return data
开发者ID:RickMohr,项目名称:otm-core,代码行数:35,代码来源:tests.py

示例4: test_email_not_found_creates_invite

    def test_email_not_found_creates_invite(self):
        self.assertEqual(InstanceInvitation.objects.count(), 0)

        mail.outbox = []

        email = '[email protected]'
        body = {'email': email}
        create_user_role(
            make_request(method='POST',
                         body=json.dumps(body),
                         user=self.commander),
            self.instance)

        self.assertEqual(InstanceInvitation.objects.count(), 1)

        ii = InstanceInvitation.objects.all()[0]

        # Should have email and default role
        self.assertEqual(ii.email, email)
        self.assertEqual(ii.instance, self.instance)
        self.assertEqual(ii.role, self.instance.default_role)

        # Should have sent an email to the user
        self.assertEqual(len(mail.outbox), 1)

        msg = mail.outbox[0]

        # Just make sure we have some chars and the
        # correct receiver
        self.assertGreater(len(msg.subject), 10)
        self.assertGreater(len(msg.body), 10)

        self.assertEquals(tuple(msg.to), (email,))
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:33,代码来源:test_roles.py

示例5: test_export_users_json

    def test_export_users_json(self):
        resp = users_json(make_request(), self.instance)

        data = json.loads(resp.content)

        commander, user1data, user2data = data

        self.assertEquals(commander['username'], self.commander.username)

        self.assertEquals(user1data['username'], self.user1.username)
        self.assertEquals(user1data.get('email'), None)
        self.assertEquals(user1data['email_hash'], self.user1.email_hash)
        self.assertEquals(user1data['first_name'], self.user1.first_name)
        self.assertEquals(user1data['last_name'], self.user1.last_name)
        self.assertEquals(user1data['organization'], self.user1.organization)
        self.assertEquals(user1data['allow_email_contact'], 'False')
        self.assertEquals(user1data['role'], 'commander')
        self.assertEquals(user1data['created'], str(self.user1.created))

        self.assertEquals(user1data['last_edit_model'], 'Plot')
        self.assertEquals(user1data['last_edit_model_id'], str(self.plot.pk))
        self.assertEquals(user1data['last_edit_instance_id'],
                          str(self.instance.pk))

        self.assertEquals(user1data['last_edit_user_id'], str(self.user1.pk))

        self.assertEquals(user2data['email'], '[email protected]')
        self.assertEquals(user2data['email_hash'], self.user2.email_hash)
        self.assertEquals(user2data['last_edit_model'], 'Tree')
        self.assertEquals(user2data['last_edit_model_id'], str(self.tree.pk))
        self.assertEquals(user2data['last_edit_instance_id'],
                          str(self.instance.pk))

        self.assertEquals(user2data['last_edit_user_id'], str(self.user2.pk))
开发者ID:cgarrard,项目名称:OTM2,代码行数:34,代码来源:tests.py

示例6: test_export_users_json_keep_info_private

    def test_export_users_json_keep_info_private(self):
        resp = users_json(make_request(), self.instance)

        data = json.loads(resp.content)

        commander, user1data, user2data = data
        self.assertFalse('first_name' in user1data)
开发者ID:RickMohr,项目名称:otm-core,代码行数:7,代码来源:tests.py

示例7: test_min_join_date

    def test_min_join_date(self):
        last_week = now() - datetime.timedelta(days=7)
        two_days_ago = now() - datetime.timedelta(days=2)
        yesterday = now() - datetime.timedelta(days=1)
        tda_ts = two_days_ago.strftime(DATETIME_FORMAT)

        Audit.objects.filter(model='InstanceUser')\
            .filter(model_id=self.user1.get_instance_user(self.instance).pk)\
            .update(created=last_week)

        Audit.objects.filter(model='InstanceUser')\
            .filter(model_id=
                    self.commander.get_instance_user(self.instance).pk)\
            .update(created=last_week)

        Audit.objects.filter(model='InstanceUser')\
            .filter(model_id=self.user2.get_instance_user(self.instance).pk)\
            .update(created=yesterday)

        resp = users_json(make_request({'minJoinDate': tda_ts}), self.instance)

        data = json.loads(resp.content)

        self.assertEquals(len(data), 1)

        self.assertEquals(data[0]['username'], self.user2.username)
开发者ID:RickMohr,项目名称:otm-core,代码行数:26,代码来源:tests.py

示例8: _add_user_to_instance_view

 def _add_user_to_instance_view(self, email):
         body = {'email': email}
         return create_user_role(
             make_request(method='POST',
                          body=json.dumps(body),
                          user=self.commander),
             self.instance)
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:7,代码来源:test_roles.py

示例9: test_invites_updated

    def test_invites_updated(self):
        email = "[email protected]"
        invite = InstanceInvitation(email=email,
                                    instance=self.instance,
                                    created_by=self.user4,
                                    role=self.instance.default_role)
        invite.save()

        new_role = Role(name='Ambassador', instance=self.instance,
                        rep_thresh=0)
        new_role.save()

        body = {'invites':
                {invite.pk:
                 {'role': new_role.pk}}}

        update_user_roles(
            make_request(method='POST',
                         body=json.dumps(body),
                         user=self.commander),
            self.instance)

        # requery invite
        invite = InstanceInvitation.objects.get(pk=invite.pk)
        self.assertEqual(invite.role, new_role)
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:25,代码来源:test_roles.py

示例10: test_export_view_permission_failure

 def test_export_view_permission_failure(self):
     request = make_request(user=self.unprivileged_user)
     begin_ctx = begin_export(request, self.instance, 'tree')
     check_ctx = check_export(request, self.instance, begin_ctx['job_id'])
     self.assertEqual(check_ctx['status'], 'MODEL_PERMISSION_ERROR')
     self.assertEqual(check_ctx['message'],
                      'User has no permissions on this model')
开发者ID:RickMohr,项目名称:otm-core,代码行数:7,代码来源:tests.py

示例11: test_invalid_email

 def test_invalid_email(self):
     body = {'email': '[email protected]'}
     self.assertRaises(ValidationError,
                       create_user_role,
                       make_request(method='POST',
                                    body=json.dumps(body),
                                    user=self.commander),
                       self.instance)
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:8,代码来源:test_roles.py

示例12: test_hide

    def test_hide(self):
        self.assertFalse(self.comment.is_removed)
        req = make_request(_comment_ids_to_params(self.comment.id),
                           user=self.user, method='POST')
        hide(req, self.instance)

        updated_comment = EnhancedThreadedComment.objects.get(
            pk=self.comment.id)
        self.assertTrue(updated_comment.is_removed)
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:9,代码来源:tests.py

示例13: test_batch_hide

 def test_batch_hide(self):
     self.assertFalse(self.comment.is_removed)
     self.assertFalse(self.comment2.is_removed)
     params = _comment_ids_to_params(self.comment.id, self.comment2.id)
     req = make_request(params, user=self.user, method='POST')
     hide(req, self.instance)
     updated_comments = EnhancedThreadedComment.objects.all()
     for updated_comment in updated_comments:
         self.assertTrue(updated_comment.is_removed)
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:9,代码来源:tests.py

示例14: testSearchBenefits

    def testSearchBenefits(self):
        request = make_request(
            {'q': json.dumps({'tree.readonly': {'IS': False}})})  # all trees
        request.instance_supports_ecobenefits = self.instance\
                                                    .has_itree_region()
        result = search_tree_benefits(request, self.instance)

        benefits = result['benefits']

        self.assertTrue(len(benefits) > 0)
开发者ID:PyBulls,项目名称:OTM2,代码行数:10,代码来源:ecobenefits.py

示例15: test_get_udfs

    def test_get_udfs(self):
        resp = udf_list(make_request(), self.instance)

        self.assertIn('udf_models', resp)
        plot_udfs = [m for m in resp['udf_models']
                     if m['name'] == 'Plot']
        self.assertEqual(len(plot_udfs), 1)
        self.assertIn('specs', plot_udfs[0])
        plain_udfs = [s['udf'] for s in plot_udfs[0]['specs']
                      if not s['udf'].iscollection]
        self.assertEqual(len(plain_udfs), 1)
        self.assertEqual(plain_udfs[0].pk, self.udf.pk)
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:12,代码来源:test_udf.py


注:本文中的treemap.tests.make_request函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。