from test_imports import * class AccountTest(unittest.TestCase): def setUp(self): self.account = Account('Test Account', 'USD') def test_name_is_not_None(self): self.failUnlessRaises(Exception,Account,None,None) def test_name_is_not_blank(self): self.failUnlessRaises(Exception, Account, '', None) def test_account_has_parent(self): account_parent = Account('Parent Account', 'USD') self.account.parent = account_parent self.assert_(self.account.parent == account_parent) self.failUnlessRaises(Exception, self.account.set_parent, None) def test_account_has_parent_has_reverse(self): account_parent = Account('Parent Account','USD') self.account.parent = account_parent self.assert_(self.account in account_parent.children) def test_account_wont_accept_different_unit_parent(self): account_parent = Account('Parent Account','GB') self.failUnlessRaises(Exception, self.account.set_parent, account_parent) def test_account_doesnt_have_parent(self): self.assert_(self.account.parent == None) def test_construct_with_unit(self): for bad_unit in ['', None]: self.failUnlessRaises(Exception, Account, 'name', bad_unit) def test_empty_account_has_zero_balance(self): self.assertEquals(0, self.account.balance()) def test_empty_tree_has_zero_balance(self): self.assertEquals(0,self.account.tree_balance()) def test_units(self): self.assertEquals('USD', self.account.units) if __name__ == '__main__': unittest.main()