Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can mock-alchemy or alchemy-mock be used to mock session.execute(selectObject).where(...).scalars.fetchAll? #42

Open
RobertHana opened this issue Oct 12, 2021 · 1 comment

Comments

@RobertHana
Copy link

https://stackoverflow.com/q/69546839/6429049?sem=2

Can mock-alchemy or alchemy-mock be used to mock the following:

def fetch() -> List[MyEntity]:
  selectObject = sqlalchemy.select(MyEntity)
  with sqlalchemy.orm.Session(engine) as session:
    results = session.execute(selectObject)
    instances = results.scalars().fetchall()
    return instances
@kentbull
Copy link

I have a similar question minus the scalars() part. The fetchall() call is recognized by the mock yet it doesn't return the data I specify when using a UnifiedAlchemyMagicMock

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants