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')
         })
Exemple #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"),
         },
     )
 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')
         })
Exemple #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"),
         },
     )