Skip to content

Instantly share code, notes, and snippets.

@mcreenan
Created February 27, 2015 15:16

Revisions

  1. mcreenan created this gist Feb 27, 2015.
    4 changes: 4 additions & 0 deletions app.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    from eve import Eve

    app = Eve()
    app.run()
    59 changes: 59 additions & 0 deletions settings.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,59 @@
    DATE_FORMAT = '%Y-%m-%dT%H:%M:%SZ'
    RESOURCE_METHODS = ['GET', 'POST', 'DELETE']
    ITEM_METHODS = ['GET', 'PATCH', 'DELETE']

    # Failure #1:
    # With the following payload:
    # {"location": {
    # "_id": "test" },
    # "extract_time": "2015-02-28T00:00:00Z",
    # "date": "2015-02-28T00:00:00Z",
    # "total": "r123" }
    # The follow response is received
    # {"_status": "ERR",
    # "_issues": { "total": "must be of integer type",
    # "extract_time": "must be of datetime type" },
    # "_error": { "message": "Insertion failure: 1 document(s) contain(s) error(s)",
    # "code": 422 } }
    # The "total" error is expected, the "extract_time" one is not
    # If "total" is changed to 123, then the document is created successfully,
    # despite there being no change to extract_time

    # Failure #2:
    # With the following payload:
    # {"location": {
    # "_id": "test" },
    # "extract_time": "2015-02-28T00:00:00Z",
    # "date": "2015-02-28T00:00:00Z",
    # "total": "123" }
    # A 200 OK is received, which is not expected
    # The "total" field is actually a string, when an integer is expected

    DOMAIN = {
    'attendance': {
    'schema': {
    'extract_time': {
    'required': True,
    'type': 'datetime'
    },
    'location': {
    'required': True,
    'type': 'dict',
    'schema': {
    '_id': {
    'required': True,
    'type': 'string',
    },
    }
    },
    'date': {
    'required': True,
    'type': 'datetime',
    },
    'total': {
    'required': True,
    'type': 'integer',
    },
    },
    },
    }