def test_rewrite_json(db_file, db_content): """Check successive write to JSON file""" write_json(db_file, db_content) write_json(db_file, db_content) assert read_json(db_file) == db_content
def test_insert(json_dao): """Check insert in database""" key = "data" data = {"test": "test"} json_dao.insert(key, data) assert read_json(json_dao.db_file) == {key: data}
def test_write_json_missing_file(tmp_path, db_content): """Check write to non existing JSON file""" db_file = tmp_path / "db.json" write_json(db_file, db_content) assert read_json(db_file) == db_content
def test_write_json(db_file, db_content): """Check write to JSON file""" write_json(db_file, db_content) assert read_json(db_file) == db_content
def test_read_json_missing_file(): """Check read from non existing JSON file""" assert read_json(Path("missing_file")) == {}
def test_read_json_empty(db_file): """Check read from empty JSON file""" assert read_json(db_file) == {}
def test_read_json(db_file, db_content): """Check read from JSON file""" json.dump(db_content, open(str(db_file), "w")) assert read_json(db_file) == db_content