Closed efratmiy closed 2 months ago
Hi @efratmiy - you can initialize and access a JsonModel
without a Redis instance, if however you wanted to stub out the Redis bits you would need to explicitly add a Redis
Mock to the Meta
class within your model:
from redis_om import JsonModel
redis = # create your mock Redis connection bit here
class Customer(HashModel):
first_name: str
last_name: str
age: int
class Meta:
database = redis
If it's me, IDK that that's the level I would be mocking at (I would go a level up and mock the service layer that's meant to be doing the simple CRUD operations to Redis. But that route is open to you
I have a similar problem as this at : https://stackoverflow.com/questions/76578825/how-to-test-a-jsonmodel-in-a-unittest
How does one test a simple JsonModel without connection to a redis instance?