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


Python test.Client方法代码示例

本文整理汇总了Python中django.test.Client方法的典型用法代码示例。如果您正苦于以下问题:Python test.Client方法的具体用法?Python test.Client怎么用?Python test.Client使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.test的用法示例。


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

示例1: client

# 需要导入模块: from django import test [as 别名]
# 或者: from django.test import Client [as 别名]
def client():
    """Django Test Client, with some convenient overriden methods.
    """
    from django.test import Client

    class _Client(Client):
        @property
        def json(self):
            """Add json method on the client for sending json type request.

            Usages:
            >>> import json
            >>> url = reverse("phone-verify")
            >>> client.json.get(url)
            >>> client.json.post(url, data=json.dumps(payload))
            """
            return PartialMethodCaller(
                obj=self, content_type='application/json;charset="utf-8"'
            )

    return _Client() 
开发者ID:CuriousLearner,项目名称:django-phone-verify,代码行数:23,代码来源:conftest.py

示例2: setUp

# 需要导入模块: from django import test [as 别名]
# 或者: from django.test import Client [as 别名]
def setUp(self):
        self.c = Client()
        self.credentials = {
            'username': 'voteusername',
            'password': 'password'
        }

        author = RedditUser.objects.create(
            user=User.objects.create_user(
                **self.credentials
            )
        )

        submission = Submission.objects.create(
            author=author,
            author_name=author.user.username,
            title="vote testing"
        )

        Comment.create(author=author,
                       raw_comment="root comment",
                       parent=submission).save() 
开发者ID:nikolak,项目名称:django_reddit,代码行数:24,代码来源:test_voting.py

示例3: setUp

# 需要导入模块: from django import test [as 别名]
# 或者: from django.test import Client [as 别名]
def setUp(self):
        self.c = Client()
        author = RedditUser.objects.create(
            user=User.objects.create_user(username="username",
                                          password="password"))

        for i in range(50):
            Submission.objects.create(score=50 - i,
                                      title=get_random_string(length=20),
                                      author=author).save()

        for i in range(1, 50, 10):
            # [1, 11, 21] [31, 41] have upvotes (lists demonstrate pages)
            Vote.create(user=author,
                        vote_object=Submission.objects.get(id=i),
                        vote_value=1).save()

        for i in range(2, 50, 15):
            # [2, 17] [32, 47] have downvotes (lists demonstrate pages)
            Vote.create(user=author,
                        vote_object=Submission.objects.get(id=i),
                        vote_value=-1).save() 
开发者ID:nikolak,项目名称:django_reddit,代码行数:24,代码来源:test_frontpage.py

示例4: testNoEncryptMessageNoMdn

# 需要导入模块: from django import test [as 别名]
# 或者: from django.test import Client [as 别名]
def testNoEncryptMessageNoMdn(self):
        """ Test Permutation 1: Sender sends un-encrypted data and does NOT request a receipt. """

        # Create the partner with appropriate settings for this case
        partner = models.Partner.objects.create(name='Client Partner',
                                                as2_name='as2server',
                                                target_url='http://localhost:8080/pyas2/as2receive',
                                                compress=False,
                                                mdn=False)

        # Build and send the message to server
        message_id = emailutils.make_msgid().strip('<>')
        in_message, response = self.buildSendMessage(message_id, partner)

        # Check if a 200 response was received
        self.assertEqual(response.status_code, 200)

        # Check if message was processed successfully
        out_message = models.Message.objects.get(message_id=message_id)
        self.assertEqual(out_message.status, 'S')

        # Check if input and output files are the same
        self.assertTrue(AS2SendReceiveTest.compareFiles(self.payload.file, out_message.payload.file)) 
开发者ID:abhishek-ram,项目名称:pyas2,代码行数:25,代码来源:tests.py

示例5: setUp

# 需要导入模块: from django import test [as 别名]
# 或者: from django.test import Client [as 别名]
def setUp(self):
        self.client = Client()
        self.user = User.objects.create(
            first_name='Ravi',
            last_name='G',
            email='ravi@micropyramid.com',
            username='ravi@micropyramid.com',
            is_superuser=True
        )
        self.password = 'secret'
        self.user.set_password(self.password)
        self.user.save()
        self.category = ForumCategory.objects.create(
            created_by=self.user,
            title='Python',
            is_active=True,
            slug='python',
            description='dynamic programming language'
        ) 
开发者ID:MicroPyramid,项目名称:django-simple-forum,代码行数:21,代码来源:tests.py

示例6: setUp

# 需要导入模块: from django import test [as 别名]
# 或者: from django.test import Client [as 别名]
def setUp(self):
        self.client = Client()
        self.token = generate_token() 
开发者ID:kimeraapp,项目名称:pythonjobs.ie,代码行数:5,代码来源:test_services.py

示例7: setUp

# 需要导入模块: from django import test [as 别名]
# 或者: from django.test import Client [as 别名]
def setUp(self):
        self.client = Client()
        self.job = Job()
        self.job.position = "test"
        self.job.company_name = "company test"
        self.job.website = "pythonjobs.ie"
        self.job.category = "full"
        self.job.description = "Testing"
        self.job.email = "test@test.com"
        self.job.location = "Testing"
        self.job.save() 
开发者ID:kimeraapp,项目名称:pythonjobs.ie,代码行数:13,代码来源:test_views.py

示例8: setUp

# 需要导入模块: from django import test [as 别名]
# 或者: from django.test import Client [as 别名]
def setUp(self):
        # Every test needs access to the request factory.
        self.factory = RequestFactory()
        self.user = User.objects.create_user(
            username='John Doe',
            email='',
            password='test')
        self.c = Client() 
开发者ID:OpenMDM,项目名称:OpenMDM,代码行数:10,代码来源:tests.py

示例9: test_supports_cors

# 需要导入模块: from django import test [as 别名]
# 或者: from django.test import Client [as 别名]
def test_supports_cors(self):
        client = Client()
        response = client.options('/', HTTP_ORIGIN='https://example.com/', secure=True)

        self.assertEqual(response.status_code, 200)
        self.assertEqual(response['Access-Control-Allow-Origin'], '*') 
开发者ID:apiaryio,项目名称:polls-api,代码行数:8,代码来源:tests.py

示例10: setUp

# 需要导入模块: from django import test [as 别名]
# 或者: from django.test import Client [as 别名]
def setUp(self):
        self.client = Client() 
开发者ID:apiaryio,项目名称:polls-api,代码行数:4,代码来源:tests.py

示例11: setUp

# 需要导入模块: from django import test [as 别名]
# 或者: from django.test import Client [as 别名]
def setUp(self):
        demo = User()
        demo.username = 'demo'
        demo.first_name = 'Demo'
        demo.last_name = 'Last'
        demo.set_password('demo123')
        demo.is_staff = False
        demo.save()
        self.user = demo
        self.user_path = os.path.join('data', 'users', 'demo')
        self.chrome = Client()
        self.upload_files = [] 
开发者ID:CiscoDevNet,项目名称:yang-explorer,代码行数:14,代码来源:testview.py

示例12: setUp

# 需要导入模块: from django import test [as 别名]
# 或者: from django.test import Client [as 别名]
def setUp(self):
        self.client = Client()
        self.user = User.objects.create_user('testname', 'test@test.com', 'testpassword')
        self.client.login(username='testname', password='testpassword') 
开发者ID:pythonkr,项目名称:pyconkr-2015,代码行数:6,代码来源:tests.py

示例13: setUp

# 需要导入模块: from django import test [as 别名]
# 或者: from django.test import Client [as 别名]
def setUp(self):
        from core.urls import BASE

        # store the base object from the server to allow mocking and direct method access
        self.base = BASE
        self.client = Client()
        util.admin_login(self.client)

        self.base.musiq.playback.start_loop() 
开发者ID:raveberry,项目名称:raveberry,代码行数:11,代码来源:raveberry_test.py

示例14: setUp

# 需要导入模块: from django import test [as 别名]
# 或者: from django.test import Client [as 别名]
def setUp(self):
        self.client = Client()
        self.user = User.objects.create_user(USERNAME_PRIMARY, f'{USERNAME_PRIMARY}@thebeatles.com', PASSWORD)
        self.other = User.objects.create_user(USERNAME_OTHER, f'{USERNAME_OTHER}@thebeatles.com', PASSWORD) 
开发者ID:twschiller,项目名称:open-synthesis,代码行数:6,代码来源:common.py

示例15: setUp

# 需要导入模块: from django import test [as 别名]
# 或者: from django.test import Client [as 别名]
def setUp(self):
        super().setUp()
        self.client = Client() 
开发者ID:apragacz,项目名称:django-rest-registration,代码行数:5,代码来源:base.py


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