예제 #1
0
 def test_postiniHeaderParsing(self):
     """
     Test that Postini's spam levels header can be parsed and structured
     data extracted from it.
     """
     f = Filter()
     self.assertEquals(
         f._parsePostiniHeader(
             '(S:99.9000 R:95.9108 P:91.9078 M:100.0000 C:96.6797 )'), {
                 'S': Decimal('99.9'),
                 'R': Decimal('95.9108'),
                 'P': Decimal('91.9078'),
                 'M': Decimal('100'),
                 'C': Decimal('96.6797')
             })
     self.assertEquals(
         f._parsePostiniHeader(
             '(S: 0.0901 R:95.9108 P:95.9108 M:99.5542 C:79.5348 )'), {
                 'S': Decimal('.0901'),
                 'R': Decimal('95.9108'),
                 'P': Decimal('95.9108'),
                 'M': Decimal('99.5542'),
                 'C': Decimal('79.5348')
             })
     self.assertEquals(
         f._parsePostiniHeader(
             '(S:99.90000/99.90000 R:95.9108 P:95.9108 M:97.0282 C:98.6951 )'
         ), {
             'S': Decimal('99.9'),
             'R': Decimal('95.9108'),
             'P': Decimal('95.9108'),
             'M': Decimal('97.0282'),
             'C': Decimal('98.6951')
         })
예제 #2
0
 def test_postiniHeaderParsing(self):
     """
     Test that Postini's spam levels header can be parsed and structured
     data extracted from it.
     """
     f = Filter()
     self.assertEquals(
         f._parsePostiniHeader("(S:99.9000 R:95.9108 P:91.9078 M:100.0000 C:96.6797 )"),
         {
             "S": Decimal("99.9"),
             "R": Decimal("95.9108"),
             "P": Decimal("91.9078"),
             "M": Decimal("100"),
             "C": Decimal("96.6797"),
         },
     )
     self.assertEquals(
         f._parsePostiniHeader("(S: 0.0901 R:95.9108 P:95.9108 M:99.5542 C:79.5348 )"),
         {
             "S": Decimal(".0901"),
             "R": Decimal("95.9108"),
             "P": Decimal("95.9108"),
             "M": Decimal("99.5542"),
             "C": Decimal("79.5348"),
         },
     )
     self.assertEquals(
         f._parsePostiniHeader("(S:99.90000/99.90000 R:95.9108 P:95.9108 M:97.0282 C:98.6951 )"),
         {
             "S": Decimal("99.9"),
             "R": Decimal("95.9108"),
             "P": Decimal("95.9108"),
             "M": Decimal("97.0282"),
             "C": Decimal("98.6951"),
         },
     )
예제 #3
0
 def test_postiniHeaderWithWhitespace(self):
     """
     Test that a Postini header with leading or trailing whitespace can
     also be parsed correctly.  Headers like this probably shouldn't ever
     show up, but investigation of old messages indicates they seem to
     sometimes.
     """
     f = Filter()
     self.assertEquals(
         f._parsePostiniHeader(
             '  (S:99.9000 R:95.9108 P:91.9078 M:100.0000 C:96.6797 )  \r'),
         {
             'S': Decimal('99.9'),
             'R': Decimal('95.9108'),
             'P': Decimal('91.9078'),
             'M': Decimal('100'),
             'C': Decimal('96.6797')
         })
예제 #4
0
 def test_postiniHeaderWithWhitespace(self):
     """
     Test that a Postini header with leading or trailing whitespace can
     also be parsed correctly.  Headers like this probably shouldn't ever
     show up, but investigation of old messages indicates they seem to
     sometimes.
     """
     f = Filter()
     self.assertEquals(
         f._parsePostiniHeader("  (S:99.9000 R:95.9108 P:91.9078 M:100.0000 C:96.6797 )  \r"),
         {
             "S": Decimal("99.9"),
             "R": Decimal("95.9108"),
             "P": Decimal("91.9078"),
             "M": Decimal("100"),
             "C": Decimal("96.6797"),
         },
     )