| | 628 | def test_props_format_ambiwidth_single(self): |
| | 629 | self.env.config.set('notification', 'mime_encoding', 'none') |
| | 630 | self.env.config.set('notification', 'ambiguous_char_width', '') |
| | 631 | ticket = Ticket(self.env) |
| | 632 | ticket['summary'] = u'This is a summary' |
| | 633 | ticket['reporter'] = u'аnonymoиs' |
| | 634 | ticket['status'] = u'new' |
| | 635 | ticket['owner'] = u'somеbody' |
| | 636 | ticket['type'] = u'バグ(dеfеct)' |
| | 637 | ticket['priority'] = u'メジャー(mаjor)' |
| | 638 | ticket['milestone'] = u'マイルストーン1' |
| | 639 | ticket['component'] = u'コンポーネント1' |
| | 640 | ticket['version'] = u'2.0 аlphа' |
| | 641 | ticket['resolution'] = u'fixed' |
| | 642 | ticket['keywords'] = u'' |
| | 643 | ticket.insert() |
| | 644 | formatted = """\ |
| | 645 | Reporter: аnonymoиs | Owner: somеbody |
| | 646 | Type: バグ(dеfеct) | Status: new |
| | 647 | Priority: メジャー(mаjor) | Milestone: マイルストーン1 |
| | 648 | Component: コンポーネント1 | Version: 2.0 аlphа |
| | 649 | Resolution: fixed | Keywords:""" |
| | 650 | self._validate_props_format(formatted, ticket, True) |
| | 651 | |
| | 652 | def test_props_format_ambiwidth_double(self): |
| | 653 | self.env.config.set('notification', 'mime_encoding', 'none') |
| | 654 | self.env.config.set('notification', 'ambiguous_char_width', 'double') |
| | 655 | ticket = Ticket(self.env) |
| | 656 | ticket['summary'] = u'This is a summary' |
| | 657 | ticket['reporter'] = u'аnonymoиs' |
| | 658 | ticket['status'] = u'new' |
| | 659 | ticket['owner'] = u'somеbody' |
| | 660 | ticket['type'] = u'バグ(dеfеct)' |
| | 661 | ticket['priority'] = u'メジャー(mаjor)' |
| | 662 | ticket['milestone'] = u'マイルストーン1' |
| | 663 | ticket['component'] = u'コンポーネント1' |
| | 664 | ticket['version'] = u'2.0 аlphа' |
| | 665 | ticket['resolution'] = u'fixed' |
| | 666 | ticket['keywords'] = u'' |
| | 667 | ticket.insert() |
| | 668 | formatted = """\ |
| | 669 | Reporter: аnonymoиs | Owner: somеbody |
| | 670 | Type: バグ(dеfеct) | Status: new |
| | 671 | Priority: メジャー(mаjor) | Milestone: マイルストーン1 |
| | 672 | Component: コンポーネント1 | Version: 2.0 аlphа |
| | 673 | Resolution: fixed | Keywords:""" |
| | 674 | self._validate_props_format(formatted, ticket, True) |
| | 675 | |
| | 676 | def test_props_format_obfuscated_email(self): |
| | 677 | self.env.config.set('notification', 'mime_encoding', 'none') |
| | 678 | ticket = Ticket(self.env) |
| | 679 | ticket['summary'] = u'This is a summary' |
| | 680 | ticket['reporter'] = u'joe@foobar.foo.bar.example.org' |
| | 681 | ticket['status'] = u'new' |
| | 682 | ticket['owner'] = u'joe.bar@foobar.foo.bar.example.org' |
| | 683 | ticket['type'] = u'defect' |
| | 684 | ticket['priority'] = u'major' |
| | 685 | ticket['milestone'] = u'milestone1' |
| | 686 | ticket['component'] = u'component1' |
| | 687 | ticket['version'] = u'2.0' |
| | 688 | ticket['resolution'] = u'fixed' |
| | 689 | ticket['keywords'] = u'' |
| | 690 | ticket.insert() |
| | 691 | formatted = """\ |
| | 692 | Reporter: joe@… | Owner: joe.bar@… |
| | 693 | Type: defect | Status: new |
| | 694 | Priority: major | Milestone: milestone1 |
| | 695 | Component: component1 | Version: 2.0 |
| | 696 | Resolution: fixed | Keywords:""" |
| | 697 | self._validate_props_format(formatted, ticket, True) |
| | 698 | |
| | 699 | def test_props_format_wrap_leftside(self): |
| | 700 | self.env.config.set('notification', 'mime_encoding', 'none') |
| | 701 | ticket = Ticket(self.env) |
| | 702 | ticket['summary'] = u'This is a summary' |
| | 703 | ticket['reporter'] = u'anonymous' |
| | 704 | ticket['status'] = u'new' |
| | 705 | ticket['owner'] = u'somebody' |
| | 706 | ticket['type'] = u'defect' |
| | 707 | ticket['priority'] = u'major' |
| | 708 | ticket['milestone'] = u'milestone1' |
| | 709 | ticket['component'] = u'Lorem ipsum dolor sit amet, consectetur ' \ |
| | 710 | u'adipisicing elit, sed do eiusmod tempor ' \ |
| | 711 | u'incididunt ut labore et dolore magna ' \ |
| | 712 | u'aliqua. Ut enim ad minim veniam, quis ' \ |
| | 713 | u'nostrud exercitation ullamco laboris nisi ' \ |
| | 714 | u'ut aliquip ex ea commodo consequat. Duis ' \ |
| | 715 | u'aute irure dolor in reprehenderit in ' \ |
| | 716 | u'voluptate velit esse cillum dolore eu ' \ |
| | 717 | u'fugiat nulla pariatur. Excepteur sint ' \ |
| | 718 | u'occaecat cupidatat non proident, sunt in ' \ |
| | 719 | u'culpa qui officia deserunt mollit anim id ' \ |
| | 720 | u'est laborum.' |
| | 721 | ticket['version'] = u'2.0' |
| | 722 | ticket['resolution'] = u'fixed' |
| | 723 | ticket['keywords'] = u'' |
| | 724 | ticket.insert() |
| | 725 | formatted = """\ |
| | 726 | Reporter: anonymous | Owner: somebody |
| | 727 | Type: defect | Status: new |
| | 728 | Priority: major | Milestone: milestone1 |
| | 729 | Component: Lorem ipsum dolor sit amet, | Version: 2.0 |
| | 730 | consectetur adipisicing elit, sed do eiusmod | Keywords: |
| | 731 | tempor incididunt ut labore et dolore magna | |
| | 732 | aliqua. Ut enim ad minim veniam, quis nostrud | |
| | 733 | exercitation ullamco laboris nisi ut aliquip | |
| | 734 | ex ea commodo consequat. Duis aute irure | |
| | 735 | dolor in reprehenderit in voluptate velit | |
| | 736 | esse cillum dolore eu fugiat nulla pariatur. | |
| | 737 | Excepteur sint occaecat cupidatat non | |
| | 738 | proident, sunt in culpa qui officia deserunt | |
| | 739 | mollit anim id est laborum. | |
| | 740 | Resolution: fixed |""" |
| | 741 | self._validate_props_format(formatted, ticket, True) |
| | 742 | |
| | 743 | def test_props_format_wrap_rightside(self): |
| | 744 | self.env.config.set('notification', 'mime_encoding', 'none') |
| | 745 | ticket = Ticket(self.env) |
| | 746 | ticket['summary'] = u'This is a summary' |
| | 747 | ticket['reporter'] = u'anonymous' |
| | 748 | ticket['status'] = u'new' |
| | 749 | ticket['owner'] = u'somebody' |
| | 750 | ticket['type'] = u'defect' |
| | 751 | ticket['priority'] = u'major' |
| | 752 | ticket['milestone'] = u'Lorem ipsum dolor sit amet, consectetur ' \ |
| | 753 | u'adipisicing elit, sed do eiusmod tempor ' \ |
| | 754 | u'incididunt ut labore et dolore magna ' \ |
| | 755 | u'aliqua. Ut enim ad minim veniam, quis ' \ |
| | 756 | u'nostrud exercitation ullamco laboris nisi ' \ |
| | 757 | u'ut aliquip ex ea commodo consequat. Duis ' \ |
| | 758 | u'aute irure dolor in reprehenderit in ' \ |
| | 759 | u'voluptate velit esse cillum dolore eu ' \ |
| | 760 | u'fugiat nulla pariatur. Excepteur sint ' \ |
| | 761 | u'occaecat cupidatat non proident, sunt in ' \ |
| | 762 | u'culpa qui officia deserunt mollit anim id ' \ |
| | 763 | u'est laborum.' |
| | 764 | ticket['component'] = u'component1' |
| | 765 | ticket['version'] = u'2.0' |
| | 766 | ticket['resolution'] = u'fixed' |
| | 767 | ticket['keywords'] = u'' |
| | 768 | ticket.insert() |
| | 769 | formatted = """\ |
| | 770 | Reporter: anonymous | Owner: somebody |
| | 771 | Type: defect | Status: new |
| | 772 | Priority: major | Milestone: Lorem ipsum dolor sit amet, |
| | 773 | Component: component1 | consectetur adipisicing elit, sed do eiusmod |
| | 774 | Resolution: fixed | tempor incididunt ut labore et dolore magna |
| | 775 | | aliqua. Ut enim ad minim veniam, quis nostrud |
| | 776 | | exercitation ullamco laboris nisi ut aliquip ex |
| | 777 | | ea commodo consequat. Duis aute irure dolor in |
| | 778 | | reprehenderit in voluptate velit esse cillum |
| | 779 | | dolore eu fugiat nulla pariatur. Excepteur sint |
| | 780 | | occaecat cupidatat non proident, sunt in culpa |
| | 781 | | qui officia deserunt mollit anim id est |
| | 782 | | laborum. |
| | 783 | | Version: 2.0 |
| | 784 | | Keywords:""" |
| | 785 | self._validate_props_format(formatted, ticket, True) |
| | 786 | |
| | 787 | def test_props_format_wrap_bothsides(self): |
| | 788 | self.env.config.set('notification', 'mime_encoding', 'none') |
| | 789 | ticket = Ticket(self.env) |
| | 790 | ticket['summary'] = u'This is a summary' |
| | 791 | ticket['reporter'] = u'anonymous' |
| | 792 | ticket['status'] = u'new' |
| | 793 | ticket['owner'] = u'somebody' |
| | 794 | ticket['type'] = u'defect' |
| | 795 | ticket['priority'] = u'major' |
| | 796 | ticket['milestone'] = u'Lorem ipsum dolor sit amet, consectetur ' \ |
| | 797 | u'adipisicing elit, sed do eiusmod tempor ' \ |
| | 798 | u'incididunt ut labore et dolore magna ' \ |
| | 799 | u'aliqua. Ut enim ad minim veniam, quis ' \ |
| | 800 | u'nostrud exercitation ullamco laboris nisi ' \ |
| | 801 | u'ut aliquip ex ea commodo consequat. Duis ' \ |
| | 802 | u'aute irure dolor in reprehenderit in ' \ |
| | 803 | u'voluptate velit esse cillum dolore eu ' \ |
| | 804 | u'fugiat nulla pariatur. Excepteur sint ' \ |
| | 805 | u'occaecat cupidatat non proident, sunt in ' \ |
| | 806 | u'culpa qui officia deserunt mollit anim id ' \ |
| | 807 | u'est laborum.' |
| | 808 | ticket['component'] = ticket['milestone'] |
| | 809 | ticket['version'] = u'2.0' |
| | 810 | ticket['resolution'] = u'fixed' |
| | 811 | ticket['keywords'] = u'' |
| | 812 | ticket.insert() |
| | 813 | formatted = """\ |
| | 814 | Reporter: anonymous | Owner: somebody |
| | 815 | Type: defect | Status: new |
| | 816 | Priority: major | Milestone: Lorem ipsum dolor sit |
| | 817 | Component: Lorem ipsum dolor sit | amet, consectetur adipisicing elit, |
| | 818 | amet, consectetur adipisicing | sed do eiusmod tempor incididunt ut |
| | 819 | elit, sed do eiusmod tempor | labore et dolore magna aliqua. Ut |
| | 820 | incididunt ut labore et dolore | enim ad minim veniam, quis nostrud |
| | 821 | magna aliqua. Ut enim ad minim | exercitation ullamco laboris nisi |
| | 822 | veniam, quis nostrud exercitation | ut aliquip ex ea commodo consequat. |
| | 823 | ullamco laboris nisi ut aliquip | Duis aute irure dolor in |
| | 824 | ex ea commodo consequat. Duis | reprehenderit in voluptate velit |
| | 825 | aute irure dolor in reprehenderit | esse cillum dolore eu fugiat nulla |
| | 826 | in voluptate velit esse cillum | pariatur. Excepteur sint occaecat |
| | 827 | dolore eu fugiat nulla pariatur. | cupidatat non proident, sunt in |
| | 828 | Excepteur sint occaecat cupidatat | culpa qui officia deserunt mollit |
| | 829 | non proident, sunt in culpa qui | anim id est laborum. |
| | 830 | officia deserunt mollit anim id | Version: 2.0 |
| | 831 | est laborum. | Keywords: |
| | 832 | Resolution: fixed |""" |
| | 833 | self._validate_props_format(formatted, ticket, True) |
| | 834 | |
| | 835 | def _validate_props_format(self, expected, ticket, newtk): |
| | 836 | tn = TicketNotifyEmail(self.env) |
| | 837 | tn.notify(ticket, newticket=newtk) |
| | 838 | message = notifysuite.smtpd.get_message() |
| | 839 | (headers, body) = parse_smtp_message(message) |
| | 840 | bodylines = body.splitlines() |
| | 841 | # Extract ticket properties |
| | 842 | delim_re = re.compile(r'^\-+\+\-+$') |
| | 843 | while not delim_re.match(bodylines[0]): |
| | 844 | bodylines.pop(0) |
| | 845 | lines = [] |
| | 846 | for line in bodylines[1:]: |
| | 847 | if delim_re.match(line): |
| | 848 | break |
| | 849 | lines.append(line) |
| | 850 | self.assertEqual(expected, '\n'.join(lines)) |
| | 851 | |