Exemplo n.º 1
0
    def test_two_simple(self):
        today = Date.today()

        result = replace_vars('"{{today|week}}" "{{today}}d"')
        expect = '"' + unicode(today.floor(WEEK).unix) + '" "' + unicode(
            today.unix) + 'd"'
        self.assertEqual(result, expect)
Exemplo n.º 2
0
    def test_overload(self):
        today = Date.today()

        result = replace_vars('"{{today|week}}" "{{var}}"', {
            "today": 1000,
            "var": 20
        })
        expect = '"' + unicode(today.floor(WEEK).unix) + '" "20"'
        self.assertEqual(result, expect)
Exemplo n.º 3
0
    def get(*args, **kwargs):
        body = kwargs.get("data")

        if not body:
            return wrap({"status_code": 400})

        text = convert.utf82unicode(body)
        text = replace_vars(text)
        data = convert.json2value(text)
        result = jx.run(data)
        output_bytes = convert.unicode2utf8(convert.value2json(result))
        return wrap({
            "status_code": 200,
            "all_content": output_bytes,
            "content": output_bytes
        })