Exemplo n.º 1
0
 def test_thumbnail_return_img_path_when_exist(self):
     with patch('library.models.os') as mock_os:
         mock_os.path.exists.return_value = True
         bookmark = BookMark()
         bookmark.url = 'https://google.com'
         bookmark.makeup()
         bookmark.img = 'test'
         self.assertEqual('/storage/test', bookmark.thumbnail)
Exemplo n.º 2
0
def add_ele():
    code = const.NO_CONTENT
    try:
        bookmark = BookMark(
            url=get_http_format_url(request.json.get('url', '')))

        tag_inputs = Tag.conv_tag_str_to_list(request.json.get('tags', ''))

        tags = [Tag.find_or_make(tag) for idx, tag in enumerate(tag_inputs)]
        bookmark.makeup()
        contract.register_bookmark_and_tag(current_user, bookmark, *tags)

    except InvalidURLException:
        code = const.SERVER_ERROR
    finally:

        return json.dumps({}), code, {'ContentType': 'application/json'}
Exemplo n.º 3
0
 def test_thumbnail_return_img_value_on_default(self):
     bookmark = BookMark()
     bookmark.url = 'https://google.com'
     bookmark.makeup()
     bookmark.img = 'test'
     self.assertEqual('test', bookmark.thumbnail)
Exemplo n.º 4
0
 def test_blank_page_thumbnail(self):
     bookmark = BookMark()
     bookmark.url = 'https://google.com'
     bookmark.makeup()
     bookmark.img = None
     self.assertEqual('/static/img/blank.png', bookmark.thumbnail)