jeancochrane / jeancochrane/pytest-flask-sqlalchemy

Pre-populating the database

Open
#21 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
253
Forks
45
PR merge metrics
No merged PRs in 30d

Description

Dear Ms. Cochrane,

I am trying to use your package with Sandman 2 and I was wondering if you were aware of any examples that use both packages ? I was wondering if there were any examples using the `client` fixture from `pytest-flask` and `db_session` or `db_engine` from your package.

Extending the example from the documentation I am pre-populate an empty database as below :

@pytest.fixture()
def session(db_session):
db_session.add(Table(id=0, name="test"))
db_session.commit() # This triggers an error
return db_session

def test_FUNCTION(client, session):
client.post(/some/path/, data={"name":"testing"})
record = session.query(Table).get(1)
assert record.name == "testing"

I find that either the rollback mechanism is failing with the `pymssql` driver at the line with the commit.

Table 'table' does not have the identity property. Cannot perform SET operation.DB-Lib error message 20018, severity 16:\nGeneral SQL Server error: Check messages from the SQL Server\n

I was hoping you may have come across this before and might be able to provide me with the odd pointer, the full code is available through a [testing](https://github.com/manaikan/pytest-flask-sqlalchemy/tree/testing) branch; explained in issue #22.

Regards,

Carel van Dam

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.