예제 #1
0
 def test_external_link(self):
     soup = BeautifulSoup(
         '<a href="https://wwww.google.com">external link/a>',
         'html.parser')
     output = str(parse_links(soup))
     self.assertIn('external-site', output)
     self.assertIn('class="icon-link_text"', output)
예제 #2
0
 def test_cfpb_link(self):
     soup = BeautifulSoup(
         '<a href="http://www.consumerfinance.gov/foo">cfpb link</a>',
         'html.parser')
     output = str(parse_links(soup))
     self.assertNotIn('external-site', output)
     self.assertNotIn('class="icon-link_text"', output)
예제 #3
0
def _process_data(field):
    if isinstance(field, basestring):
        field = parse_links(field).encode(formatter=None)
    elif isinstance(field, list):
        for i, value in enumerate(field):
            field[i] = _process_data(value)
    elif isinstance(field, dict):
        for key, value in field.iteritems():
            field[key] = _process_data(value)
    return field
예제 #4
0
def process_external_link_field(field):
    # Convert any HTTP image links to S3 to HTTPS.
    # noop if AWS_STORAGE_BUCKET_NAME is not set
    if getattr(settings, 'AWS_STORAGE_BUCKET_NAME', None):
        field = convert_http_image_links(field, [
            (http_s3_url_prefix(), https_s3_url_prefix()),
        ])

        # Add appropriate markup to all links in HTML.
        field = parse_links(field).encode(formatter=None)

    return field
예제 #5
0
 def test_gov_link(self):
     soup = BeautifulSoup('<a href="http://www.fdic.gov/bar">gov link</a>', 'html.parser')
     output = str(parse_links(soup))
     self.assertNotIn('external-site', output)
     self.assertIn('class="icon-link_text"', output)
예제 #6
0
 def test_cfpb_link(self):
     soup = BeautifulSoup('<a href="http://www.consumerfinance.gov/foo">cfpb link</a>', 'html.parser')
     output = str(parse_links(soup))
     self.assertNotIn('external-site', output)
     self.assertNotIn('class="icon-link_text"', output)
예제 #7
0
 def test_gov_link(self):
     link = '<a href="http://www.fdic.gov/bar">gov link</a>'
     output = str(parse_links(link))
     self.assertNotIn('external-site', output)
     self.assertIn('class="icon-link_text"', output)
예제 #8
0
 def test_cfpb_link(self):
     link = '<a href="http://www.consumerfinance.gov/foo">cfpb link</a>'
     output = str(parse_links(link))
     self.assertNotIn('external-site', output)
     self.assertNotIn('class="icon-link_text"', output)
예제 #9
0
 def test_external_link(self):
     link = '<a href="https://wwww.google.com">external link/a>'
     output = str(parse_links(link))
     self.assertIn('external-site', output)
     self.assertIn('class="icon-link_text"', output)
예제 #10
0
 def test_gov_link(self):
     link = '<a href="http://www.fdic.gov/bar">gov link</a>'
     output = str(parse_links(link))
     self.assertNotIn('external-site', output)
     self.assertIn('class="icon-link_text"', output)
예제 #11
0
 def test_external_link(self):
     link = '<a href="https://wwww.google.com">external link/a>'
     output = str(parse_links(link))
     self.assertIn('external-site', output)
     self.assertIn('class="icon-link_text"', output)
예제 #12
0
 def test_different_case_pdf_link_gets_download_icon(self):
     link = '<a href="/something.PDF">link</a>'
     parsed = str(parse_links(link))
     self.assertIn('cf-icon-download', parsed)
예제 #13
0
 def test_parse_links_returns_beautiful_soup(self):
     self.assertIsInstance(
         parse_links('<a href="/something">text</a>'),
         BeautifulSoup
     )
예제 #14
0
 def test_gov_link(self):
     soup = BeautifulSoup('<a href="http://www.fdic.gov/bar">gov link</a>',
                          'html.parser')
     output = str(parse_links(soup))
     self.assertNotIn('external-site', output)
     self.assertIn('class="icon-link_text"', output)
예제 #15
0
 def test_external_link(self):
     soup = BeautifulSoup('<a href="https://wwww.google.com">external link/a>', 'html.parser')
     output = str(parse_links(soup))
     self.assertIn('external-site', output)
     self.assertIn('class="icon-link_text"', output)
예제 #16
0
 def test_cfpb_link(self):
     link = '<a href="http://www.consumerfinance.gov/foo">cfpb link</a>'
     output = str(parse_links(link))
     self.assertNotIn('external-site', output)
     self.assertNotIn('class="icon-link_text"', output)
예제 #17
0
 def test_pdf_link_gets_download_icon(self):
     link = '<a href="/something.pdf">link</a>'
     parsed = str(parse_links(link))
     self.assertIn('cf-icon-svg', parsed)