示例#1
0
 def test_expand_db_attributes_for_editor_throws_exception(self, mock_file, mock_image):
     result = ImageEmbedHandler.expand_db_attributes(
         {'id': 1,
          'format': 'left'},
         True
     )
     self.assertEqual(result, '')
 def expand_db_attributes(attrs, for_editor):
     img = ImageEmbedHandler.expand_db_attributes(attrs, for_editor)
     clazz = ''
     if 'format' in attrs:
         clazz = 'class="image-%s-aligned"' % attrs['format']
     if not for_editor:
         return '<div %s>%s<p class="intext-image-title">%s</p></div>' % (clazz, img, attrs['alt'])
示例#3
0
 def test_expand_db_attributes_for_editor_throws_exception(
         self, mock_file, mock_image):
     result = ImageEmbedHandler.expand_db_attributes(
         {
             'id': 1,
             'format': 'left'
         }, True)
     self.assertEqual(result, '')
示例#4
0
 def test_expand_db_attributes_not_for_editor(self, mock_file, mock_image):
     result = ImageEmbedHandler.expand_db_attributes(
         {
             'id': 1,
             'alt': 'test-alt',
             'format': 'left'
         }, False)
     self.assertIn('<img class="richtext-image left"', result)
示例#5
0
 def test_expand_db_attributes_for_editor(self, mock_file, mock_image):
     result = ImageEmbedHandler.expand_db_attributes(
         {'id': 1,
          'alt': 'test-alt',
          'format': 'left'},
         True
     )
     self.assertIn('<img data-embedtype="image" data-id="1" data-format="left" data-alt="test-alt" class="richtext-image left"', result)
示例#6
0
 def test_expand_db_attributes_not_for_editor(self, mock_file, mock_image):
     result = ImageEmbedHandler.expand_db_attributes(
         {'id': 1,
          'alt': 'test-alt',
          'format': 'left'},
         False
     )
     self.assertIn('<img class="richtext-image left"', result)
示例#7
0
 def test_expand_db_attributes_for_editor(self, mock_file, mock_image):
     result = ImageEmbedHandler.expand_db_attributes(
         {
             'id': 1,
             'alt': 'test-alt',
             'format': 'left'
         }, True)
     self.assertIn(
         '<img data-embedtype="image" data-id="1" data-format="left" data-alt="test-alt" class="richtext-image left"',
         result)
示例#8
0
 def test_get_db_attributes(self):
     soup = BeautifulSoup(
         '<b data-id="test-id" data-format="test-format" data-alt="test-alt">foo</b>'
     )
     tag = soup.b
     result = ImageEmbedHandler.get_db_attributes(tag)
     self.assertEqual(result,
                      {'alt': 'test-alt',
                       'id': 'test-id',
                       'format': 'test-format'})
示例#9
0
 def test_get_db_attributes(self):
     soup = BeautifulSoup(
         '<b data-id="test-id" data-format="test-format" data-alt="test-alt">foo</b>'
     )
     tag = soup.b
     result = ImageEmbedHandler.get_db_attributes(tag)
     self.assertEqual(result, {
         'alt': 'test-alt',
         'id': 'test-id',
         'format': 'test-format'
     })
示例#10
0
 def test_expand_db_attributes_page_does_not_exist(self):
     result = ImageEmbedHandler.expand_db_attributes({'id': 0}, False)
     self.assertEqual(result, '<img>')
示例#11
0
 def test_expand_db_attributes_page_does_not_exist(self):
     result = ImageEmbedHandler.expand_db_attributes(
         {'id': 0},
         False
     )
     self.assertEqual(result, '<img>')