def test_no_error_json_storage(thing): storage = JSONStorage('./noerrors.json') storage.write(thing) assert thing == storage.read() storage.close()
def test_json(tmpdir): # Write contents path = str(tmpdir.join('test.db')) storage = JSONStorage(path) storage.write(doc) # Verify contents assert doc == storage.read() storage.close()
def test_create_dirs(): temp_dir = tempfile.gettempdir() db_dir = '' db_file = '' while True: dname = os.path.join(temp_dir, str(random.getrandbits(20))) if not os.path.exists(dname): db_dir = dname db_file = os.path.join(db_dir, 'db.json') break db_conn = JSONStorage(db_file, create_dirs=True) db_conn.close() db_exists = os.path.exists(db_file) os.remove(db_file) os.rmdir(db_dir) assert db_exists