()
| 614 | |
| 615 | |
| 616 | def test_rule_templates(): |
| 617 | testcase = r.RuleTemplate( |
| 618 | [ |
| 619 | r.Submount( |
| 620 | "/test/$app", |
| 621 | [ |
| 622 | r.Rule("/foo/", endpoint="handle_foo"), |
| 623 | r.Rule("/bar/", endpoint="handle_bar"), |
| 624 | r.Rule("/baz/", endpoint="handle_baz"), |
| 625 | ], |
| 626 | ), |
| 627 | r.EndpointPrefix( |
| 628 | "${app}", |
| 629 | [ |
| 630 | r.Rule("/${app}-blah", endpoint="bar"), |
| 631 | r.Rule("/${app}-meh", endpoint="baz"), |
| 632 | ], |
| 633 | ), |
| 634 | r.Subdomain( |
| 635 | "$app", |
| 636 | [r.Rule("/blah", endpoint="x_bar"), r.Rule("/meh", endpoint="x_baz")], |
| 637 | ), |
| 638 | ] |
| 639 | ) |
| 640 | |
| 641 | url_map = r.Map( |
| 642 | [ |
| 643 | testcase(app="test1"), |
| 644 | testcase(app="test2"), |
| 645 | testcase(app="test3"), |
| 646 | testcase(app="test4"), |
| 647 | ] |
| 648 | ) |
| 649 | |
| 650 | out = sorted((x.rule, x.subdomain, x.endpoint) for x in url_map.iter_rules()) |
| 651 | |
| 652 | assert out == [ |
| 653 | ("/blah", "test1", "x_bar"), |
| 654 | ("/blah", "test2", "x_bar"), |
| 655 | ("/blah", "test3", "x_bar"), |
| 656 | ("/blah", "test4", "x_bar"), |
| 657 | ("/meh", "test1", "x_baz"), |
| 658 | ("/meh", "test2", "x_baz"), |
| 659 | ("/meh", "test3", "x_baz"), |
| 660 | ("/meh", "test4", "x_baz"), |
| 661 | ("/test/test1/bar/", "", "handle_bar"), |
| 662 | ("/test/test1/baz/", "", "handle_baz"), |
| 663 | ("/test/test1/foo/", "", "handle_foo"), |
| 664 | ("/test/test2/bar/", "", "handle_bar"), |
| 665 | ("/test/test2/baz/", "", "handle_baz"), |
| 666 | ("/test/test2/foo/", "", "handle_foo"), |
| 667 | ("/test/test3/bar/", "", "handle_bar"), |
| 668 | ("/test/test3/baz/", "", "handle_baz"), |
| 669 | ("/test/test3/foo/", "", "handle_foo"), |
| 670 | ("/test/test4/bar/", "", "handle_bar"), |
| 671 | ("/test/test4/baz/", "", "handle_baz"), |
| 672 | ("/test/test4/foo/", "", "handle_foo"), |
| 673 | ("/test1-blah", "", "test1bar"), |
nothing calls this directly
no test coverage detected