def test_database_get_by_id(tmpdir): file = tmpdir.join("test.db.json") file.write(EMPTY_FIXTURE_STR) db = Database().on(file.strpath) data = {"name": "test"} xactId = db.add(data) found = db.getById(xactId) assert len(found) == len(data) assert set(found.keys()) == set(data.keys()) for k in data.keys: assert data[k] == found[k] with pytest.raises(IdNotFoundError): db.getById(xactId + 1)
def test_database_add_invalid_schema_exception(tmpdir): file = tmpdir.join("test.db.json") file.write(UUID_FIXTURE_STR) db = Database().on(file.strpath) with pytest.raises(SchemaError): db.add({"namme": "sd"})
def test_database_add(tmpdir): file = tmpdir.join("test.db.json") file.write(EMPTY_FIXTURE_STR) db = Database().on(file.strpath) x = db.add({"name": "test"}) assert uuid.UUID(x)
def test_database_add(tmpdir): file = tmpdir.join("test.db.yaml") file.write(EMPTY_FIXTURE_STR) db = Database().on(file.strpath, uuid=False) x = db.add({"name": "test"}) assert int(x)