def test_what_choice(db): plan = AccountsPlan() acc1 = plan.add_account() acc2 = plan.add_account() t = plan.create_transaction(acc1, acc2, 200.0) t.what = u'за хлеб' t.save() t = plan.create_transaction(acc1, acc2, 300.0) t.what = u'за воду' t.save() result = bank.get_what_choice() assert result == [u'за воду', u'за хлеб'] t = plan.create_transaction(acc1, acc2, 300.0) t.what = u'за воду' t.save() result = bank.get_what_choice() assert result == [u'за воду', u'за хлеб']
def get_what_choice(): if cached_choices[1] is None: cached_choices[1] = bank.get_what_choice() return cached_choices[1]