def test_merging_personal_accounts(self): create_account('second personal account') self.modeladmin.merge_accounts(request, Account.objects.personal()) self.assertEquals(Account.objects.personal().count(), 2) self.assertEquals(len(self.modeladmin.messages), 2) self.assertIn('You can only merge foreign accounts, "personal" isn\'t.', self.modeladmin.messages) self.assertIn('You can only merge foreign accounts, "second personal account" isn\'t.', self.modeladmin.messages)
def setUp(self): self.first = create_account(name='first', account_type=Account.FOREIGN) self.second = create_account(name='second', account_type=Account.FOREIGN) self.third = create_account(name='third', account_type=Account.FOREIGN) self.personal = create_account(name='personal') create_transaction('first', self.personal, self.first, 50, Transaction.WITHDRAW) create_transaction('second', self.personal, self.second, 100, Transaction.WITHDRAW) create_transaction('second', self.personal, self.third, 25, Transaction.WITHDRAW) self.site = AdminSite() self.modeladmin = MockedAdmin(Account, self.site)