Skip to content

Commit

Permalink
Add test for full processing pipeline.
Browse files Browse the repository at this point in the history
  • Loading branch information
amcgregor committed Apr 19, 2016
1 parent 4e4066a commit 35a5e87
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/test_extensions/test_analytics.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
# encoding: utf-8

import time
import pytest

from webob import Request
from web.core import Application
from web.core.context import Context
from web.ext.analytics import AnalyticsExtension


def endpoint(context):
time.sleep(0.1)
return "Hi."


sample = Application(endpoint, extensions=[AnalyticsExtension()])


def test_analytics_extension():
ctx = Context(response=Context(headers=dict()))
ext = AnalyticsExtension()
Expand All @@ -20,3 +31,13 @@ def test_analytics_extension():
ext.after(ctx)
assert 0.1 <= float(ctx.response.headers['X-Generation-Time']) <= 0.2


def test_analytics_extension_in_context():
try:
__import__('web.dispatch.object')
except ImportError:
pytest.skip("web.dispatch.object not installed")

resp = Request.blank('/').get_response(sample)
assert 0.1 <= float(resp.headers['X-Generation-Time']) <= 0.2

0 comments on commit 35a5e87

Please sign in to comment.