<s> import unittest <EOL> from . basetest import BasetTest , measure , flask_profiler , CONF <EOL> import time <EOL> from pprint import pprint as pp <EOL> from flask import Flask <EOL> from flask . ext . testing import TestCase as FlaskTestCase <EOL> class EndpointMeasurementTest ( BasetTest , FlaskTestCase ) : <EOL> def create_app ( self ) : <EOL> app = Flask ( __name__ ) <EOL> app . config [ "<STR_LIT>" ] = CONF <EOL> app . config [ '<STR_LIT>' ] = True <EOL> @ app . route ( "<STR_LIT>" ) <EOL> def sayHello ( firstname ) : <EOL> return firstname <EOL> flask_profiler . init_app ( app ) <EOL> @ app . route ( "<STR_LIT>" ) <EOL> def withoutProfiler ( ) : <EOL> return "<STR_LIT>" <EOL> @ app . route ( "<STR_LIT>" ) <EOL> @ flask_profiler . profile ( ) <EOL> def customProfilerEP ( message ) : <EOL> return "<STR_LIT>" <EOL> return app <EOL> def tearDown ( self ) : <EOL> pass <EOL> def test_01_return_value ( self ) : <EOL> name = "<STR_LIT>" <EOL> response = self . client . get ( "<STR_LIT>" . format ( name ) ) <EOL> r = response . data . decode ( "<STR_LIT:utf-8>" , "<STR_LIT:strict>" ) <EOL> self . assertEquals ( r , name ) <EOL> def test_02_without_profiler ( self ) : <EOL> response = self . client . get ( "<STR_LIT>" ) <EOL> r = response . data . decode ( "<STR_LIT:utf-8>" , "<STR_LIT:strict>" ) <EOL> self . assertEquals ( r , "<STR_LIT>" ) <EOL> measurements = list ( flask_profiler . collection . filter ( ) ) <EOL> self . assertEquals ( len ( measurements ) , <NUM_LIT:0> ) <EOL> def test_02_with_profiler ( self ) : <EOL> response = self . client . get ( "<STR_LIT>" ) <EOL> r = response . data . decode ( "<STR_LIT:utf-8>" , "<STR_LIT:strict>" ) <EOL> self . assertEquals ( r , "<STR_LIT>" ) <EOL> measurements = list ( flask_profiler . collection . filter ( ) ) <EOL> self . assertEquals ( len ( measurements ) , <NUM_LIT:1> ) <EOL> m = measurements [ <NUM_LIT:0> ] <EOL> self . assertEqual ( m [ "<STR_LIT:name>" ] , "<STR_LIT>" ) <EOL> self . assertEqual ( m [ "<STR_LIT>" ] , "<STR_LIT:GET>" ) <EOL> self . assertEqual ( m [ "<STR_LIT>" ] , { "<STR_LIT:message>" : "<STR_LIT:hello>" } ) <EOL> self . assertEqual ( m [ "<STR_LIT>" ] [ "<STR_LIT:args>" ] , { "<STR_LIT:q>" : "<STR_LIT:1>" } ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
