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)
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)
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)
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')
def export_fixture(model, filters=None): return json_dumps(_export_fixture(model, filters))