Completed
Push — develop ( d5f38a...7fff52 )
by
unknown
14s
created

DataURIConverterTestCase.test_remote_image()   A

Complexity

Conditions 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
import unittest
2
from os.path import join, dirname
3
from binstar_client.utils.notebook.data_uri import DataURIConverter
4
5
6
class DataURIConverterTestCase(unittest.TestCase):
7
    def data_dir(self, filename):
8
        test_data = join(dirname(__file__), 'data')
9
        return join(test_data, filename)
10
11
    def test_local_image(self):
12
        location = self.data_dir('bokeh-logo.png')
13
        output = DataURIConverter(location)()
14
        self.assertEqual(output[0:5], "iVBOR")
15
16
    def test_file_not_found(self):
17
        location = self.data_dir('no-exists.png')
18
        with self.assertRaises(IOError):
19
            DataURIConverter(location)()
20
21
    def test_is_python_3(self):
22
        output = DataURIConverter('')
23
        self.assertIsInstance(output.is_py3(), bool)
24
25
    def test_is_url(self):
26
        location = 'http://docs.continuum.io/_static/img/continuum_analytics_logo.png'
27
        self.assertTrue(DataURIConverter(location).is_url())
28
29
        location = self.data_dir('bokeh-logo.png')
30
        self.assertNotEqual(DataURIConverter(location).is_url(), True)
31