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

DataURIConverterTestCase   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 25
rs 10
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A data_dir() 0 3 1
A test_local_image() 0 4 1
A test_is_url() 0 6 1
A test_file_not_found() 0 4 2
A test_is_python_3() 0 3 1
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