priestc / giotto

Python web development simplified
BSD 2-Clause "Simplified" License
59 stars 10 forks source link

Create 'model-mock' functionality #6

Closed priestc closed 11 years ago

priestc commented 11 years ago

Add an option to running concrete controllers that bypasses the model. For example:

class Multiply(GiottoProgram):
    name = 'multiply'
    model = [multiply]
    model_mock = {'x': 4, 'y': 5, 'product': 20}
    view = [MultiplyViewer]
    controllers = ('cmd')

When running the http-dev controller, you pass in a --mock-model argument, which means all programs return the model_mock value regardless of the controller data.

$ ./giotto http-dev --model_mock
$ curl --header "Accept: application/json" "localhost:5000/multiply?x=99&y=99"
{x: 4, y: 5, product: 20}