def testGetByAccount(self): account = self.create_account() methods = PaymentMethod.get_by_account(self.store, account) self.assertTrue(methods.is_empty()) PaymentMethod(store=self.store, method_name=u'test', destination_account=account) methods = PaymentMethod.get_by_account(self.store, account) self.assertFalse(methods.is_empty())
def test_get_by_account(self): account = self.create_account() methods = PaymentMethod.get_by_account(self.store, account) self.assertTrue(methods.is_empty()) PaymentMethod(store=self.store, method_name=u'test', destination_account=account) methods = PaymentMethod.get_by_account(self.store, account) self.assertFalse(methods.is_empty())
def _delete_account(self, account_view): store = api.new_store() account = store.fetch(account_view.account) methods = PaymentMethod.get_by_account(store, account) if methods.count() > 0: if not yesno( _('This account is used in at least one payment method.\n' 'To be able to delete it the payment methods needs to be' 're-configured first'), gtk.RESPONSE_NO, _("Configure payment methods"), _("Keep account")): store.close() return elif not yesno( _('Are you sure you want to remove account "%s" ?') % ( (account_view.description, )), gtk.RESPONSE_NO, _("Remove account"), _("Keep account")): store.close() return if account_view.id in self._pages: account_page = self._pages[account_view.id] self._close_page(account_page) self.accounts.remove(account_view) self.accounts.flush() imbalance = api.sysparam(store).IMBALANCE_ACCOUNT for method in methods: method.destination_account = imbalance account.remove(store) store.commit(close=True)