當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。