def test_lidt_delete_403(self):
     headers = {**self.headers, **testing.get_user_headers("aaa")}
     response = self.app.delete("/buckets/b1/collections", headers=headers, status=403)
     response = self.cast_bravado_response(response)
     op = self.resources["Collections"].delete_collections
     schema = self.spec.deref(op.op_spec["responses"]["403"])
     validate_response(schema, op, response)
 def test_get_record_200(self):
     response = self.app.get('/buckets/b1/collections/c1/records/r1',
                             headers=self.headers, status=200)
     response = self.cast_bravado_response(response)
     op = self.resources['Records'].get_record
     schema = self.spec.deref(op.op_spec['responses']['200'])
     validate_response(schema, op, response)
 def test_put_record_201(self):
     response = self.app.put_json('/buckets/b1/collections/c1/records/r2',
                                  MINIMALIST_RECORD, headers=self.headers, status=201)
     response = self.cast_bravado_response(response)
     op = self.resources['Records'].update_record
     schema = self.spec.deref(op.op_spec['responses']['201'])
     validate_response(schema, op, response)
 def test_object_get_403(self):
     headers = {**self.headers, **testing.get_user_headers("aaa")}
     response = self.app.get("/buckets/b1", headers=headers, status=403)
     response = self.cast_bravado_response(response)
     op = self.resources["Buckets"].get_bucket
     schema = self.spec.deref(op.op_spec["responses"]["403"])
     validate_response(schema, op, response)
 def test_object_get_406(self):
     headers = {**self.headers, "Accept": "text/html"}
     response = self.app.get("/buckets/b1", headers=headers, status=406)
     response = self.cast_bravado_response(response)
     op = self.resources["Buckets"].get_bucket
     schema = self.spec.deref(op.op_spec["responses"]["406"])
     validate_response(schema, op, response)
 def test_delete_collections_200(self):
     response = self.app.delete('/buckets/b1/collections',
                                headers=self.headers, status=200)
     response = self.cast_bravado_response(response)
     op = self.resources['Collections'].delete_collections
     schema = self.spec.deref(op.op_spec['responses']['200'])
     validate_response(schema, op, response)
 def test_object_get_404(self):
     response = self.app.get('/buckets/b1/collections/col',
                             headers=self.headers, status=404)
     response = self.cast_bravado_response(response)
     op = self.resources['Collections'].get_collection
     schema = self.spec.deref(op.op_spec['responses']['404'])
     validate_response(schema, op, response)
 def test_list_get_400(self):
     response = self.app.get('/buckets?_since=aaa',
                             headers=self.headers, status=400)
     response = self.cast_bravado_response(response)
     op = self.resources['Buckets'].get_buckets
     schema = self.spec.deref(op.op_spec['responses']['400'])
     validate_response(schema, op, response)
 def test_object_put_415(self):
     headers = {**self.headers, "Content-Type": "text/html"}
     response = self.app.put_json("/buckets/b1", MINIMALIST_BUCKET, headers=headers, status=415)
     response = self.cast_bravado_response(response)
     op = self.resources["Buckets"].update_bucket
     schema = self.spec.deref(op.op_spec["responses"]["415"])
     validate_response(schema, op, response)
Beispiel #10
0
 def test_object_put_400(self):
     response = self.app.put_json('/buckets/b1', [],
                                  headers=self.headers, status=400)
     response = self.cast_bravado_response(response)
     op = self.resources['Buckets'].update_bucket
     schema = self.spec.deref(op.op_spec['responses']['400'])
     validate_response(schema, op, response)
 def test_object_get_400(self):
     headers = {**self.headers, "If-None-Match": "aaa"}
     response = self.app.get("/buckets/b1", headers=headers, status=400)
     response = self.cast_bravado_response(response)
     op = self.resources["Buckets"].get_bucket
     schema = self.spec.deref(op.op_spec["responses"]["400"])
     validate_response(schema, op, response)
 def test_put_collection_201(self):
     response = self.app.put_json('/buckets/b1/collections/c2', MINIMALIST_COLLECTION,
                                  headers=self.headers, status=201)
     response = self.cast_bravado_response(response)
     op = self.resources['Collections'].update_collection
     schema = self.spec.deref(op.op_spec['responses']['201'])
     validate_response(schema, op, response)
def test_validate_when_configured_validate(
        mock_validate_response_body, mock_validate_response_headers):
    swagger_spec = Mock(spec=Spec, config={'validate_responses': True})
    op = Mock(spec=Operation, swagger_spec=swagger_spec)
    response = Mock(spec=OutgoingResponse)
    validate_response({'description': 'blah'}, op, response)
    assert mock_validate_response_body.call_count == 1
    assert mock_validate_response_headers.call_count == 1
def test_validate_when_configured_validate(
        mock_validate_response_body, mock_validate_response_headers):
    swagger_spec = Mock(spec=Spec, config={'validate_responses': True})
    op = Mock(spec=Operation, swagger_spec=swagger_spec)
    response = Mock(spec=OutgoingResponse)
    validate_response({'description': 'blah'}, op, response)
    assert mock_validate_response_body.call_count == 1
    assert mock_validate_response_headers.call_count == 1
Beispiel #15
0
 def test_delete_records_200(self):
     response = self.app.delete("/buckets/b1/collections/c1/records",
                                headers=self.headers,
                                status=200)
     response = self.cast_bravado_response(response)
     op = self.resources["Records"].delete_records
     schema = self.spec.deref(op.op_spec["responses"]["200"])
     validate_response(schema, op, response)
 def test_put_collection_200(self):
     response = self.app.put_json(
         "/buckets/b1/collections/c1", MINIMALIST_COLLECTION, headers=self.headers, status=200
     )
     response = self.cast_bravado_response(response)
     op = self.resources["Collections"].update_collection
     schema = self.spec.deref(op.op_spec["responses"]["200"])
     validate_response(schema, op, response)
Beispiel #17
0
 def test_get_groups_200(self):
     response = self.app.get("/buckets/b1/groups",
                             headers=self.headers,
                             status=200)
     response = self.cast_bravado_response(response)
     op = self.resources["Groups"].get_groups
     schema = self.spec.deref(op.op_spec["responses"]["200"])
     validate_response(schema, op, response)
 def test_put_bucket_201(self):
     response = self.app.put("/buckets/b2",
                             headers=self.headers,
                             status=201)
     response = self.cast_bravado_response(response)
     op = self.resources["Buckets"].update_bucket
     schema = self.spec.deref(op.op_spec["responses"]["201"])
     validate_response(schema, op, response)
 def test_put_group_201(self):
     response = self.app.put_json(
         "/buckets/b1/groups/g2", MINIMALIST_GROUP, headers=self.headers, status=201
     )
     response = self.cast_bravado_response(response)
     op = self.resources["Groups"].update_group
     schema = self.spec.deref(op.op_spec["responses"]["201"])
     validate_response(schema, op, response)
Beispiel #20
0
 def test_object_patch_415(self):
     headers = {**self.headers, 'Content-Type': 'text/html'}
     response = self.app.patch_json('/buckets/b1', MINIMALIST_BUCKET,
                                    headers=headers, status=415)
     response = self.cast_bravado_response(response)
     op = self.resources['Buckets'].patch_bucket
     schema = self.spec.deref(op.op_spec['responses']['415'])
     validate_response(schema, op, response)
Beispiel #21
0
 def test_object_get_400(self):
     headers = {**self.headers, 'If-None-Match': 'aaa'}
     response = self.app.get('/buckets/b1',
                             headers=headers, status=400)
     response = self.cast_bravado_response(response)
     op = self.resources['Buckets'].get_bucket
     schema = self.spec.deref(op.op_spec['responses']['400'])
     validate_response(schema, op, response)
 def test_delete_records_200(self):
     response = self.app.delete(
         "/buckets/b1/collections/c1/records", headers=self.headers, status=200
     )
     response = self.cast_bravado_response(response)
     op = self.resources["Records"].delete_records
     schema = self.spec.deref(op.op_spec["responses"]["200"])
     validate_response(schema, op, response)
Beispiel #23
0
 def test_object_get_403(self):
     headers = {**self.headers, **testing.get_user_headers('aaa')}
     response = self.app.get('/buckets/b1',
                             headers=headers, status=403)
     response = self.cast_bravado_response(response)
     op = self.resources['Buckets'].get_bucket
     schema = self.spec.deref(op.op_spec['responses']['403'])
     validate_response(schema, op, response)
 def test_post_bucket_201(self):
     response = self.app.post_json(
         "/buckets", MINIMALIST_BUCKET, headers=self.headers, status=201
     )
     response = self.cast_bravado_response(response)
     op = self.resources["Buckets"].create_bucket
     schema = self.spec.deref(op.op_spec["responses"]["201"])
     validate_response(schema, op, response)
 def test_delete_bucket_200(self):
     response = self.app.delete("/buckets/b1",
                                headers=self.headers,
                                status=200)
     response = self.cast_bravado_response(response)
     op = self.resources["Buckets"].delete_bucket
     schema = self.spec.deref(op.op_spec["responses"]["200"])
     validate_response(schema, op, response)
 def test_object_patch_404(self):
     response = self.app.patch_json(
         "/buckets/b1/collections/col", MINIMALIST_COLLECTION, headers=self.headers, status=404
     )
     response = self.cast_bravado_response(response)
     op = self.resources["Collections"].patch_collection
     schema = self.spec.deref(op.op_spec["responses"]["404"])
     validate_response(schema, op, response)
 def test_post_group_200(self):
     response = self.app.post_json(
         "/buckets/b1/groups", self.group, headers=self.headers, status=200
     )
     response = self.cast_bravado_response(response)
     op = self.resources["Groups"].create_group
     schema = self.spec.deref(op.op_spec["responses"]["200"])
     validate_response(schema, op, response)
Beispiel #28
0
 def test_object_get_406(self):
     headers = {**self.headers, 'Accept': 'text/html'}
     response = self.app.get('/buckets/b1',
                             headers=headers, status=406)
     response = self.cast_bravado_response(response)
     op = self.resources['Buckets'].get_bucket
     schema = self.spec.deref(op.op_spec['responses']['406'])
     validate_response(schema, op, response)
Beispiel #29
0
 def test_lidt_delete_403(self):
     headers = {**self.headers, **testing.get_user_headers('aaa')}
     response = self.app.delete('/buckets/b1/collections',
                                headers=headers, status=403)
     response = self.cast_bravado_response(response)
     op = self.resources['Collections'].delete_collections
     schema = self.spec.deref(op.op_spec['responses']['403'])
     validate_response(schema, op, response)
Beispiel #30
0
 def test_object_patch_404(self):
     response = self.app.patch_json("/buckets/b1/collections/col",
                                    MINIMALIST_COLLECTION,
                                    headers=self.headers,
                                    status=404)
     response = self.cast_bravado_response(response)
     op = self.resources["Collections"].patch_collection
     schema = self.spec.deref(op.op_spec["responses"]["404"])
     validate_response(schema, op, response)
 def test_put_group_201(self):
     response = self.app.put_json("/buckets/b1/groups/g2",
                                  MINIMALIST_GROUP,
                                  headers=self.headers,
                                  status=201)
     response = self.cast_bravado_response(response)
     op = self.resources["Groups"].update_group
     schema = self.spec.deref(op.op_spec["responses"]["201"])
     validate_response(schema, op, response)
 def test_post_group_200(self):
     response = self.app.post_json('/buckets/b1/groups',
                                   self.group,
                                   headers=self.headers,
                                   status=200)
     response = self.cast_bravado_response(response)
     op = self.resources['Groups'].create_group
     schema = self.spec.deref(op.op_spec['responses']['200'])
     validate_response(schema, op, response)
 def test_put_collection_200(self):
     response = self.app.put_json('/buckets/b1/collections/c1',
                                  MINIMALIST_COLLECTION,
                                  headers=self.headers,
                                  status=200)
     response = self.cast_bravado_response(response)
     op = self.resources['Collections'].update_collection
     schema = self.spec.deref(op.op_spec['responses']['200'])
     validate_response(schema, op, response)
Beispiel #34
0
 def test_object_get_412(self):
     headers = self.headers.copy()
     headers['If-Match'] = '"%d"' % (self.bucket['data']['last_modified']-1)
     response = self.app.get('/buckets/b1',
                             headers=headers, status=412)
     response = self.cast_bravado_response(response)
     op = self.resources['Buckets'].get_bucket
     schema = self.spec.deref(op.op_spec['responses']['412'])
     validate_response(schema, op, response)
Beispiel #35
0
 def test_post_collection_200(self):
     response = self.app.post_json("/buckets/b1/collections",
                                   self.collection,
                                   headers=self.headers,
                                   status=200)
     response = self.cast_bravado_response(response)
     op = self.resources["Collections"].create_collection
     schema = self.spec.deref(op.op_spec["responses"]["200"])
     validate_response(schema, op, response)
Beispiel #36
0
 def test_list_delete_403(self):
     headers = {**self.headers, **testing.get_user_headers("aaa")}
     response = self.app.delete("/buckets/b1/collections",
                                headers=headers,
                                status=403)
     response = self.cast_bravado_response(response)
     op = self.resources["Collections"].delete_collections
     schema = self.spec.deref(op.op_spec["responses"]["403"])
     validate_response(schema, op, response)
 def test_lidt_delete_403(self):
     headers = {**self.headers, **testing.get_user_headers('aaa')}
     response = self.app.delete('/buckets/b1/collections',
                                headers=headers,
                                status=403)
     response = self.cast_bravado_response(response)
     op = self.resources['Collections'].delete_collections
     schema = self.spec.deref(op.op_spec['responses']['403'])
     validate_response(schema, op, response)
 def test_post_record_200(self):
     response = self.app.post_json('/buckets/b1/collections/c1/records',
                                   self.record,
                                   headers=self.headers,
                                   status=200)
     response = self.cast_bravado_response(response)
     op = self.resources['Records'].create_record
     schema = self.spec.deref(op.op_spec['responses']['200'])
     validate_response(schema, op, response)
Beispiel #39
0
 def test_object_get_406(self):
     headers = self.headers.copy()
     headers['Accept'] = 'text/html'
     response = self.app.get('/buckets/b1',
                             headers=headers, status=406)
     response = self.cast_bravado_response(response)
     op = self.resources['Buckets'].get_bucket
     schema = self.spec.deref(op.op_spec['responses']['406'])
     validate_response(schema, op, response)
Beispiel #40
0
 def test_put_collection_201(self):
     response = self.app.put_json("/buckets/b1/collections/c2",
                                  MINIMALIST_COLLECTION,
                                  headers=self.headers,
                                  status=201)
     response = self.cast_bravado_response(response)
     op = self.resources["Collections"].update_collection
     schema = self.spec.deref(op.op_spec["responses"]["201"])
     validate_response(schema, op, response)
 def test_put_group_200(self):
     response = self.app.put_json('/buckets/b1/groups/g1',
                                  MINIMALIST_GROUP,
                                  headers=self.headers,
                                  status=200)
     response = self.cast_bravado_response(response)
     op = self.resources['Groups'].update_group
     schema = self.spec.deref(op.op_spec['responses']['200'])
     validate_response(schema, op, response)
 def test_put_record_201(self):
     response = self.app.put_json('/buckets/b1/collections/c1/records/r2',
                                  MINIMALIST_RECORD,
                                  headers=self.headers,
                                  status=201)
     response = self.cast_bravado_response(response)
     op = self.resources['Records'].update_record
     schema = self.spec.deref(op.op_spec['responses']['201'])
     validate_response(schema, op, response)
 def test_post_bucket_201(self):
     response = self.app.post_json("/buckets",
                                   MINIMALIST_BUCKET,
                                   headers=self.headers,
                                   status=201)
     response = self.cast_bravado_response(response)
     op = self.resources["Buckets"].create_bucket
     schema = self.spec.deref(op.op_spec["responses"]["201"])
     validate_response(schema, op, response)
Beispiel #44
0
 def test_list_get_304(self):
     headers = self.headers.copy()
     headers['If-None-Match'] = '"%d"' % self.bucket['data']['last_modified']
     response = self.app.get('/buckets',
                             headers=headers, status=304)
     response = self.cast_bravado_response(response)
     op = self.resources['Buckets'].get_buckets
     schema = self.spec.deref(op.op_spec['responses']['304'])
     validate_response(schema, op, response)
Beispiel #45
0
 def test_object_patch_415(self):
     headers = self.headers.copy()
     headers['Content-Type'] = 'text/html'
     response = self.app.patch_json('/buckets/b1', MINIMALIST_BUCKET,
                                    headers=headers, status=415)
     response = self.cast_bravado_response(response)
     op = self.resources['Buckets'].patch_bucket
     schema = self.spec.deref(op.op_spec['responses']['415'])
     validate_response(schema, op, response)
Beispiel #46
0
 def test_object_get_403(self):
     headers = self.headers.copy()
     headers.update(testing.get_user_headers('aaa'))
     response = self.app.get('/buckets/b1',
                             headers=headers, status=403)
     response = self.cast_bravado_response(response)
     op = self.resources['Buckets'].get_bucket
     schema = self.spec.deref(op.op_spec['responses']['403'])
     validate_response(schema, op, response)
Beispiel #47
0
 def test_object_get_412(self):
     headers = {**self.headers,
                'If-Match': '"{}"'.format(self.bucket['data']['last_modified']-1)}
     response = self.app.get('/buckets/b1',
                             headers=headers, status=412)
     response = self.cast_bravado_response(response)
     op = self.resources['Buckets'].get_bucket
     schema = self.spec.deref(op.op_spec['responses']['412'])
     validate_response(schema, op, response)
Beispiel #48
0
 def test_object_get_400(self):
     headers = self.headers.copy()
     headers['If-None-Match'] = 'aaa'
     response = self.app.get('/buckets/b1',
                             headers=headers, status=400)
     response = self.cast_bravado_response(response)
     op = self.resources['Buckets'].get_bucket
     schema = self.spec.deref(op.op_spec['responses']['400'])
     validate_response(schema, op, response)
Beispiel #49
0
 def test_list_get_304(self):
     headers = {**self.headers,
                'If-None-Match': '"{}"'.format(self.bucket['data']['last_modified'])}
     response = self.app.get('/buckets',
                             headers=headers, status=304)
     response = self.cast_bravado_response(response)
     op = self.resources['Buckets'].get_buckets
     schema = self.spec.deref(op.op_spec['responses']['304'])
     validate_response(schema, op, response)
 def test_object_patch_406(self):
     headers = {**self.headers, 'Accept': 'text/html'}
     response = self.app.patch_json('/buckets/b1',
                                    MINIMALIST_BUCKET,
                                    headers=headers,
                                    status=406)
     response = self.cast_bravado_response(response)
     op = self.resources['Buckets'].patch_bucket
     schema = self.spec.deref(op.op_spec['responses']['406'])
     validate_response(schema, op, response)
Beispiel #51
0
 def validate_request_call(self, op, **kargs):
     params = unmarshal_request(self.request, op)
     response = self.app.request(op.path_name.format_map(params),
                                 body=json.dumps(self.request.json()).encode(),
                                 method=op.http_method.upper(),
                                 headers=self.headers, **kargs)
     schema = self.spec.deref(op.op_spec['responses'][str(response.status_code)])
     casted_resp = self.cast_bravado_response(response)
     validate_response(schema, op, casted_resp)
     return response
 def test_list_get_304(self):
     headers = {
         **self.headers,
         "If-None-Match": '"{}"'.format(self.bucket["data"]["last_modified"]),
     }
     response = self.app.get("/buckets", headers=headers, status=304)
     response = self.cast_bravado_response(response)
     op = self.resources["Buckets"].get_buckets
     schema = self.spec.deref(op.op_spec["responses"]["304"])
     validate_response(schema, op, response)
 def test_list_delete_412(self):
     headers = {
         **self.headers, 'If-Match':
         '"{}"'.format(self.bucket['data']['last_modified'] - 1)
     }
     response = self.app.delete('/buckets', headers=headers, status=412)
     response = self.cast_bravado_response(response)
     op = self.resources['Buckets'].delete_buckets
     schema = self.spec.deref(op.op_spec['responses']['412'])
     validate_response(schema, op, response)
 def test_object_patch_403(self):
     headers = {**self.headers, **testing.get_user_headers('aaa')}
     response = self.app.patch_json('/buckets/b1',
                                    MINIMALIST_BUCKET,
                                    headers=headers,
                                    status=403)
     response = self.cast_bravado_response(response)
     op = self.resources['Buckets'].patch_bucket
     schema = self.spec.deref(op.op_spec['responses']['403'])
     validate_response(schema, op, response)
Beispiel #55
0
 def test_object_put_406(self):
     headers = {**self.headers, "Accept": "text/html"}
     response = self.app.put_json("/buckets/b1",
                                  MINIMALIST_BUCKET,
                                  headers=headers,
                                  status=406)
     response = self.cast_bravado_response(response)
     op = self.resources["Buckets"].update_bucket
     schema = self.spec.deref(op.op_spec["responses"]["406"])
     validate_response(schema, op, response)
Beispiel #56
0
 def test_object_patch_403(self):
     headers = {**self.headers, **testing.get_user_headers("aaa")}
     response = self.app.patch_json("/buckets/b1",
                                    MINIMALIST_BUCKET,
                                    headers=headers,
                                    status=403)
     response = self.cast_bravado_response(response)
     op = self.resources["Buckets"].patch_bucket
     schema = self.spec.deref(op.op_spec["responses"]["403"])
     validate_response(schema, op, response)
Beispiel #57
0
 def test_object_patch_415(self):
     headers = {**self.headers, "Content-Type": "text/html"}
     response = self.app.patch_json("/buckets/b1",
                                    MINIMALIST_BUCKET,
                                    headers=headers,
                                    status=415)
     response = self.cast_bravado_response(response)
     op = self.resources["Buckets"].patch_bucket
     schema = self.spec.deref(op.op_spec["responses"]["415"])
     validate_response(schema, op, response)
 def test_object_get_304(self):
     headers = {
         **self.headers, 'If-None-Match':
         '"{}"'.format(self.bucket['data']['last_modified'])
     }
     response = self.app.get('/buckets/b1', headers=headers, status=304)
     response = self.cast_bravado_response(response)
     op = self.resources['Buckets'].get_bucket
     schema = self.spec.deref(op.op_spec['responses']['304'])
     validate_response(schema, op, response)
 def test_object_get_412(self):
     headers = {
         **self.headers,
         "If-Match": '"{}"'.format(self.bucket["data"]["last_modified"] - 1),
     }
     response = self.app.get("/buckets/b1", headers=headers, status=412)
     response = self.cast_bravado_response(response)
     op = self.resources["Buckets"].get_bucket
     schema = self.spec.deref(op.op_spec["responses"]["412"])
     validate_response(schema, op, response)
 def test_put_record_201(self):
     response = self.app.put_json(
         "/buckets/b1/collections/c1/records/r2",
         MINIMALIST_RECORD,
         headers=self.headers,
         status=201,
     )
     response = self.cast_bravado_response(response)
     op = self.resources["Records"].update_record
     schema = self.spec.deref(op.op_spec["responses"]["201"])
     validate_response(schema, op, response)