def test_traverse_with_verbose(): """Ensure traverse() finds the proper routes and outputs verbose info.""" output = compat.StringIO() with redirected(stdout=output): print_routes.traverse(_api._router._roots, verbose=True) route, get_info, options_info = output.getvalue().strip().split('\n') assert '-> /test' == route # NOTE(kgriffs) We might receive these in either order, since the # method map is not ordered, so check and swap if necessary. if options_info.startswith('-->GET'): get_info, options_info = options_info, get_info assert options_info.startswith('-->OPTIONS') if cython: assert options_info.endswith('[unknown file]') else: assert 'falcon/responders.py:' in options_info assert get_info.startswith('-->GET') # NOTE(vytas): This builds upon the fact that on_get is defined on line 14 # in this file. Adjust the test if the said responder is relocated, or just # check for any number if this becomes too painful to maintain. assert get_info.endswith('tests/test_cmd_print_api.py:14')
def test_traverse_with_verbose(): """Ensure traverse() finds the proper routes and outputs verbose info.""" output = io.StringIO() with redirected(stdout=output): print_routes.traverse(_api._router._roots, verbose=True) route, get_info, options_info = output.getvalue().strip().split('\n') assert '-> /test' == route # NOTE(kgriffs) We might receive these in either order, since the # method map is not ordered, so check and swap if necessary. if options_info.startswith('-->GET'): get_info, options_info = options_info, get_info assert options_info.startswith('-->OPTIONS') if cython: assert options_info.endswith('[unknown file]') else: assert 'falcon/responders.py:' in options_info assert get_info.startswith('-->GET') # NOTE(vytas): This builds upon the fact that on_get is defined on line 14 # in this file. Adjust the test if the said responder is relocated, or just # check for any number if this becomes too painful to maintain. assert get_info.endswith('tests/test_cmd_print_api.py:15')
def test_traverse_with_verbose(app): """Ensure traverse() finds the proper routes and outputs verbose info.""" output = io.StringIO() with redirected(stdout=output): print_routes.traverse(app._router._roots, verbose=True) route, get_info, options_info = output.getvalue().strip().split('\n') assert '-> /test' == route # NOTE(kgriffs) We might receive these in either order, since the # method map is not ordered, so check and swap if necessary. if options_info.startswith('-->GET'): get_info, options_info = options_info, get_info assert options_info.startswith('-->OPTIONS') assert '{}:'.format(normpath('falcon/responders.py')) in options_info assert get_info.startswith('-->GET') # NOTE(vytas): This builds upon the fact that on_get is defined on line # 18 or 25 (in the case of DummyResourceAsync) in the present file. # Adjust the test if the said responder is relocated, or just check for # any number if this becomes too painful to maintain. path = normpath('tests/test_cmd_print_api.py') assert (get_info.endswith('{}:14'.format(path)) or get_info.endswith('{}:21'.format(path)))
def test_traverse(): """Ensure traverse() finds the proper routes.""" output = compat.StringIO() with redirected(stdout=output): print_routes.traverse(_api._router._roots, verbose=False) route = output.getvalue().strip() assert '-> /test' == route
def test_traverse_with_verbose(self): """Ensure traverse finds the proper routes and adds verbose output.""" print_routes.traverse(_api._router._roots, verbose=True) route, options = self.output.getvalue().strip().split('\n') self.assertEquals('-> /test', route) self.assertTrue('OPTIONS' in options) self.assertTrue('falcon/falcon/responders.py:' in options)
def test_traverse(): """Ensure traverse() finds the proper routes.""" output = six.moves.StringIO() with redirected(stdout=output): print_routes.traverse(_api._router._roots, verbose=False) route = output.getvalue().strip() assert '-> /test' == route
def test_traverse(self): """Ensure traverse finds the proper routes.""" print_routes.traverse( _api._router._roots, verbose=False) route = self.output.getvalue().strip() self.assertEquals('-> /test', route)
def test_traverse_with_verbose(): """Ensure traverse finds the proper routes and adds verbose output.""" output = six.moves.StringIO() with redirected(stdout=output): print_routes.traverse(_api._router._roots, verbose=True) route, options = output.getvalue().strip().split('\n') assert '-> /test' == route assert 'OPTIONS' in options assert 'falcon/responders.py:' in options
def test_traverse_with_verbose(self): """Ensure traverse finds the proper routes and adds verbose output.""" print_routes.traverse( _api._router._roots, verbose=True) route, options = self.output.getvalue().strip().split('\n') self.assertEquals('-> /test', route) self.assertTrue('OPTIONS' in options) self.assertTrue('falcon/falcon/responders.py:' in options)
def test_traverse_with_verbose(): """Ensure traverse finds the proper routes and adds verbose output for a method function as well as the OPTIONS partial.""" output = six.moves.StringIO() with redirected(stdout=output): print_routes.traverse(_api._router._roots, verbose=True) route, method, options = output.getvalue().strip().split('\n') assert '-> /test' == route # Check in both methods and options for the GET method # because method map is not ordered assert 'GET' in method + options if 'GET' in method: assert 'OPTIONS' in options assert 'falcon/responders.py:' in options else: assert 'OPTIONS' in method assert 'falcon/responders.py:' in method
def test_traverse_with_verbose(): """Ensure traverse() finds the proper routes and outputs verbose info.""" output = six.moves.StringIO() with redirected(stdout=output): print_routes.traverse(_api._router._roots, verbose=True) route, get_info, options_info = output.getvalue().strip().split('\n') assert '-> /test' == route # NOTE(kgriffs) We might receive these in either order, since the # method map is not ordered, so check and swap if necessary. if options_info.startswith('-->GET'): get_info, options_info = options_info, get_info assert options_info.startswith('-->OPTIONS') assert 'falcon/responders.py:' in options_info assert get_info.startswith('-->GET') assert 'tests/test_cmd_print_api.py:' in get_info