def test_ordered_lists_markup_transformation(self):
        """ webcomment - ordered lists markup transformation """
        washer = EmailWasher()
        body_input = """<ol>
          <li>foo</li>
          <li>bar</li>
        </ol>"""
        body_expected = """
  1. foo
  2. bar
"""
        self.assertEqual(washer.wash(body_input), body_expected)

        # Without spaces and EOL
        body_input = '<ol><li>foo</li><li>bar</li></ol>'
        self.assertEqual(washer.wash(body_input), body_expected)
    def test_links_markup_transformation(self):
        """ webcomment - links markup transformation """

        washer = EmailWasher()
        body_input = 'text http://foo.com some more text'
        body_expected = 'text http://foo.com some more text'
        self.assertEqual(washer.wash(body_input), body_expected)

        washer = EmailWasher()
        body_input = '<a href="https://cds.cern.ch/">CDS</a>'
        body_expected = '<https://cds.cern.ch/>(CDS)'
        self.assertEqual(washer.wash(body_input), body_expected)

        washer = EmailWasher()
        body_input = '<a href="https://cds.cern.ch/">https://cds.cern.ch/</a>'
        body_expected = '<https://cds.cern.ch/>'
        self.assertEqual(washer.wash(body_input), body_expected)
    def test_ordered_lists_markup_transformation(self):
        """ webcomment - ordered lists markup transformation """
        washer = EmailWasher()
        body_input = """<ol>
          <li>foo</li>
          <li>bar</li>
        </ol>"""
        body_expected = """
  1. foo
  2. bar
"""
        self.assertEqual(washer.wash(body_input),
                         body_expected)

        # Without spaces and EOL
        body_input = '<ol><li>foo</li><li>bar</li></ol>'
        self.assertEqual(washer.wash(body_input),
                         body_expected)
    def test_links_markup_transformation(self):
        """ webcomment - links markup transformation """

        washer = EmailWasher()
        body_input = 'text http://foo.com some more text'
        body_expected = 'text http://foo.com some more text'
        self.assertEqual(washer.wash(body_input),
                         body_expected)

        washer = EmailWasher()
        body_input = '<a href="https://cds.cern.ch/">CDS</a>'
        body_expected = '<https://cds.cern.ch/>(CDS)'
        self.assertEqual(washer.wash(body_input),
                         body_expected)

        washer = EmailWasher()
        body_input = '<a href="https://cds.cern.ch/">https://cds.cern.ch/</a>'
        body_expected = '<https://cds.cern.ch/>'
        self.assertEqual(washer.wash(body_input),
                         body_expected)
Beispiel #5
0
    def test_global_markup_transformation(self):
        """ webcomment - global transformation """
        washer = EmailWasher()
        body_input = """<a href="http://foo.com">http://foo.com</a>
        <ol>
          <li>Main Ordered List item</li>
          <li>Below is an example of HTML nested unordered list
            <ul>
              <li>nested list item 1</li>

                 <li>nested list item 2</li>
              <li>Sub nested ordered list
                <ol>
                  <li>sub nested list item A</li>
                  <li>sub nested list item B</li>
                </ol>
              </li>
            </ul>
          </li>
          <li>The last line in the main ordered list</li>
        </ol> <a href="http://foo.com">bar</a>"""
        body_expected = """<http://foo.com>
  1. Main Ordered List item
  2. Below is an example of HTML nested unordered list
    * nested list item 1
    * nested list item 2
    * Sub nested ordered list
      1. sub nested list item A
      2. sub nested list item B
  3. The last line in the main ordered list
 <http://foo.com>(bar)"""
        self.assertEqual(washer.wash(body_input),
                         body_expected)

        # Without spaces and EOL
        body_input = '<a href="http://foo.com">http://foo.com</a><ol><li>Main Ordered List item</li><li>Below is an example of HTML nested unordered list<ul><li>nested list item 1</li><li>nested list item 2</li><li>Sub nested ordered list<ol><li>sub nested list item A</li><li>sub nested list item B</li></ol></li></ul></li><li>The last line in the main ordered list</li></ol> <a href="http://foo.com">bar</a>'
        self.assertEqual(washer.wash(body_input),
                         body_expected)
    def test_global_markup_transformation(self):
        """ webcomment - global transformation """
        washer = EmailWasher()
        body_input = """<a href="http://foo.com">http://foo.com</a>
        <ol>
          <li>Main Ordered List item</li>
          <li>Below is an example of HTML nested unordered list
            <ul>
              <li>nested list item 1</li>

                 <li>nested list item 2</li>
              <li>Sub nested ordered list
                <ol>
                  <li>sub nested list item A</li>
                  <li>sub nested list item B</li>
                </ol>
              </li>
            </ul>
          </li>
          <li>The last line in the main ordered list</li>
        </ol> <a href="http://foo.com">bar</a>"""
        body_expected = """<http://foo.com>
  1. Main Ordered List item
  2. Below is an example of HTML nested unordered list
    * nested list item 1
    * nested list item 2
    * Sub nested ordered list
      1. sub nested list item A
      2. sub nested list item B
  3. The last line in the main ordered list
 <http://foo.com>(bar)"""
        self.assertEqual(washer.wash(body_input),
                         body_expected)

        # Without spaces and EOL
        body_input = '<a href="http://foo.com">http://foo.com</a><ol><li>Main Ordered List item</li><li>Below is an example of HTML nested unordered list<ul><li>nested list item 1</li><li>nested list item 2</li><li>Sub nested ordered list<ol><li>sub nested list item A</li><li>sub nested list item B</li></ol></li></ul></li><li>The last line in the main ordered list</li></ol> <a href="http://foo.com">bar</a>'
        self.assertEqual(washer.wash(body_input),
                         body_expected)