python类POST的实例源码

test_project.py 文件源码 项目:python-matchlightsdk 作者: TerbiumLabs 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def test_project_add(connection, project_name, project_payload,
                     project_type, upload_token):
    """Verifies project creation."""
    httpretty.register_uri(
        httpretty.POST, '{}/project/add'.format(
            matchlight.MATCHLIGHT_API_URL_V2),
        body=json.dumps({'data': project_payload}),
        content_type='application/json', status=200)
    project = connection.projects.add(project_name, project_type)
    assert project.upload_token == upload_token
test_plan.py 文件源码 项目:paystack-python 作者: andela-sjames 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def test_create(self):
        """Method defined to test plan creation."""
        httpretty.register_uri(
            httpretty.POST,
            "https://api.paystack.co/plan",
            content_type='text/json',
            body='{"status": true, "contributors": true}',
            status=201,
        )

        response = Plan.create(
            name="John Doe", description="Payment plan for awesome people contributions",
            amount=50000, interval="daily", send_invoices=True, )
        self.assertTrue(response['status'])
test_base.py 文件源码 项目:paystack-python 作者: andela-sjames 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def test_post_method_called(self):

        httpretty.register_uri(
            httpretty.POST,
            "https://api.paystack.co/transaction/charge_token",
            content_type='text/json',
            body='{"status": true, "contributors": null}',
            status=302,
        )

        req = PayStackRequests()
        response = req.post('transaction/charge_token',
                            data={'track': 'requests'})
        self.assertTrue(response['status'])
test_transaction.py 文件源码 项目:paystack-python 作者: andela-sjames 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def test_charge(self):
        httpretty.register_uri(
            httpretty.POST,
            "https://api.paystack.co/transaction/charge_authorization",
            content_type='text/json',
            body='{"status": true, "contributors": true}',
            status=201,
        )

        response = Transaction.charge(
            reference='getupall', authorization_code='authorization_code',
            email='email', amount='amount')
        self.assertTrue(response['status'])
steps.py 文件源码 项目:concourse-resource-bitbucket 作者: Karunamon 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def step_impl(context):
    d = context.bad_login
    assert d['source']['username'] != 'ValidUser'
    httpretty.enable()
    httpretty.register_uri(
            httpretty.POST,
            context.good_build_url,
            body='{"errors":[{"context":null,"message":"Authentication failed. Please check your credentials and try again.","exceptionName":"com.atlassian.bitbucket.auth.IncorrectPasswordAuthenticationException"}]}',
            status=401
    )
    from scripts.bitbucket import post_result, err
    result = post_result(context.good_build_url, d['source']['username'], d['source']['password'], False, good_status_dict(), True)
    assert result.status_code == 401
    httpretty.disable()
    httpretty.reset()
steps.py 文件源码 项目:concourse-resource-bitbucket 作者: Karunamon 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def step_impl(context):
    d = context.good_login
    assert context.good_login['source']['username'] == 'ValidUser'
    httpretty.enable()
    httpretty.register_uri(
            httpretty.POST,
            context.bad_build_url,
            body='{"errors":[{"context":null,"message":"You are not permitted to access this resource","exceptionName":"com.atlassian.bitbucket.AuthorisationException"}]}',
            status=403
    )
    from scripts.bitbucket import post_result, err
    result = post_result(context.bad_build_url, d['source']['username'], d['source']['password'], False, good_status_dict(), True)
    assert result.status_code == 403
    httpretty.disable()
    httpretty.reset()
steps.py 文件源码 项目:concourse-resource-bitbucket 作者: Karunamon 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def step_impl(context):
    d = context.good_login
    assert context.good_login['source']['username'] == 'ValidUser'
    assert 'somethingicantaccess' not in context.good_build_url
    httpretty.enable()
    httpretty.register_uri(
            httpretty.POST,
            context.good_build_url,
            status=204
    )
    from scripts.bitbucket import post_result, err
    result = post_result(context.good_build_url, d['source']['username'], d['source']['password'], False, good_status_dict(), True)
    assert result.status_code == 204
    context.goodresult = result
test_default_stream_update.py 文件源码 项目:ouroboros 作者: madedotcom 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def given_that_there_is_no_default_acl(self):
        self.start_mocking_http()
        self.fake_response('/streams/$settings', status=404)
        self.expect_call('/streams/$settings', httpretty.POST)
test_default_stream_update.py 文件源码 项目:ouroboros 作者: madedotcom 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def given_that_there_is_no_default_acl(self):
        self.start_mocking_http()
        self.fake_response('/streams/$settings', status=404)
        self.expect_call('/streams/$settings', httpretty.POST)
test_default_stream_update.py 文件源码 项目:ouroboros 作者: madedotcom 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def given_a_default_acl(self):
        self.start_mocking_http()
        self.fake_response('/streams/$settings', file='settings-stream.js')
        self.fake_response('/streams/$settings/6', file='settings.json')
        self.expect_call('/streams/$settings', httpretty.POST)
test_default_stream_update.py 文件源码 项目:ouroboros 作者: madedotcom 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def given_a_default_acl(self):
        self.start_mocking_http()
        self.fake_response('/streams/$settings', file='settings-stream.js')
        self.fake_response('/streams/$settings/6', file='settings.json')
        self.expect_call('/streams/$settings', httpretty.POST)
test_default_stream_update.py 文件源码 项目:ouroboros 作者: madedotcom 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def given_a_default_acl(self):
        self.start_mocking_http()
        self.fake_response('/streams/$settings', file='settings-stream.js')
        self.fake_response('/streams/$settings/6', file='settings.json')
        self.expect_call('/streams/$settings', httpretty.POST)
test_stream_creation.py 文件源码 项目:ouroboros 作者: madedotcom 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def given_a_client(self):
        self.start_mocking_http()
        self.expect_call('/streams/my-stream/metadata', httpretty.POST)
test_stream_creation.py 文件源码 项目:ouroboros 作者: madedotcom 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def given_a_client(self):
        self.start_mocking_http()
        self.expect_call('/streams/my-stream/metadata', httpretty.POST)
test_stream_update.py 文件源码 项目:ouroboros 作者: madedotcom 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def given_an_existing_stream_with_no_metadata(self):
        self.start_mocking_http()
        self.fake_response('/streams/my-stream/metadata', status=200, body='{}')
        self.expect_call('/streams/my-stream/metadata', httpretty.POST)
test_stream_update.py 文件源码 项目:ouroboros 作者: madedotcom 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def given_a_stream_with_an_acl(self):
       self.start_mocking_http()
       self.expect_call('/streams/my-stream/metadata', httpretty.POST)
       self.fake_response('/streams/my-stream/metadata', status=200,
                          body = """
                          {
                             "$acl" : {
                                "$w"  : "greg",
                                "$r"  : ["greg", "john"],
                                "$d"  : "$admins",
                                "$mw" : "$admins",
                                "$mr" : "$admins"
                             }
                          }""")
test_stream_update.py 文件源码 项目:ouroboros 作者: madedotcom 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def given_the_absence_of_a_stream(self):
       self.start_mocking_http()
       self.expect_call('/streams/my-stream/metadata', httpretty.POST)
       self.fake_response('/streams/missing-stream/metadata', status=404)
test_stream_update.py 文件源码 项目:ouroboros 作者: madedotcom 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def given_a_stream_with_an_acl(self):
       self.start_mocking_http()
       self.expect_call('/streams/my-stream/metadata', httpretty.POST)
       self.fake_response('/streams/my-stream/metadata', status=200,
                          body = """
                          {
                             "$acl" : {
                                "$w"  : "greg",
                                "$r"  : ["greg", "john"],
                                "$d"  : "$admins",
                                "$mw" : "$admins",
                                "$mr" : "$admins"
                             }
                          }""")


问题


面经


文章

微信
公众号

扫码关注公众号