예제 #1
0
def test_schema_generation_non_strict_enums():
    schema = build_schema(NewPersonSchema(), strict_enums=False)
    assert_that(
        schema,
        is_(
            equal_to({
                "type": "object",
                "properties": {
                    "eyeColor": {
                        "type": "string",
                    },
                    "firstName": {
                        "type": "string",
                    },
                    "lastName": {
                        "type": "string",
                    },
                    "email": {
                        "format": "email",
                        "type": "string",
                    },
                },
                "required": [
                    "firstName",
                    "lastName",
                ],
            })))
예제 #2
0
def test_schema_generation():
    schema = build_schema(NewPersonSchema())
    assert_that(
        schema,
        is_(
            equal_to({
                "type": "object",
                "properties": {
                    "eyeColor": {
                        "enum": [
                            "PURPLE",
                            "TEAL",
                            "RUBY",
                        ],
                        "format": "enum",
                        "type": "string",
                    },
                    "firstName": {
                        "type": "string",
                    },
                    "lastName": {
                        "type": "string",
                    },
                    "email": {
                        "format": "email",
                        "type": "string",
                    },
                },
                "required": [
                    "firstName",
                    "lastName",
                ],
            })))
예제 #3
0
def test_schema_generation():
    schema = build_schema(NewPersonSchema())
    assert_that(schema, is_(equal_to({
        "type": "object",
        "properties": {
            "firstName": {
                "type": "string",
            },
            "lastName": {
                "type": "string",
            },
        },
        "required": [
            "firstName",
            "lastName",
        ],
    })))
예제 #4
0
    def __str__(self):
        return self.value


class SearchAddressPageSchema(OffsetLimitPageSchema):
    list_param = QueryStringList(String())
    enum_param = EnumField(TestEnum)


def add_request_id(headers, response_data):
    headers["X-Request-Id"] = "request-id"


PERSON_MAPPINGS = {
    Operation.Create:
    (person_create, NewPersonSchema(), PersonSchema(), add_request_id),
    Operation.Delete: (person_delete, ),
    Operation.DeleteBatch: (person_delete_batch, ),
    Operation.UpdateBatch:
    (person_update_batch, NewPersonBatchSchema(), PersonBatchSchema()),
    Operation.Replace: (person_replace, NewPersonSchema(), PersonSchema()),
    Operation.Retrieve:
    (person_retrieve, PersonLookupSchema(), PersonSchema()),
    Operation.Search: (person_search, OffsetLimitPageSchema(), PersonSchema()),
    Operation.Update: (person_update, UpdatePersonSchema(), PersonSchema()),
}

ADDRESS_MAPPINGS = {
    Operation.Delete: (address_delete, DeleteAddressSchema(), AddressSchema()),
    Operation.Retrieve: (address_retrieve, AddressSchema()),
    Operation.Search:
예제 #5
0
from microcosm_flask.conventions.registry import iter_endpoints
from microcosm_flask.namespaces import Namespace
from microcosm_flask.operations import Operation
from microcosm_flask.swagger.definitions import build_swagger
from microcosm_flask.tests.conventions.fixtures import (
    NewPersonSchema,
    Person,
    PersonSchema,
    UpdatePersonSchema,
    person_create,
    person_update,
)


PERSON_MAPPINGS = {
    Operation.Create: (person_create, NewPersonSchema(), PersonSchema()),
    Operation.Update: (person_update, UpdatePersonSchema(), PersonSchema()),
}


# match all (of the one) operations
def match_function(operation, obj, rule):
    return True


def test_build_swagger():
    graph = create_object_graph(name="example", testing=True)
    ns = Namespace(
        subject=Person,
        version="v1",
    )
예제 #6
0
    person_search,
    person_update,
    person_update_batch,
    Person,
    PersonBatchSchema,
    PersonLookupSchema,
    PersonSchema,
    ADDRESS_ID_1,
    PERSON_ID_1,
    PERSON_ID_2,
    PERSON_ID_3,
)


PERSON_MAPPINGS = {
    Operation.Create: (person_create, NewPersonSchema(), PersonSchema()),
    Operation.Delete: (person_delete,),
    Operation.UpdateBatch: (person_update_batch, NewPersonBatchSchema(), PersonBatchSchema()),
    Operation.Replace: (person_replace, NewPersonSchema(), PersonSchema()),
    Operation.Retrieve: (person_retrieve, PersonLookupSchema(), PersonSchema()),
    Operation.Search: (person_search, PageSchema(), PersonSchema()),
    Operation.Update: (person_update, NewPersonSchema(), PersonSchema()),
}


ADDRESS_MAPPINGS = {
    Operation.Retrieve: (address_retrieve, AddressSchema()),
    Operation.Search: (address_search, PageSchema(), AddressSchema()),
}