示例#1
0
def test_load_config__value_error_handled():
    with mock.patch('imhotep.main.open', create=True) as mock_open:
        mock_open.return_value = mock.MagicMock(spec=io.IOBase)

        file_handle = mock_open.return_value.__enter__.return_value
        file_handle.read.side_effect = ValueError()

        cfg = load_config('filename')

        assert {} == cfg
示例#2
0
def test_load_config__returns_json_content():
    with mock.patch('imhotep.main.open', create=True) as mock_open:
        mock_open.return_value = mock.MagicMock(spec=io.IOBase)

        file_handle = mock_open.return_value.__enter__.return_value
        file_handle.read.return_value = '{"valid": "json"}'

        cfg = load_config('filename')

        assert {'valid': 'json'} == cfg
示例#3
0
def test_load_config__value_error_handled():
    with mock.patch('imhotep.main.open', create=True) as mock_open:
        mock_open.return_value = mock.MagicMock(spec=io.IOBase)

        file_handle = mock_open.return_value.__enter__.return_value
        file_handle.read.side_effect = ValueError()

        cfg = load_config('filename')

        assert {} == cfg
示例#4
0
def test_load_config__returns_json_content():
    with mock.patch('imhotep.main.open', create=True) as mock_open:
        mock_open.return_value = mock.MagicMock(spec=io.IOBase)

        file_handle = mock_open.return_value.__enter__.return_value
        file_handle.read.return_value = '{"valid": "json"}'

        cfg = load_config('filename')

        assert {'valid': 'json'} == cfg
示例#5
0
def test_config_loading():
    c = load_config('doesnt_exist')
    assert isinstance(c, dict)
示例#6
0
def test_config_loading():
    c = load_config('doesnt_exist')
    assert isinstance(c, dict)