# Path: crosscompute/exceptions.py
# class CrossComputeError(Exception):
# class CrossComputeConfigurationError(CrossComputeError):
# class CrossComputeConfigurationNotFoundError(CrossComputeConfigurationError):
# class CrossComputeConfigurationFormatError(CrossComputeError):
# class CrossComputeDataError(CrossComputeError):
# class CrossComputeExecutionError(CrossComputeError):
#     def __str__(self):


from crosscompute.exceptions import DataTypeError
from crosscompute.types import DataType
from pytest import raises


class CDataType(DataType):

    @classmethod
    def load_for_view(Class, path):
        instance = Class()
        instance.path = path
        return instance


class TestDataType(object):

    def test_load_for_view_safely(self):
        x = ADataType.load_for_view_safely('a')
        assert x.path == 'a'

        x = ADataType.load_for_view_safely('x')
        assert x is None

        x = BDataType.load_for_view_safely('b', 'bb')
        assert x.path == 'b'
        assert x.default_value == 'bb'

        x = CDataType.load_for_view_safely('c')
        assert x.path == 'c'

    def test_parse_safely(self):
        assert ADataType.parse_safely(None) is None
        assert ADataType.parse_safely(1) is 'a'

# Path: crosscompute/exceptions.py
# class CrossComputeError(Exception):
# class CrossComputeConfigurationError(CrossComputeError):
# class CrossComputeConfigurationNotFoundError(CrossComputeConfigurationError):
# class CrossComputeConfigurationFormatError(CrossComputeError):
# class CrossComputeDataError(CrossComputeError):
# class CrossComputeExecutionError(CrossComputeError):
#     def __str__(self):


# Path: experiments/0.7/tests/x_types.py
from crosscompute.exceptions import DataTypeError
from crosscompute.types import DataType
from pytest import raises



class CDataType(DataType):

    @classmethod
    def load_for_view(Class, path):
        instance = Class()
        instance.path = path
        return instance


class TestDataType(object):

    def test_load_for_view_safely(self):
        x = ADataType.load_for_view_safely('a')
        assert x.path == 'a'

        x = ADataType.load_for_view_safely('x')
        assert x is None

        x = BDataType.load_for_view_safely('b', 'bb')
        assert x.path == 'b'
        assert x.default_value == 'bb'

        x = CDataType.load_for_view_safely('c')
        assert x.path == 'c'

    def test_parse_safely(self):
        assert ADataType.parse_safely(None) is None
        assert ADataType.parse_safely(1) is 'a'

        with raises(DataTypeError):