Beispiel #1
0
def test_read(mock_ext):
    mock_ext.return_value = json.loads
    with tempfile.NamedTemporaryFile() as tmp:
        tmp.write('{"fizz": "buzz"}'.encode("utf-8"))
        tmp.flush()
        furimap = furi.map(tmp.name)
        returned = furimap._read()
        expected = {"fizz": "buzz"}
        assert_equal(returned, expected)
Beispiel #2
0
def config():
    """ Helper to get server config. """
    try:
        return dict(furi.map(OPT["--config"]))
    except AttributeError:
        return {}
Beispiel #3
0
def test_len(mock_read):
    mock_read.return_value = {"fizz": "buzz"}
    furimap = furi.map("/path/to/map.json")
    returned = len(furimap)
    expected = 1
    assert_equal(returned, expected)
Beispiel #4
0
def test_iter(mock_read):
    mock_read.return_value = {"fizz": "buzz"}
    furimap = furi.map("/path/to/map.json")
    returned = list(iter(furimap))
    expected = ["fizz"]
    assert_equal(returned, expected)
Beispiel #5
0
def test_getitem_bad(mock_read):
    mock_read.return_value = {"fizz": "buzz"}
    furimap = furi.map("/path/to/map.json")
    furimap["foo"]
Beispiel #6
0
def test_getitem(mock_read):
    mock_read.return_value = {"fizz": "buzz"}
    furimap = furi.map("/path/to/map.json")
    returned = furimap["fizz"]
    expected = "buzz"
    assert_equal(returned, expected)
Beispiel #7
0
def test_repr():
    furimap = furi.map("/path/to/file.json")
    returned = repr(furimap)
    expected = "<FileMap: /path/to/file.json>"
    assert_equal(returned, expected)