##// END OF EJS Templates
testing: cleanup request/config stubs...
marcink -
r2311:321e8b97 default
parent child Browse files
Show More
@@ -593,8 +593,13 b' def add_events_routes(config):'
593 outside of pyramid context, we need to bootstrap request with some
593 outside of pyramid context, we need to bootstrap request with some
594 routing registered
594 routing registered
595 """
595 """
596
597 from rhodecode.apps._base import ADMIN_PREFIX
598
596 config.add_route(name='home', pattern='/')
599 config.add_route(name='home', pattern='/')
597
600
601 config.add_route(name='login', pattern=ADMIN_PREFIX + '/login')
602 config.add_route(name='logout', pattern=ADMIN_PREFIX + '/logout')
598 config.add_route(name='repo_summary', pattern='/{repo_name}')
603 config.add_route(name='repo_summary', pattern='/{repo_name}')
599 config.add_route(name='repo_summary_explicit', pattern='/{repo_name}/summary')
604 config.add_route(name='repo_summary_explicit', pattern='/{repo_name}/summary')
600 config.add_route(name='repo_group_home', pattern='/{repo_group_name}')
605 config.add_route(name='repo_group_home', pattern='/{repo_group_name}')
@@ -603,13 +608,25 b' def add_events_routes(config):'
603 pattern='/{repo_name}/pull-request/{pull_request_id}')
608 pattern='/{repo_name}/pull-request/{pull_request_id}')
604 config.add_route(name='pull_requests_global',
609 config.add_route(name='pull_requests_global',
605 pattern='/pull-request/{pull_request_id}')
610 pattern='/pull-request/{pull_request_id}')
606
607 config.add_route(name='repo_commit',
611 config.add_route(name='repo_commit',
608 pattern='/{repo_name}/changeset/{commit_id}')
612 pattern='/{repo_name}/changeset/{commit_id}')
613
609 config.add_route(name='repo_files',
614 config.add_route(name='repo_files',
610 pattern='/{repo_name}/files/{commit_id}/{f_path}')
615 pattern='/{repo_name}/files/{commit_id}/{f_path}')
611
616
612
617
618 def bootstrap_config(request):
619 import pyramid.testing
620 registry = pyramid.testing.Registry('RcTestRegistry')
621 config = pyramid.testing.setUp(registry=registry, request=request)
622
623 # allow pyramid lookup in testing
624 config.include('pyramid_mako')
625
626 add_events_routes(config)
627 return config
628
629
613 def bootstrap_request(**kwargs):
630 def bootstrap_request(**kwargs):
614 import pyramid.testing
631 import pyramid.testing
615
632
@@ -628,7 +645,5 b' def bootstrap_request(**kwargs):'
628 request = TestRequest(**kwargs)
645 request = TestRequest(**kwargs)
629 request.session = TestDummySession()
646 request.session = TestDummySession()
630
647
631 config = pyramid.testing.setUp(request=request)
632 add_events_routes(config)
633 return request
648 return request
634
649
@@ -62,7 +62,7 b' from rhodecode.tests import ('
62 login_user_session, get_new_dir, utils, TESTS_TMP_PATH,
62 login_user_session, get_new_dir, utils, TESTS_TMP_PATH,
63 TEST_USER_ADMIN_LOGIN, TEST_USER_REGULAR_LOGIN, TEST_USER_REGULAR2_LOGIN,
63 TEST_USER_ADMIN_LOGIN, TEST_USER_REGULAR_LOGIN, TEST_USER_REGULAR2_LOGIN,
64 TEST_USER_REGULAR_PASS)
64 TEST_USER_REGULAR_PASS)
65 from rhodecode.tests.utils import CustomTestApp, set_anonymous_access, add_test_routes
65 from rhodecode.tests.utils import CustomTestApp, set_anonymous_access
66 from rhodecode.tests.fixture import Fixture
66 from rhodecode.tests.fixture import Fixture
67
67
68
68
@@ -1665,6 +1665,15 b' def rhodecode_fixtures():'
1665
1665
1666
1666
1667 @pytest.fixture
1667 @pytest.fixture
1668 def context_stub():
1669 """
1670 Stub context object.
1671 """
1672 context = pyramid.testing.DummyResource()
1673 return context
1674
1675
1676 @pytest.fixture
1668 def request_stub():
1677 def request_stub():
1669 """
1678 """
1670 Stub request object.
1679 Stub request object.
@@ -1675,21 +1684,12 b' def request_stub():'
1675
1684
1676
1685
1677 @pytest.fixture
1686 @pytest.fixture
1678 def context_stub():
1679 """
1680 Stub context object.
1681 """
1682 context = pyramid.testing.DummyResource()
1683 return context
1684
1685
1686 @pytest.fixture
1687 def config_stub(request, request_stub):
1687 def config_stub(request, request_stub):
1688 """
1688 """
1689 Set up pyramid.testing and return the Configurator.
1689 Set up pyramid.testing and return the Configurator.
1690 """
1690 """
1691 config = pyramid.testing.setUp(request=request_stub)
1691 from rhodecode.lib.base import bootstrap_config
1692 add_test_routes(config)
1692 config = bootstrap_config(request=request_stub)
1693
1693
1694 @request.addfinalizer
1694 @request.addfinalizer
1695 def cleanup():
1695 def cleanup():
@@ -404,28 +404,3 b' def commit_change('
404 f_path=filename
404 f_path=filename
405 )
405 )
406 return commit
406 return commit
407
408
409 def add_test_routes(config):
410 """
411 Adds test routing that can be used in different functional tests
412 """
413 from rhodecode.apps._base import ADMIN_PREFIX
414
415 config.add_route(name='home', pattern='/')
416
417 config.add_route(name='login', pattern=ADMIN_PREFIX + '/login')
418 config.add_route(name='logout', pattern=ADMIN_PREFIX + '/logout')
419 config.add_route(name='repo_summary', pattern='/{repo_name}')
420 config.add_route(name='repo_summary_explicit', pattern='/{repo_name}/summary')
421 config.add_route(name='repo_group_home', pattern='/{repo_group_name}')
422
423 config.add_route(name='pullrequest_show',
424 pattern='/{repo_name}/pull-request/{pull_request_id}')
425 config.add_route(name='pull_requests_global',
426 pattern='/pull-request/{pull_request_id}')
427 config.add_route(name='repo_commit',
428 pattern='/{repo_name}/changeset/{commit_id}')
429
430 config.add_route(name='repo_files',
431 pattern='/{repo_name}/files/{commit_id}/{f_path}')
General Comments 0
You need to be logged in to leave comments. Login now