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)
def config(): """ Helper to get server config. """ try: return dict(furi.map(OPT["--config"])) except AttributeError: return {}
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)
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)
def test_getitem_bad(mock_read): mock_read.return_value = {"fizz": "buzz"} furimap = furi.map("/path/to/map.json") furimap["foo"]
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)
def test_repr(): furimap = furi.map("/path/to/file.json") returned = repr(furimap) expected = "<FileMap: /path/to/file.json>" assert_equal(returned, expected)