@@ -29,6 +29,8 @@ class ComponentTests(ChannelsLiveServerTestCase):
29
29
30
30
@classmethod
31
31
def setUpClass (cls ):
32
+ super ().setUpClass ()
33
+
32
34
# Repurposed from ChannelsLiveServerTestCase._pre_setup
33
35
for connection in connections .all ():
34
36
if cls ._is_in_memory_db (cls , connection ):
@@ -77,14 +79,14 @@ def tearDownClass(cls):
77
79
cls .playwright .stop ()
78
80
79
81
# Close the other server processes
82
+ cls ._server_process .terminate ()
83
+ cls ._server_process .join ()
80
84
cls ._server_process2 .terminate ()
81
85
cls ._server_process2 .join ()
82
86
cls ._server_process3 .terminate ()
83
87
cls ._server_process3 .join ()
84
88
85
89
# Repurposed from ChannelsLiveServerTestCase._post_teardown
86
- cls ._server_process .terminate ()
87
- cls ._server_process .join ()
88
90
cls ._live_server_modified_settings .disable ()
89
91
for db_name in {"default" , config .REACTPY_DATABASE }:
90
92
call_command (
@@ -95,15 +97,15 @@ def tearDownClass(cls):
95
97
reset_sequences = False ,
96
98
)
97
99
100
+ super ().tearDownClass ()
101
+
98
102
def _pre_setup (self ):
99
103
"""Handled manually in `setUpClass` to speed things up."""
100
- pass
101
104
102
105
def _post_teardown (self ):
103
106
"""Handled manually in `tearDownClass` to prevent TransactionTestCase from doing
104
107
database flushing. This is needed to prevent a `SynchronousOnlyOperation` from
105
108
occuring due to a bug within `ChannelsLiveServerTestCase`."""
106
- pass
107
109
108
110
def setUp (self ):
109
111
if self .page .url == "about:blank" :
@@ -544,26 +546,44 @@ def test_url_router(self):
544
546
new_page .goto (f"{ self .live_server_url } /router/" )
545
547
path = new_page .wait_for_selector ("#router-path" )
546
548
self .assertIn ("/router/" , path .get_attribute ("data-path" ))
549
+ string = new_page .query_selector ("#router-string" )
550
+ self .assertEqual ("/router/" , string .text_content ())
551
+
552
+ new_page .goto (f"{ self .live_server_url } /router/subroute/" )
553
+ path = new_page .wait_for_selector ("#router-path" )
554
+ self .assertIn ("/router/subroute/" , path .get_attribute ("data-path" ))
555
+ string = new_page .query_selector ("#router-string" )
556
+ self .assertEqual ("subroute/" , string .text_content ())
547
557
548
- new_page .goto (f"{ self .live_server_url } /router/any /123/" )
558
+ new_page .goto (f"{ self .live_server_url } /router/unspecified /123/" )
549
559
path = new_page .wait_for_selector ("#router-path" )
550
- self .assertIn ("/router/any/123/" , path .get_attribute ("data-path" ))
560
+ self .assertIn ("/router/unspecified/123/" , path .get_attribute ("data-path" ))
561
+ string = new_page .query_selector ("#router-string" )
562
+ self .assertEqual ("/router/unspecified/<value>/" , string .text_content ())
551
563
552
564
new_page .goto (f"{ self .live_server_url } /router/integer/123/" )
553
565
path = new_page .wait_for_selector ("#router-path" )
554
566
self .assertIn ("/router/integer/123/" , path .get_attribute ("data-path" ))
567
+ string = new_page .query_selector ("#router-string" )
568
+ self .assertEqual ("/router/integer/<int:value>/" , string .text_content ())
555
569
556
570
new_page .goto (f"{ self .live_server_url } /router/path/abc/123/" )
557
571
path = new_page .wait_for_selector ("#router-path" )
558
572
self .assertIn ("/router/path/abc/123/" , path .get_attribute ("data-path" ))
573
+ string = new_page .query_selector ("#router-string" )
574
+ self .assertEqual ("/router/path/<path:value>/" , string .text_content ())
559
575
560
576
new_page .goto (f"{ self .live_server_url } /router/slug/abc-123/" )
561
577
path = new_page .wait_for_selector ("#router-path" )
562
578
self .assertIn ("/router/slug/abc-123/" , path .get_attribute ("data-path" ))
579
+ string = new_page .query_selector ("#router-string" )
580
+ self .assertEqual ("/router/slug/<slug:value>/" , string .text_content ())
563
581
564
582
new_page .goto (f"{ self .live_server_url } /router/string/abc/" )
565
583
path = new_page .wait_for_selector ("#router-path" )
566
584
self .assertIn ("/router/string/abc/" , path .get_attribute ("data-path" ))
585
+ string = new_page .query_selector ("#router-string" )
586
+ self .assertEqual ("/router/string/<str:value>/" , string .text_content ())
567
587
568
588
new_page .goto (
569
589
f"{ self .live_server_url } /router/uuid/123e4567-e89b-12d3-a456-426614174000/"
@@ -573,18 +593,8 @@ def test_url_router(self):
573
593
"/router/uuid/123e4567-e89b-12d3-a456-426614174000/" ,
574
594
path .get_attribute ("data-path" ),
575
595
)
576
-
577
- new_page .goto (f"{ self .live_server_url } /router/abc/" )
578
- path = new_page .wait_for_selector ("#router-path" )
579
- self .assertIn ("/router/abc/" , path .get_attribute ("data-path" ))
580
-
581
- new_page .goto (f"{ self .live_server_url } /router/two/123/abc/" )
582
- path = new_page .wait_for_selector ("#router-path" )
583
- self .assertIn ("/router/two/123/abc/" , path .get_attribute ("data-path" ))
584
-
585
- new_page .goto (f"{ self .live_server_url } /router/any/one/" )
586
- path = new_page .wait_for_selector ("#router-path" )
587
- self .assertIn ("/router/any/one/" , path .get_attribute ("data-path" ))
596
+ string = new_page .query_selector ("#router-string" )
597
+ self .assertEqual ("/router/uuid/<uuid:value>/" , string .text_content ())
588
598
589
599
new_page .goto (
590
600
f"{ self .live_server_url } /router/any/adslkjgklasdjhfah/6789543256/"
@@ -595,7 +605,15 @@ def test_url_router(self):
595
605
path .get_attribute ("data-path" ),
596
606
)
597
607
string = new_page .query_selector ("#router-string" )
598
- self .assertEqual ("Path 12" , string .text_content ())
608
+ self .assertEqual ("/router/any/<any:name>" , string .text_content ())
609
+
610
+ new_page .goto (f"{ self .live_server_url } /router/two/123/abc/" )
611
+ path = new_page .wait_for_selector ("#router-path" )
612
+ self .assertIn ("/router/two/123/abc/" , path .get_attribute ("data-path" ))
613
+ string = new_page .query_selector ("#router-string" )
614
+ self .assertEqual (
615
+ "/router/two/<int:value>/<str:value2>/" , string .text_content ()
616
+ )
599
617
600
618
finally :
601
619
new_page .close ()
0 commit comments