Exemplo n.º 1
0
def test_no_data():
    """Test no data should return Failure."""
    test = [{}, ['keys']]
    t_result = fetch_data_by_keys(*test)
    assert not is_successful(t_result)
    assert 'keys' in str(t_result.failure())
Exemplo n.º 2
0
def test():
    """Test that we can fetch key in dict."""
    test = [{'key': 'val1'}, ['key']]
    assert fetch_data_by_keys(*test).unwrap() == 'val1'
Exemplo n.º 3
0
def test_no_path():
    """Test no path should return Failure."""
    test = [{'key': 'val'}, []]
    t_result = fetch_data_by_keys(*test)
    assert not is_successful(t_result)
    assert 'path list empty' in str(t_result.failure())
Exemplo n.º 4
0
def test_no_such_key():
    """Test Failure on missing key."""
    test = [{'key': 'val1'}, ['missing']]
    t_result = fetch_data_by_keys(*test)
    assert not is_successful(t_result)
    assert 'missing' in str(t_result.failure())
Exemplo n.º 5
0
def test_find_array():
    """Test that giving path to array is okay."""
    test = [{'key': ['val', 'val']}, ['key']]
    assert fetch_data_by_keys(*test) == Success(['val', 'val'])
Exemplo n.º 6
0
def test_find_dictionary():
    """Test that giving path to dict is okay."""
    test = [{'key': {'key1': 'val'}}, ['key']]
    assert fetch_data_by_keys(*test) == Success({'key1': 'val'})
Exemplo n.º 7
0
def test_two_keys():
    """Test that we are able to map with multiple keys."""
    test = [{'key1': {'key2': 'val1'}}, ['key1', 'key2']]
    assert fetch_data_by_keys(*test).unwrap() == 'val1'