alchemy-mock
alchemy-mock copied to clipboard
SQLAlchemy mock helpers.
This is to fix this issue https://github.com/miki725/alchemy-mock/issues/35
Importing ABC directly from collections will be removed in Python 3.10 . Use collections.abc for Python 3 and collections for Python 2. ``` alchemy_mock/comparison.py 150: elif isinstance(self.expr, collections.Mapping): ```
Selecting single columns does not work for me. eg. the following is not working ``` db = UnifiedAlchemyMagicMock() db.session.query(MyTable.col).all() ```
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...
I have been unable to figure out the usefulness of this module. Admittedly, I am not very experienced with sqlalchemy, but the examples in the readme - while helpful -...
Hay, I found a bug. The filter_by does not affect the output of the query. It is no issue if not using the mock. https://github.com/sqlalchemy/sqlalchemy/issues/6873 ``` python from sqlalchemy.orm import...
The mocked `get()` function only accepts tuples, but [the real version of the function](https://docs.sqlalchemy.org/en/13/orm/query.html#sqlalchemy.orm.query.Query.get.params.ident) can take in dictionaries, and more importantly scalar values. I had to change the code to...
# New Fork called `mock-alchemy` Since this library appears to no longer be supported, I created a fork of this project with the improvements that I suggested in PR #39....
I was using this library for some simple SqlAlchemy testing and found the lack of a basic delete somewhat preventative in mocking up queries and session commands. So I decided...
from sqlalchemy import Column, Integer, String, Text, DateTime, Float, Boolean, PickleType from sqlalchemy.ext.declarative import declarative_base from alchemy_mock.mocking import UnifiedAlchemyMagicMock Base = declarative_base() class Post(Base): __tablename__ = 'posts' id = Column(Integer,...