Skip to content

Commit b5e39d8

Browse files
committed
refactor: tests: Use case for patching test ids of large frequency.
1 parent 8d9adc7 commit b5e39d8

File tree

1 file changed

+62
-54
lines changed

1 file changed

+62
-54
lines changed

tests/ui_tools/test_buttons.py

Lines changed: 62 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -549,45 +549,50 @@ def test__decode_message_id(
549549
@pytest.mark.parametrize(
550550
"link, expected_parsed_link",
551551
[
552-
(
552+
case(
553553
SERVER_URL + "/#narrow/stream/1-Stream-1",
554554
ParsedNarrowLink(
555555
narrow="stream", stream=DecodedStream(stream_id=1, stream_name=None)
556556
),
557+
id="modern_stream_narrow_link",
557558
),
558-
(
559+
case(
559560
SERVER_URL + "/#narrow/stream/Stream.201",
560561
ParsedNarrowLink(
561562
narrow="stream",
562563
stream=DecodedStream(stream_id=None, stream_name="Stream 1"),
563564
),
565+
id="deprecated_stream_narrow_link",
564566
),
565-
(
567+
case(
566568
SERVER_URL + "/#narrow/stream/1-Stream-1/topic/foo.20bar",
567569
ParsedNarrowLink(
568570
narrow="stream:topic",
569571
topic_name="foo bar",
570572
stream=DecodedStream(stream_id=1, stream_name=None),
571573
),
574+
id="topic_narrow_link",
572575
),
573-
(
576+
case(
574577
SERVER_URL + "/#narrow/stream/1-Stream-1/near/1",
575578
ParsedNarrowLink(
576579
narrow="stream:near",
577580
message_id=1,
578581
stream=DecodedStream(stream_id=1, stream_name=None),
579582
),
583+
id="stream_near_narrow_link",
580584
),
581-
(
585+
case(
582586
SERVER_URL + "/#narrow/stream/1-Stream-1/topic/foo/near/1",
583587
ParsedNarrowLink(
584588
narrow="stream:topic:near",
585589
topic_name="foo",
586590
message_id=1,
587591
stream=DecodedStream(stream_id=1, stream_name=None),
588592
),
593+
id="topic_near_narrow_link",
589594
),
590-
(
595+
case(
591596
SERVER_URL + "/#narrow/pm-with/1001,12-pm",
592597
ParsedNarrowLink(
593598
narrow="pm-with",
@@ -597,8 +602,9 @@ def test__decode_message_id(
597602
recipient_emails=["[email protected]", "[email protected]"],
598603
),
599604
),
605+
id="pm_with_two_recipients_narrow_link",
600606
),
601-
(
607+
case(
602608
SERVER_URL + "/#narrow/pm-with/1001,12-group",
603609
ParsedNarrowLink(
604610
narrow="pm-with",
@@ -608,8 +614,9 @@ def test__decode_message_id(
608614
recipient_emails=["[email protected]", "[email protected]"],
609615
),
610616
),
617+
id="group_pm_with_two_recipients_narrow_link",
611618
),
612-
(
619+
case(
613620
SERVER_URL + "/#narrow/pm-with/11-user11",
614621
ParsedNarrowLink(
615622
narrow="pm-with",
@@ -619,8 +626,9 @@ def test__decode_message_id(
619626
recipient_emails=["[email protected]", "[email protected]"],
620627
),
621628
),
629+
id="pm_exposed_format_1_narrow_link",
622630
),
623-
(
631+
case(
624632
SERVER_URL + "/#narrow/pm-with/6-bot-name",
625633
ParsedNarrowLink(
626634
narrow="pm-with",
@@ -630,8 +638,9 @@ def test__decode_message_id(
630638
recipient_emails=["[email protected]", "[email protected]"],
631639
),
632640
),
641+
id="pm_with_bot_exposed_format_1_narrow_link",
633642
),
634-
(
643+
case(
635644
SERVER_URL + "/#narrow/pm-with/1001,12-pm/near/1",
636645
ParsedNarrowLink(
637646
narrow="pm-with:near",
@@ -642,8 +651,9 @@ def test__decode_message_id(
642651
recipient_emails=["[email protected]", "[email protected]"],
643652
),
644653
),
654+
id="common_pm_near_narrow_link",
645655
),
646-
(
656+
case(
647657
SERVER_URL + "/#narrow/pm-with/1001,11,12-pm",
648658
ParsedNarrowLink(
649659
narrow="pm-with",
@@ -657,8 +667,9 @@ def test__decode_message_id(
657667
],
658668
),
659669
),
670+
id="pm_with_more_than_two_recipients_narrow_link",
660671
),
661-
(
672+
case(
662673
SERVER_URL + "/#narrow/pm-with/1001,11,12-group",
663674
ParsedNarrowLink(
664675
narrow="pm-with",
@@ -672,35 +683,34 @@ def test__decode_message_id(
672683
],
673684
),
674685
),
686+
id="group_pm_with_more_than_two_recipients_narrow_link",
675687
),
676-
(SERVER_URL + "/#narrow/foo", ParsedNarrowLink()),
677-
(SERVER_URL + "/#narrow/stream/", ParsedNarrowLink()),
678-
(SERVER_URL + "/#narrow/stream/1-Stream-1/topic/", ParsedNarrowLink()),
679-
(SERVER_URL + "/#narrow/stream/1-Stream-1//near/", ParsedNarrowLink()),
680-
(
688+
case(
689+
SERVER_URL + "/#narrow/foo",
690+
ParsedNarrowLink(),
691+
id="invalid_narrow_link_1",
692+
),
693+
case(
694+
SERVER_URL + "/#narrow/stream/",
695+
ParsedNarrowLink(),
696+
id="invalid_narrow_link_2",
697+
),
698+
case(
699+
SERVER_URL + "/#narrow/stream/1-Stream-1/topic/",
700+
ParsedNarrowLink(),
701+
id="invalid_narrow_link_3",
702+
),
703+
case(
704+
SERVER_URL + "/#narrow/stream/1-Stream-1//near/",
705+
ParsedNarrowLink(),
706+
id="invalid_narrow_link_4",
707+
),
708+
case(
681709
SERVER_URL + "/#narrow/stream/1-Stream-1/topic/foo/near/",
682710
ParsedNarrowLink(),
711+
id="invalid_narrow_link_5",
683712
),
684713
],
685-
ids=[
686-
"modern_stream_narrow_link",
687-
"deprecated_stream_narrow_link",
688-
"topic_narrow_link",
689-
"stream_near_narrow_link",
690-
"topic_near_narrow_link",
691-
"pm_with_two_recipients_narrow_link",
692-
"group_pm_with_two_recipients_narrow_link",
693-
"pm_exposed_format_1_narrow_link",
694-
"pm_with_bot_exposed_format_1_narrow_link",
695-
"common_pm_near_narrow_link",
696-
"pm_with_more_than_two_recipients_narrow_link",
697-
"group_pm_with_more_than_two_recipients_narrow_link",
698-
"invalid_narrow_link_1",
699-
"invalid_narrow_link_2",
700-
"invalid_narrow_link_3",
701-
"invalid_narrow_link_4",
702-
"invalid_narrow_link_5",
703-
],
704714
)
705715
def test__parse_narrow_link(
706716
self, link: str, expected_parsed_link: ParsedNarrowLink
@@ -1078,16 +1088,17 @@ def test__validate_pm_data(
10781088
"narrow_to_user_called",
10791089
],
10801090
[
1081-
(
1091+
case(
10821092
ParsedNarrowLink(
10831093
narrow="stream",
10841094
stream=DecodedStream(stream_id=1, stream_name="Stream 1"),
10851095
),
10861096
True,
10871097
False,
10881098
False,
1099+
id="stream_narrow",
10891100
),
1090-
(
1101+
case(
10911102
ParsedNarrowLink(
10921103
narrow="stream:topic",
10931104
topic_name="Foo",
@@ -1096,8 +1107,9 @@ def test__validate_pm_data(
10961107
False,
10971108
True,
10981109
False,
1110+
id="topic_narrow",
10991111
),
1100-
(
1112+
case(
11011113
ParsedNarrowLink(
11021114
narrow="stream:near",
11031115
message_id=1,
@@ -1106,8 +1118,9 @@ def test__validate_pm_data(
11061118
True,
11071119
False,
11081120
False,
1121+
id="stream_near_narrow",
11091122
),
1110-
(
1123+
case(
11111124
ParsedNarrowLink(
11121125
narrow="stream:topic:near",
11131126
topic_name="Foo",
@@ -1117,8 +1130,9 @@ def test__validate_pm_data(
11171130
False,
11181131
True,
11191132
False,
1133+
id="topic_near_narrow",
11201134
),
1121-
(
1135+
case(
11221136
ParsedNarrowLink(
11231137
narrow="pm-with",
11241138
pm_with=DecodedPM(
@@ -1130,8 +1144,9 @@ def test__validate_pm_data(
11301144
False,
11311145
False,
11321146
True,
1147+
id="pm_narrow",
11331148
),
1134-
(
1149+
case(
11351150
ParsedNarrowLink(
11361151
narrow="pm-with",
11371152
pm_with=DecodedPM(
@@ -1147,8 +1162,9 @@ def test__validate_pm_data(
11471162
False,
11481163
False,
11491164
True,
1165+
id="group_pm_narrow",
11501166
),
1151-
(
1167+
case(
11521168
ParsedNarrowLink(
11531169
narrow="pm-with:near",
11541170
message_id=1,
@@ -1161,8 +1177,9 @@ def test__validate_pm_data(
11611177
False,
11621178
False,
11631179
True,
1180+
id="pm_near_narrow",
11641181
),
1165-
(
1182+
case(
11661183
ParsedNarrowLink(
11671184
narrow="pm-with:near",
11681185
message_id=1,
@@ -1179,18 +1196,9 @@ def test__validate_pm_data(
11791196
False,
11801197
False,
11811198
True,
1199+
id="group_pm_near_narrow",
11821200
),
11831201
],
1184-
ids=[
1185-
"stream_narrow",
1186-
"topic_narrow",
1187-
"stream_near_narrow",
1188-
"topic_near_narrow",
1189-
"pm_narrow",
1190-
"group_pm_narrow",
1191-
"pm_near_narrow",
1192-
"group_pm_near_narrow",
1193-
],
11941202
)
11951203
def test__switch_narrow_to(
11961204
self,

0 commit comments

Comments
 (0)