예제 #1
0
def export_all_fixtures():
    model_list = [o for o in models.__dict__.itervalues()
                  if isinstance(o, type) and issubclass(o, Base)]
    resp = []
    for model in model_list:
        resp += _export_fixture(model)
    return json_dumps(resp)
예제 #2
0
def send_call(app, method, url, params=None, token=None):
    kwargs = {
        'content_type': 'application/json',
        'headers': {'Authorization': (
            'MYC apikey="whatever"%s' % (
                ', token="%s"' % token if token else ''))},
    }
    if params:
        kwargs['data'] = (params if isinstance(params, basestring)
                          else json_dumps(params))
    return getattr(app, method)(url, **kwargs)
예제 #3
0
 def test_this(self):
     data = {
         'decimal': Decimal('1.41199860'),
         'string': 'Hobro',
         'integer': 1,
         'date': date(2012, 11, 11),
         'time': time(15, 30),
         'datetime': datetime(2012, 12, 10, 16, 43),
     }
     base_one = json_dumps(data)
     base_two = json_loads(base_one)
     self.assertEquals(data, base_two)
예제 #4
0
def jsonify(*args, **kwargs):
    """
    Custom implementation of jsonify, to use the custom JSON dumps function.
    """
    if args:
        if len(args) == 1:
            val = args[0]
        else:
            val = args
    else:
        val = kwargs
    return app.response_class(
        json_dumps(val, indent=None if request.is_xhr else 2),
        mimetype='application/json')
예제 #5
0
def export_fixture(model, filters=None):
    return json_dumps(_export_fixture(model, filters))