예제 #1
0
def test_loading_a_image_from_pathlib():
    """Tests the loading of a image from a pathlib"""
    filepath = Path(__file__).parent.parent / "test_data" / "logo.png"

    image_pane = PNG(filepath)
    image_data = image_pane._data()
    assert b'PNG' in image_data
예제 #2
0
def test_loading_a_image_from_url():
    """Tests the loading of a image from a url"""
    url = 'https://file-examples-com.github.io/uploads/2017/10/file_example_PNG_500kB.png'

    image_pane = PNG(url)
    image_data = image_pane._data()
    assert b'PNG' in image_data
예제 #3
0
def test_loading_a_image_from_url():
    """Tests the loading of a image from a url"""
    url = 'https://raw.githubusercontent.com/holoviz/panel/master/doc/_static/logo.png'

    image_pane = PNG(url)
    image_data = image_pane._data()
    assert b'PNG' in image_data
예제 #4
0
def test_image_link_url(document, comm):
    """Tests the loading of a image from a url"""
    url = 'https://file-examples-com.github.io/uploads/2017/10/file_example_PNG_500kB.png'

    image_pane = PNG(url, embed=False, link_url="http://anaconda.org")
    model = image_pane.get_root(document, comm)

    assert model.text.startswith('<a href="http://anaconda.org"')
예제 #5
0
def test_image_alt_text(document, comm):
    """Tests the loading of a image from a url"""
    url = 'https://file-examples-com.github.io/uploads/2017/10/file_example_PNG_500kB.png'

    image_pane = PNG(url, embed=False, alt_text="Some alt text")
    model = image_pane.get_root(document, comm)

    assert 'alt="Some alt text"' in model.text
예제 #6
0
def test_image_link_url(document, comm):
    """Tests the loading of a image from a url"""
    url = 'https://raw.githubusercontent.com/holoviz/panel/master/doc/_static/logo.png'

    image_pane = PNG(url, embed=False, link_url="http://anaconda.org")
    model = image_pane.get_root(document, comm)

    assert model.text.startswith('<a href="http://anaconda.org"')
예제 #7
0
def test_image_alt_text(document, comm):
    """Tests the loading of a image from a url"""
    url = 'https://raw.githubusercontent.com/holoviz/panel/master/doc/_static/logo.png'

    image_pane = PNG(url, embed=False, alt_text="Some alt text")
    model = image_pane.get_root(document, comm)

    assert 'alt="Some alt text"' in model.text
예제 #8
0
def test_loading_a_image_from_url():
    """Tests the loading of a image from a url"""
    url = 'https://upload.wikimedia.org/wikipedia/commons/7/71/' \
          '1700_CE_world_map.PNG'

    image_pane = PNG(url)
    image_data = image_pane._img()
    assert b'PNG' in image_data
예제 #9
0
def test_image_from_bytes():
    path = os.path.dirname(__file__)
    with open(os.path.join(path, '../test_data/logo.png'), 'rb') as f:
        img = f.read()

    image_pane = PNG(img)
    image_data = image_pane._data()
    assert b'PNG' in image_data
예제 #10
0
def test_load_from_stringio():
    """Testing a loading a image from a StringIO"""
    memory = StringIO()
    with open('panel/tests/test_data/logo.png', 'rb') as image_file:
        memory.write(str(image_file.read()))
    memory.seek(0)
    image_pane = PNG(memory)
    image_data = image_pane._img()
    assert 'PNG' in image_data
예제 #11
0
def test_load_from_byteio():
    """Testing a loading a image from a ByteIo"""
    memory = BytesIO()
    with open('panel/tests/test_data/logo.png', 'rb') as image_file:
        memory.write(image_file.read())
    memory.seek(0)
    image_pane = PNG(memory)
    image_data = image_pane._img()
    assert b'PNG' in image_data
예제 #12
0
def test_image_link_url(document, comm):
    """Tests the loading of a image from a url"""
    url = 'https://upload.wikimedia.org/wikipedia/commons/7/71/' \
          '1700_CE_world_map.PNG'

    image_pane = PNG(url, embed=False, link_url="http://anaconda.org")
    model = image_pane.get_root(document, comm)

    assert model.text.startswith('<a href="http://anaconda.org"')
예제 #13
0
def test_image_alt_text(document, comm):
    """Tests the loading of a image from a url"""
    url = 'https://upload.wikimedia.org/wikipedia/commons/7/71/' \
          '1700_CE_world_map.PNG'

    image_pane = PNG(url, embed=False, alt_text="Some alt text")
    model = image_pane.get_root(document, comm)

    assert 'alt="Some alt text"' in model.text
예제 #14
0
def test_load_from_stringio():
    """Testing a loading a image from a StringIO"""
    memory = StringIO()

    path = os.path.dirname(__file__)
    with open(os.path.join(path, '../test_data/logo.png'), 'rb') as image_file:
        memory.write(str(image_file.read()))

    image_pane = PNG(memory)
    image_data = image_pane._data()
    assert 'PNG' in image_data
예제 #15
0
def test_load_from_byteio():
    """Testing a loading a image from a ByteIo"""
    memory = BytesIO()

    path = os.path.dirname(__file__)
    with open(os.path.join(path, '../test_data/logo.png'), 'rb') as image_file:
        memory.write(image_file.read())

    image_pane = PNG(memory)
    image_data = image_pane._img()
    assert b'PNG' in image_data