1818
1919from testing_support .fixtures import (
2020 collector_agent_registration_fixture ,
21- collector_available_fixture ,
22- override_application_settings ,
23- override_generic_settings ,
24- override_ignore_status_codes ,
21+ collector_available_fixture , # noqa: F401 # autouse fixture, must be importable in this module
2522)
26- from testing_support .validators .validate_code_level_metrics import validate_code_level_metrics
27- from testing_support .validators .validate_transaction_errors import validate_transaction_errors
2823from testing_support .validators .validate_transaction_metrics import validate_transaction_metrics
2924
3025
3934}
4035
4136collector_agent_registration = collector_agent_registration_fixture (
42- app_name = "Python Agent Test (framework_django )" , default_settings = _default_settings , scope = "module"
37+ app_name = "Python Agent Test (framework_wagtail )" , default_settings = _default_settings , scope = "module"
4338)
4439
45- @pytest .fixture
46- def database (autouse = True ):
40+ @pytest .fixture ( autouse = True )
41+ def database ():
4742 os .environ .setdefault ("DJANGO_SETTINGS_MODULE" , "settings" )
4843 import django
4944
@@ -52,52 +47,69 @@ def database(autouse=True):
5247
5348 call_command ("migrate" , verbosity = 0 , interactive = False , run_syncdb = True )
5449
50+ # Wagtail's own migrations seed a default "Welcome" home page (a plain
51+ # ``Page``) and a default ``Site``. Replace that root with a ``HomePage``
52+ # and hang a ``RoutablePage`` beneath it so that "/" and "/routable/"
53+ # resolve to real, renderable pages served by the dummy_app page types.
54+ from wagtail .models import Page , Site
55+
56+ from dummy_app .models import HomePage , RoutablePage
57+
58+ if not HomePage .objects .exists ():
59+ site = Site .objects .get (is_default_site = True )
60+ default_home = site .root_page
61+ home = Page .objects .get (depth = 1 ).add_child (instance = HomePage (title = "Home" , slug = "home-page" ))
62+ site .root_page = home
63+ site .save ()
64+ default_home .delete ()
65+ home .add_child (instance = RoutablePage (title = "Routable" , slug = "routable" ))
66+
5567def target_application ():
5668 from _target_application import _target_application
5769
5870 return _target_application
5971
6072
6173@validate_transaction_metrics (
62- "views:index " ,
74+ "dummy_app.models:HomePage.route " ,
6375 scoped_metrics = [
6476 ("Function/django.core.handlers.wsgi:WSGIHandler.__call__" , 1 ),
6577 ("Python/WSGI/Application" , 1 ),
6678 ("Python/WSGI/Response" , 1 ),
6779 ("Python/WSGI/Finalize" , 1 ),
68- ("Function/views:index " , 1 ),
80+ ("Function/wagtail. views:serve " , 1 ),
6981 ]
7082)
7183def test_home ():
7284 test_application = target_application ()
73- response = test_application .get ("" )
85+ response = test_application .get ("/ " )
7486
7587
7688@validate_transaction_metrics (
77- "views:index " ,
89+ "dummy_app.models:RoutablePage.index_route " ,
7890 scoped_metrics = [
7991 ("Function/django.core.handlers.wsgi:WSGIHandler.__call__" , 1 ),
8092 ("Python/WSGI/Application" , 1 ),
8193 ("Python/WSGI/Response" , 1 ),
8294 ("Python/WSGI/Finalize" , 1 ),
83- ("Function/views:index " , 1 ),
95+ ("Function/wagtail. views:serve " , 1 ),
8496 ]
8597)
8698def test_routable ():
8799 test_application = target_application ()
88- response = test_application .get ("/routable" )
100+ response = test_application .get ("/routable/ " )
89101
90102
91103@validate_transaction_metrics (
92- "views: index" ,
104+ "dummy_app.models:RoutablePage. index" ,
93105 scoped_metrics = [
94106 ("Function/django.core.handlers.wsgi:WSGIHandler.__call__" , 1 ),
95107 ("Python/WSGI/Application" , 1 ),
96108 ("Python/WSGI/Response" , 1 ),
97109 ("Python/WSGI/Finalize" , 1 ),
98- ("Function/views:index " , 1 ),
110+ ("Function/wagtail. views:serve " , 1 ),
99111 ]
100112)
101113def test_routable_routable ():
102114 test_application = target_application ()
103- response = test_application .get ("/routable/routable" )
115+ response = test_application .get ("/routable/routable/ " )
0 commit comments