def test_it_throws_an_exception_if_a_random_string_is_passed_in_for_account_type( self): params = { "name": "account name", "owner": "Bob Bobberson", "investment": "investment", "asset_class": AssetClass.CASH_EQUIVALENTS, "institution": "Rachel's Bank", "account_type": "RANDOM" } invalid_account = Account(params) self.assertRaises(AttributeError, invalid_account.account_type)
def setUp(self): self.asset_params = { "name": "account name", "owner": "Bob Bobberson", "investment": "investment", "asset_class": AssetClass.CASH_EQUIVALENTS, "institution": "Rachel's Bank", "account_type": AccountType.ASSET, "open_date": "2001-12-12", "update_frequency": 12, "term": Term.SHORT, "uuid": "12345" } self.asset = Account(self.asset_params) self.liability_params = { "name": "account name", "owner": "Bob Bobberson", "investment": "investment", "asset_class": AssetClass.CASH_EQUIVALENTS, "institution": "Rachel's Bank", "account_type": AccountType.ASSET } self.liability = Account(self.liability_params)
def build(self) -> Account: if self.__params.get("name") is None: raise InvalidAccountException( "The name of the account must be set.") elif self.__params.get("owner") is None: raise InvalidAccountException("The name of the owner must be set.") elif self.__params.get("investment") is None: raise InvalidAccountException( "The name of the investment must be set.") elif self.__params.get("institution") is None: raise InvalidAccountException( "The name of the institution must be set.") else: return Account(self.__params)
def test_an_account_is_not_identical_to_one_with_a_different_open_date( self): self.asset_params["open_date"] = "another open date" different_account = Account(self.asset_params) self.assertFalse(self.asset.is_identical_to(different_account))
def test_an_account_is_identical_to_one_with_a_different_update_frequency( self): self.asset_params["update_frequency"] = 1000000 different_account = Account(self.asset_params) self.assertTrue(self.asset.is_identical_to(different_account))
def test_an_account_is_not_identical_to_one_with_a_different_account_type( self): self.asset_params["account_type"] = AccountType.LIABILITY different_account = Account(self.asset_params) self.assertFalse(self.asset.is_identical_to(different_account))
def test_an_account_is_not_identical_to_one_with_a_different_institution( self): self.asset_params["institution"] = "another institution" different_account = Account(self.asset_params) self.assertFalse(self.asset.is_identical_to(different_account))
def test_an_account_is_not_identical_to_one_with_a_different_asset_class( self): self.asset_params["asset_class"] = AssetClass.EQUITIES different_account = Account(self.asset_params) self.assertFalse(self.asset.is_identical_to(different_account))
def test_it_sets_an_account_as_a_liability_by_passing_in_the_account_type(self): account = self.builder.set_account_type(AccountType.LIABILITY).build() params = {"name": "name", "owner": "owner", "investment": "investment", "asset_class": AssetClass.NONE, "institution": "institution", "account_type": AccountType.LIABILITY} self.assertTrue(account.is_identical_to(Account(params)))
def test_it_creates_a_unique_uuid(self): account_one = Account(self.liability_params) account_two = Account(self.liability_params) self.assertNotEqual(account_one.uuid(), account_two.uuid())
def test_it_sets_the_term(self): account = self.builder.set_term(Term.MEDIUM).build() params = {"name": "name", "owner": "owner", "investment": "investment", "asset_class": AssetClass.CASH_EQUIVALENTS, "institution": "institution", "account_type": AccountType.ASSET, "term": Term.MEDIUM} self.assertTrue(account.is_identical_to(Account(params)))
def test_it_sets_the_open_date(self): account = self.builder.set_open_date("2005-1-1").build() params = {"name": "name", "owner": "owner", "investment": "investment", "asset_class": AssetClass.CASH_EQUIVALENTS, "institution": "institution", "account_type": AccountType.ASSET, "open_date": "2005-1-1"} self.assertTrue(account.is_identical_to(Account(params)))
def test_it_sets_the_update_frequency_of_an_account(self): account = self.builder.set_update_frequency(12).build() params = {"name": "name", "owner": "owner", "investment": "investment", "asset_class": AssetClass.CASH_EQUIVALENTS, "institution": "institution", "account_type": AccountType.ASSET} self.assertTrue(account.is_identical_to(Account(params)))
def test_it_sets_the_asset_class_of_an_account(self): account = self.builder.set_asset_class(AssetClass.ANNUITIES).build() params = {"name": "name", "owner": "owner", "investment": "investment", "asset_class": AssetClass.ANNUITIES, "institution": "institution", "account_type": AccountType.ASSET} self.assertTrue(account.is_identical_to(Account(params)))
def test_it_sets_an_account_as_an_asset(self): account = self.builder.set_liability().set_asset().build() params = {"name": "name", "owner": "owner", "investment": "investment", "asset_class": AssetClass.NONE, "institution": "institution", "account_type": AccountType.ASSET} self.assertTrue(account.is_identical_to(Account(params)))
def test_an_account_is_not_identical_to_one_with_a_different_term(self): self.asset_params["term"] = Term.MEDIUM different_account = Account(self.asset_params) self.assertFalse(self.asset.is_identical_to(different_account))
def test_it_can_have_a_term_of_long(self): self.asset_params["term"] = Term.LONG asset = Account(self.asset_params) self.assertEqual(asset.term(), Term.LONG.value)
def test_it_throws_an_exception_if_a_string_is_passed_in_for_an_account_type( self): self.asset_params["account_type"] = "RANDOM" invalid_account = Account(self.asset_params) self.assertRaises(AttributeError, invalid_account.account_type)
def test_it_can_have_a_term_of_medium(self): self.asset_params["term"] = Term.MEDIUM asset = Account(self.asset_params) self.assertEqual(asset.term(), Term.MEDIUM.value)
def test_it_builds_an_account_with_defaults(self): account = self.builder.build() params = {"name": "name", "owner": "owner", "investment": "investment", "asset_class": AssetClass.CASH_EQUIVALENTS, "institution": "institution", "account_type": AccountType.ASSET} self.assertTrue(account.is_identical_to(Account(params)))