Exemplo n.º 1
0
class GeneralLedgerAccountUnitTester(unittest.TestCase):
    """
    Tester for the auxi.modelling.financial.des.GeneralLedgerAccount class.
    """

    def setUp(self):
        self.object = GeneralLedgerAccount("NameA",
                                           description="DescriptionA",
                                           number="010",
                                           account_type=AccountType.asset)

    def test_constructor(self):
        self.assertEqual(self.object.name, "NameA")
        self.assertEqual(self.object.description, "DescriptionA")
        self.assertEqual(self.object.number, "010")
        self.assertEqual(self.object.account_type, AccountType.asset)

    def test_set_parent_path(self):
        self.object.set_parent_path("accyA/accyB")
        self.assertEqual(self.object.path, "accyA/accyB/NameA")

    def test_create_account(self):
        new_account = self.object.create_account("TestA",
                                                 description="TestA_Desc",
                                                 number="011")
        self.assertEqual(new_account.name, "TestA")
        self.assertEqual(new_account.description, "TestA_Desc")
        self.assertEqual(new_account.number, "011")
        self.assertEqual(new_account.account_type, self.object.account_type)

        self.assertEqual(new_account, self.object.accounts[0])

    def test_remove_account(self):
        num_accounts = len(self.object.accounts)
        self.object.create_account("TestA",
                                   description="TestA_Desc",
                                   number="011")
        self.object.remove_account("TestA")
        self.assertEqual(len(self.object.accounts), num_accounts)

    def test_get_child_account(self):
        sub_acc = self.object.create_account(
            "TestA",
            description="TestA_Desc",
            number="011")
        sub_sub_acc = sub_acc.create_account(
            "TestA1",
            description="TestA1_Desc",
            number="012")
        result = self.object.get_child_account("TestA/TestA1")

        self.assertEqual(result.name, sub_sub_acc.name)
        self.assertEqual(result.description, sub_sub_acc.description)
        self.assertEqual(result.number, sub_sub_acc.number)
        self.assertEqual(result.account_type, sub_sub_acc.account_type)

        self.assertEqual(result, sub_sub_acc)
Exemplo n.º 2
0
class GeneralLedgerAccountUnitTester(unittest.TestCase):
    """
    Tester for the auxi.modelling.financial.des.GeneralLedgerAccount class.
    """
    def setUp(self):
        self.object = GeneralLedgerAccount("NameA",
                                           description="DescriptionA",
                                           number="010",
                                           account_type=AccountType.asset)

    def test_constructor(self):
        self.assertEqual(self.object.name, "NameA")
        self.assertEqual(self.object.description, "DescriptionA")
        self.assertEqual(self.object.number, "010")
        self.assertEqual(self.object.account_type, AccountType.asset)

    def test_set_parent_path(self):
        self.object.set_parent_path("accyA/accyB")
        self.assertEqual(self.object.path, "accyA/accyB/NameA")

    def test_create_account(self):
        new_account = self.object.create_account("TestA",
                                                 description="TestA_Desc",
                                                 number="011")
        self.assertEqual(new_account.name, "TestA")
        self.assertEqual(new_account.description, "TestA_Desc")
        self.assertEqual(new_account.number, "011")
        self.assertEqual(new_account.account_type, self.object.account_type)

        self.assertEqual(new_account, self.object.accounts[0])

    def test_remove_account(self):
        num_accounts = len(self.object.accounts)
        self.object.create_account("TestA",
                                   description="TestA_Desc",
                                   number="011")
        self.object.remove_account("TestA")
        self.assertEqual(len(self.object.accounts), num_accounts)

    def test_get_child_account(self):
        sub_acc = self.object.create_account("TestA",
                                             description="TestA_Desc",
                                             number="011")
        sub_sub_acc = sub_acc.create_account("TestA1",
                                             description="TestA1_Desc",
                                             number="012")
        result = self.object.get_child_account("TestA/TestA1")

        self.assertEqual(result.name, sub_sub_acc.name)
        self.assertEqual(result.description, sub_sub_acc.description)
        self.assertEqual(result.number, sub_sub_acc.number)
        self.assertEqual(result.account_type, sub_sub_acc.account_type)

        self.assertEqual(result, sub_sub_acc)