def test_unreconciled(self):
Transaction()
m_db = Mock()
m_q = Mock(spec_set=Query)
m_filt = Mock(spec_set=Query)
m_db.query.return_value = m_q
m_q.filter.return_value = m_filt
res = Transaction.unreconciled(m_db)
assert res == m_filt
assert len(m_db.mock_calls) == 2
assert m_db.mock_calls[0] == call.query(Transaction)
kall = m_db.mock_calls[1]
assert kall[0] == 'query().filter'
expected1 = Transaction.reconcile.__eq__(null())
expected2 = Transaction.date.__ge__(date(2017, 3, 17))
expected3 = Transaction.account.has(reconcile_trans=True)
assert len(kall[1]) == 3
assert str(expected1) == str(kall[1][0])
assert binexp_to_dict(expected2) == binexp_to_dict(kall[1][1])
assert str(expected3) == str(kall[1][2])
评论列表
文章目录