Esempio n. 1
0
 def test_path_replace_no(self):
     ss = '''
         #Markdown
         with no image
     '''
     img_det = ImageManager(ss)
     self.assertEqual(ss, img_det.replace_path_imgs('/main'))
Esempio n. 2
0
 def test_download_img(self):
     import os
     url = 'http://www.rokers.io/img/logo.png'
     imgs = [['logo rokers', url], ['image', 'img.png']]
     text = self.create_random_text_from_img_list(imgs)
     img_det = ImageManager(text)
     img_det.download('./imgs/')
     self.assertTrue(os.path.isdir("./imgs/"))
     self.assertTrue(os.path.exists("./imgs/logo.png"))
Esempio n. 3
0
 def test_path_replace_multiple(self):
     for i in range(1, 5):
         text_list = self.create_random_text_list(i)
         imgs_list = self.create_random_imgs(i)
         path = '/complex_path/test/'
         imgs_list_expected = [[img[0], path + img[1].split('/')[-1]]
                               for img in imgs_list]
         text = self.merge_text_and_img_lists(text_list, imgs_list)
         text_expected = self.merge_text_and_img_lists(
             text_list, imgs_list_expected)
         img_det = ImageManager(text)
         self.assertEqual(text_expected, img_det.replace_path_imgs(path))
Esempio n. 4
0
 def test_path_replace_any(self):
     import os.path
     for i in range(1, 20):
         text, imgs = self.create_random_text_with_img(i)
         img_det = ImageManager(text)
         path = '/img/test/'
         img_repr = [path + img.split('/')[-1] for img in img_det.imgs]
Esempio n. 5
0
 def test_general(self):
     for i in range(1, 5):
         text, imgs = self.create_random_text_with_img(i)
         img_det = ImageManager(text)
         self.assertTrue(img_det.imgs)
         self.assertEqual(len(img_det.imgs), i)
         for img in imgs:
             self.assertTrue(img[1] in img_det.imgs)
Esempio n. 6
0
    def test_no_image(self):
        ss = '''
            #Markdown
            with no image
        '''

        img_det = ImageManager(ss)
        self.assertFalse(img_det.imgs)
Esempio n. 7
0
 def test_one_image(self):
     ss = '''
         #Markdown
         with image
         ![lkjsd](img.png)
     '''
     img_det = ImageManager(ss)
     self.assertTrue(img_det.imgs)
     self.assertTrue('img.png' in img_det.imgs)
     self.assertEqual(len(img_det.imgs), 1)
Esempio n. 8
0
    def test_path_replace_one(self):
        ss = '''
            #Markdown
            with image
            ![lkjsd](img.png)
        '''

        ss_expected_1 = '''
            #Markdown
            with image
            ![lkjsd](/main/img.png)
        '''

        ss_expected_2 = '''
            #Markdown
            with image
            ![lkjsd](main/img.png)
        '''
        img_det = ImageManager(ss)
        self.assertEqual(ss_expected_1, img_det.replace_path_imgs('/main'))
        self.assertEqual(ss_expected_2, img_det.replace_path_imgs('main'))