Mock a DB query:I am trying to mock a db query and assert that save is called but it is failing with assertion. can someone please help?
models.py
import peewee
class A():
human = CharField()
Age = CharField()
app.py
def get_A():
return models.select().where(models.A.Age="5")
def update_A():
age = get_A()
for i in age:
i.Age = 10
i.save()
test.py
def build_mock_A():
a = A()
a.human = "hath"
a.Age. = 5
return a
@patch('app.get_A')
def test_A(self,mock_get_A):
mock_get_A.return_value = build_mock_A()
app.update_A()
mock_get_A.save.assert_called_once()
Error:
raise AssertionError(msg)
AssertionError: Expected 'save' to have been called once. Called 0 times.