##// END OF EJS Templates
tests: fix unit tests and make limited_date validation conditional
ergo -
Show More
@@ -1498,6 +1498,7 b' class TestAPISentryView(object):'
1498 request = pyramid.threadlocal.get_current_request()
1498 request = pyramid.threadlocal.get_current_request()
1499 context = DummyContext()
1499 context = DummyContext()
1500 context.resource = ApplicationService.by_id(1)
1500 context.resource = ApplicationService.by_id(1)
1501 context.resource.allow_permanent_storage = True
1501 request.context = context
1502 request.context = context
1502 request.matched_route = route
1503 request.matched_route = route
1503 request.body = b'eJy1UmFr2zAQ/S0T+7BCLOzYThp/C6xjG6SDLd/GCBf57Ki' \
1504 request.body = b'eJy1UmFr2zAQ/S0T+7BCLOzYThp/C6xjG6SDLd/GCBf57Ki' \
@@ -1537,6 +1538,7 b' class TestAPISentryView(object):'
1537 })
1538 })
1538 context = DummyContext()
1539 context = DummyContext()
1539 context.resource = ApplicationService.by_id(1)
1540 context.resource = ApplicationService.by_id(1)
1541 context.resource.allow_permanent_storage = True
1540 request.context = context
1542 request.context = context
1541 request.matched_route = route
1543 request.matched_route = route
1542 request.body = SENTRY_RUBY_ENCODED
1544 request.body = SENTRY_RUBY_ENCODED
@@ -1556,6 +1558,7 b' class TestAPISentryView(object):'
1556 request = pyramid.threadlocal.get_current_request()
1558 request = pyramid.threadlocal.get_current_request()
1557 context = DummyContext()
1559 context = DummyContext()
1558 context.resource = ApplicationService.by_id(1)
1560 context.resource = ApplicationService.by_id(1)
1561 context.resource.allow_permanent_storage = True
1559 request.context = context
1562 request.context = context
1560 request.matched_route = route
1563 request.matched_route = route
1561 request.body = json.dumps(SENTRY_PYTHON_PAYLOAD_7).encode('utf8')
1564 request.body = json.dumps(SENTRY_PYTHON_PAYLOAD_7).encode('utf8')
@@ -1583,6 +1586,7 b' class TestAPISentryView(object):'
1583 })
1586 })
1584 context = DummyContext()
1587 context = DummyContext()
1585 context.resource = ApplicationService.by_id(1)
1588 context.resource = ApplicationService.by_id(1)
1589 context.resource.allow_permanent_storage = True
1586 request.context = context
1590 request.context = context
1587 request.matched_route = route
1591 request.matched_route = route
1588 request.body = SENTRY_PYTHON_ENCODED
1592 request.body = SENTRY_PYTHON_ENCODED
@@ -50,6 +50,12 b' def deferred_utcnow(node, kw):'
50 return kw['utcnow']
50 return kw['utcnow']
51
51
52
52
53 @colander.deferred
54 def optional_limited_date(node, kw):
55 if not kw.get('allow_permanent_storage'):
56 return limited_date
57
58
53 def lowercase_preparer(input_data):
59 def lowercase_preparer(input_data):
54 """
60 """
55 Transforms a list of string entries to lowercase
61 Transforms a list of string entries to lowercase
@@ -292,9 +298,11 b' class ReportDetailBaseSchema(colander.MappingSchema):'
292 preparer=shortener_factory(1024), missing='')
298 preparer=shortener_factory(1024), missing='')
293 ip = colander.SchemaNode(colander.String(), preparer=shortener_factory(39),
299 ip = colander.SchemaNode(colander.String(), preparer=shortener_factory(39),
294 missing=None)
300 missing=None)
295 start_time = colander.SchemaNode(NonTZDate(), validator=limited_date,
301 start_time = colander.SchemaNode(NonTZDate(),
302 validator=optional_limited_date,
296 missing=deferred_utcnow)
303 missing=deferred_utcnow)
297 end_time = colander.SchemaNode(NonTZDate(), validator=limited_date,
304 end_time = colander.SchemaNode(NonTZDate(),
305 validator=optional_limited_date,
298 missing=None)
306 missing=None)
299 user_agent = colander.SchemaNode(colander.String(),
307 user_agent = colander.SchemaNode(colander.String(),
300 preparer=[shortener_factory(512),
308 preparer=[shortener_factory(512),
@@ -428,7 +428,9 b' def sentry_compat(request):'
428 len(non_pkey_logs)))
428 len(non_pkey_logs)))
429 tasks.add_logs.delay(application.resource_id, {}, non_pkey_logs)
429 tasks.add_logs.delay(application.resource_id, {}, non_pkey_logs)
430 if event_type == ParsedSentryEventType.ERROR_REPORT:
430 if event_type == ParsedSentryEventType.ERROR_REPORT:
431 schema = ReportSchema_0_5().bind(utcnow=datetime.datetime.utcnow())
431 schema = ReportSchema_0_5().bind(
432 utcnow=datetime.datetime.utcnow(),
433 allow_permanent_storage=application.allow_permanent_storage)
432 deserialized_reports = [schema.deserialize(event)]
434 deserialized_reports = [schema.deserialize(event)]
433 rate_limiting(request, application,
435 rate_limiting(request, application,
434 'per_application_reports_rate_limit',
436 'per_application_reports_rate_limit',
General Comments 0
You need to be logged in to leave comments. Login now