@@ -659,3 +659,132 @@ def test_add_ftl(self):
659
659
)
660
660
661
661
ctx .maybe_add_localization ('privacy.ftl' )
662
+
663
+
664
+ class TestMessagesEqual (unittest .TestCase ):
665
+ maxDiff = None
666
+
667
+ def setUp (self ):
668
+ # Silence all logging.
669
+ logging .disable (logging .CRITICAL )
670
+
671
+ self .ctx = MergeContext (
672
+ lang = 'pl' ,
673
+ reference_dir = here ('fixtures/en-US' ),
674
+ localization_dir = here ('fixtures/pl' )
675
+ )
676
+
677
+ def tearDown (self ):
678
+ # Resume logging.
679
+ logging .disable (logging .NOTSET )
680
+
681
+ def test_messages_equal (self ):
682
+ first = FTL .Resource ([
683
+ FTL .Message (
684
+ id = FTL .Identifier ('bar' ),
685
+ value = FTL .Pattern ([
686
+ FTL .TextElement ('Hardcoded Value' )
687
+ ])
688
+ ),
689
+ ])
690
+ second = FTL .Resource ([
691
+ FTL .Message (
692
+ id = FTL .Identifier ('bar' ),
693
+ value = FTL .Pattern ([
694
+ FTL .TextElement ('Hardcoded Value' )
695
+ ])
696
+ ),
697
+ ])
698
+ self .assertTrue (self .ctx .messages_equal (first , second ))
699
+
700
+ def test_messages_different_attributes (self ):
701
+ first = FTL .Resource ([
702
+ FTL .Message (
703
+ id = FTL .Identifier ('bar' ),
704
+ value = FTL .Pattern ([
705
+ FTL .TextElement ('Hardcoded Value' )
706
+ ])
707
+ ),
708
+ ])
709
+ second = FTL .Resource ([
710
+ FTL .Message (
711
+ id = FTL .Identifier ('bar' ),
712
+ value = FTL .Pattern ([
713
+ FTL .TextElement ('Hardcoded Value' )
714
+ ]),
715
+ attributes = [
716
+ FTL .Attribute (
717
+ FTL .Identifier ('one' ),
718
+ value = FTL .Pattern ([
719
+ FTL .TextElement ('Attribute Value' )
720
+ ])
721
+ ),
722
+ ]
723
+ ),
724
+ ])
725
+ self .assertFalse (self .ctx .messages_equal (first , second ))
726
+
727
+ def test_terms_equal (self ):
728
+ first = FTL .Resource ([
729
+ FTL .Term (
730
+ id = FTL .Identifier ('-bar' ),
731
+ value = FTL .Pattern ([
732
+ FTL .TextElement ('Hardcoded Value' )
733
+ ])
734
+ ),
735
+ ])
736
+ second = FTL .Resource ([
737
+ FTL .Term (
738
+ id = FTL .Identifier ('-bar' ),
739
+ value = FTL .Pattern ([
740
+ FTL .TextElement ('Hardcoded Value' )
741
+ ])
742
+ ),
743
+ ])
744
+ self .assertTrue (self .ctx .messages_equal (first , second ))
745
+
746
+ def test_terms_different_attributes (self ):
747
+ first = FTL .Resource ([
748
+ FTL .Term (
749
+ id = FTL .Identifier ('-bar' ),
750
+ value = FTL .Pattern ([
751
+ FTL .TextElement ('Hardcoded Value' )
752
+ ])
753
+ ),
754
+ ])
755
+ second = FTL .Resource ([
756
+ FTL .Term (
757
+ id = FTL .Identifier ('-bar' ),
758
+ value = FTL .Pattern ([
759
+ FTL .TextElement ('Hardcoded Value' )
760
+ ]),
761
+ attributes = [
762
+ FTL .Attribute (
763
+ FTL .Identifier ('one' ),
764
+ value = FTL .Pattern ([
765
+ FTL .TextElement ('Attribute Value' )
766
+ ])
767
+ ),
768
+ ]
769
+ ),
770
+ ])
771
+ self .assertFalse (self .ctx .messages_equal (first , second ))
772
+
773
+ def test_term_and_message (self ):
774
+ first = FTL .Resource ([
775
+ FTL .Term (
776
+ id = FTL .Identifier ('-bar' ),
777
+ value = FTL .Pattern ([
778
+ FTL .TextElement ('Hardcoded Value' )
779
+ ])
780
+ ),
781
+ ])
782
+ second = FTL .Resource ([
783
+ FTL .Message (
784
+ id = FTL .Identifier ('bar' ),
785
+ value = FTL .Pattern ([
786
+ FTL .TextElement ('Hardcoded Value' )
787
+ ])
788
+ ),
789
+ ])
790
+ self .assertFalse (self .ctx .messages_equal (first , second ))
0 commit comments