python类Client()的实例源码

test_login_is_logged.py 文件源码 项目:django-useraudit 作者: muccg 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def test_long_user_agent_is_truncated(self):
        user_agent_field_length = m.LoginLog._meta.get_field('user_agent').max_length
        long_user_agent = 'x' * (user_agent_field_length) + 'this should be truncated'

        client = Client(REMOTE_ADDR='192.168.1.1', HTTP_USER_AGENT=long_user_agent)
        client.post('/admin/login/', {
                    'username': 'john',
                    'password': 'sue',
                    'this_is_the_login_form': 1,
        })
        log = m.LoginLog.objects.all()[0]
        self.assertEquals(len(log.user_agent), user_agent_field_length)
        self.assertTrue(long_user_agent.startswith(log.user_agent))
test_login_is_logged.py 文件源码 项目:django-useraudit 作者: muccg 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_ip_forwarded_by_proxies(self):
        client = Client(REMOTE_ADDR='3.3.3.3',
                        HTTP_X_FORWARDED_FOR='192.168.1.1, 1.1.1.1, 2.2.2.2')
        client.post('/admin/login/', {
                    'username': 'john',
                    'password': 'sue',
                    'this_is_the_login_form': 1,
        })
        log = m.LoginLog.objects.first()
        self.assertIsNotNone(log)
        self.assertEquals(log.ip_address, '192.168.1.1')
        self.assertEquals(log.forwarded_by, '3.3.3.3,2.2.2.2,1.1.1.1')
tests.py 文件源码 项目:daisychain 作者: daisychainme 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def setUp(self):
        self.client = Client()
        self.user = self.create_user()
        self.user.save()
        self.trigger_channel = self.create_channel("Twitter")
        self.action_channel = self.trigger_channel
        self.trigger = self.create_trigger(channel=self.trigger_channel,
                                           trigger_type=200,
                                           name="New Image")
        self.action = self.create_action(channel=self.action_channel,
                                         action_type=200,
                                         name="Post Image")
        self.trigger_output = "image_data"
        self.trigger_input = self.create_trigger_input(trigger=self.trigger,
                                                       name="test input")
        self.action_input = self.create_action_input(self.action,
                                                     "image_data",
                                                     "image")
        self.recipe = self.create_recipe(self.trigger, self.action, self.user)
        self.recipe_mapping = self.create_recipe_mapping(
                self.recipe,
                self.trigger_output,
                self.action_input)
        self.recipe_condition = self.create_recipe_condition(
                self.recipe,
                self.trigger_input,
                "test value")
        self.payload = {"foo": "bar"}

        self.conditions_dict = {"test input": "test value"}
test_views.py 文件源码 项目:daisychain 作者: daisychainme 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def setUp(self):
        self.client = Client()
        self.user = self.create_user()


问题


面经


文章

微信
公众号

扫码关注公众号