def test_it_can_register_cls_checkers(self):
     original = dict(FormatChecker.checkers)
     self.addCleanup(FormatChecker.checkers.pop, "boom")
     FormatChecker.cls_checks("boom")(boom)
     self.assertEqual(
         FormatChecker.checkers,
         dict(original, boom=(boom, ())),
     )
Exemplo n.º 2
0
 def test_it_can_register_cls_checkers(self):
     original = dict(FormatChecker.checkers)
     self.addCleanup(FormatChecker.checkers.pop, "boom")
     FormatChecker.cls_checks("boom")(boom)
     self.assertEqual(
         FormatChecker.checkers,
         dict(original, boom=(boom, ())),
     )
Exemplo n.º 3
0
 def test_it_can_register_cls_checkers(self):
     with mock.patch.dict(FormatChecker.checkers, clear=True):
         FormatChecker.cls_checks("new")(self.fn)
         self.assertEqual(FormatChecker.checkers, {"new": (self.fn, ())})
Exemplo n.º 4
0
 def test_it_can_register_cls_checkers(self):
     with mock.patch.dict(FormatChecker.checkers, clear=True):
         FormatChecker.cls_checks("new")(self.fn)
         self.assertEqual(FormatChecker.checkers, {"new": (self.fn, ())})
Exemplo n.º 5
0
        for trace in trace_seq:
            validate_timestamp(trace['timestamp'])
    # FIXME: Be more specific with errors.
    except Exception as e:
        print(e)
        abort(400)

    try:
        for trace in trace_seq:
            # FIXME: If not unique timestamp, it's a user error 400.
            write_trace_in_db(session_id, trace)
        # FIXME: Or 200, as the resource is not shown to user?
        return make_response(jsonify({"status": "OK"}), 201)
    except Exception as e:
        print(e)
        abort(500)



# Adds date-time checking.
# FIXME: Is this really how it's supposed to be done?
FormatChecker.cls_checks("date-time", ())(validate_rfc3339)

json_schema = open_json_schema()



if __name__ == "__main__":
    app.run()