You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
1.1 KiB
28 lines
1.1 KiB
4 years ago
|
"""Module with tests for DataTypeFilter"""
|
||
|
|
||
|
# Copyright (c) IPython Development Team.
|
||
|
# Distributed under the terms of the Modified BSD License.
|
||
|
|
||
|
from ...tests.base import TestsBase
|
||
|
from ..datatypefilter import DataTypeFilter
|
||
|
|
||
|
|
||
|
class TestDataTypeFilter(TestsBase):
|
||
|
"""Contains test functions for datatypefilter.py"""
|
||
|
|
||
|
def test_constructor(self):
|
||
|
"""Can an instance of a DataTypeFilter be created?"""
|
||
|
DataTypeFilter()
|
||
|
|
||
|
def test_junk_types(self):
|
||
|
"""Can the DataTypeFilter pickout a useful type from a dict with junk types as keys?"""
|
||
|
filter = DataTypeFilter()
|
||
|
assert "image/png" in filter({"hair":"1", "water":2, "image/png":3, "rock":4.0})
|
||
|
assert "application/pdf" in filter({"application/pdf":"file_path", "hair":2, "water":"yay", "png":'not a png', "rock":'is a rock'})
|
||
|
self.assertEqual(filter({"hair":"this is not", "water":"going to return anything", "rock":"or is it"}), [])
|
||
|
|
||
|
def test_null(self):
|
||
|
"""Will the DataTypeFilter fail if no types are passed in?"""
|
||
|
filter = DataTypeFilter()
|
||
|
self.assertEqual(filter({}), [])
|