robin.keunen
5 years ago
5 changed files with 129 additions and 71 deletions
-
3easy_my_coop/tests/__init__.py
-
16easy_my_coop/tests/test_base.py
-
70easy_my_coop/tests/test_coop.py
-
1easy_my_coop_loan/tests/__init__.py
-
110easy_my_coop_loan/tests/test_emc_loan.py
@ -1 +1,2 @@ |
|||
from . import test_coop |
|||
from . import test_base |
|||
from . import test_emc |
@ -0,0 +1,16 @@ |
|||
# Copyright 2019 Coop IT Easy SCRL fs |
|||
# Robin Keunen <robin@coopiteasy.be> |
|||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). |
|||
|
|||
import odoo.tests.common as common |
|||
|
|||
|
|||
class EMCBaseCase(common.TransactionCase): |
|||
def as_user(self): |
|||
self.uid = self.ref("base.user_demo") |
|||
|
|||
def as_emc_user(self): |
|||
self.uid = self.ref("easy_my_coop.res_users_user_emc_demo") |
|||
|
|||
def as_emc_manager(self): |
|||
self.uid = self.ref("easy_my_coop.res_users_manager_emc_demo") |
@ -1,70 +0,0 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2019 Coop IT Easy SCRL fs |
|||
# Robin Keunen <robin@coopiteasy.be> |
|||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). |
|||
|
|||
import odoo.tests.common as common |
|||
from odoo.fields import Date |
|||
|
|||
|
|||
class TestCoop(common.TransactionCase): |
|||
def setUp(self): |
|||
super(TestCoop, self).setUp() |
|||
|
|||
self.request = self.browse_ref( |
|||
"easy_my_coop.subscription_request_1_demo" |
|||
) |
|||
self.bank_journal_euro = self.env["account.journal"].create( |
|||
{"name": "Bank", "type": "bank", "code": "BNK67"} |
|||
) |
|||
self.payment_method_manual_in = self.env.ref( |
|||
"account.account_payment_method_manual_in" |
|||
) |
|||
|
|||
def test_put_on_waiting_list(self): |
|||
self.request.put_on_waiting_list() |
|||
self.assertEquals(self.request.state, "waiting") |
|||
|
|||
def test_validate_subscription_request(self): |
|||
self.request.validate_subscription_request() |
|||
|
|||
self.assertEquals(self.request.state, "done") |
|||
self.assertTrue(self.request.partner_id) |
|||
self.assertTrue(self.request.partner_id.coop_candidate) |
|||
self.assertFalse(self.request.partner_id.member) |
|||
self.assertEquals(self.request.type, "new") |
|||
self.assertTrue(len(self.request.capital_release_request) >= 1) |
|||
self.assertEquals(self.request.capital_release_request.state, "open") |
|||
self.assertTrue(self.request.capital_release_request.sent) |
|||
|
|||
def test_register_payment_for_capital_release(self): |
|||
self.request.validate_subscription_request() |
|||
invoice = self.request.capital_release_request |
|||
|
|||
ctx = {"active_model": "account.invoice", "active_ids": [invoice.id]} |
|||
register_payments = ( |
|||
self.env["account.register.payments"] |
|||
.with_context(ctx) |
|||
.create( |
|||
{ |
|||
"payment_date": Date.today(), |
|||
"journal_id": self.bank_journal_euro.id, |
|||
"payment_method_id": self.payment_method_manual_in.id, |
|||
} |
|||
) |
|||
) |
|||
register_payments.create_payments() |
|||
self.assertEquals(self.request.capital_release_request.state, "paid") |
|||
|
|||
partner = self.request.partner_id |
|||
self.assertFalse(partner.coop_candidate) |
|||
self.assertTrue(partner.member) |
|||
self.assertTrue(partner.share_ids) |
|||
self.assertEquals(self.request.partner_id.effective_date, Date.today()) |
|||
|
|||
share = partner.share_ids[0] |
|||
self.assertEquals(share.share_number, self.request.ordered_parts) |
|||
self.assertEquals( |
|||
share.share_product_id, self.request.share_product_id |
|||
) |
|||
self.assertEquals(share.effective_date, Date.today()) |
@ -0,0 +1 @@ |
|||
from . import test_emc_loan |
@ -0,0 +1,110 @@ |
|||
# Copyright 2019 Coop IT Easy SCRL fs |
|||
# Robin Keunen <robin@coopiteasy.be> |
|||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from odoo.addons.easy_my_coop.tests.test_base import EMCBaseCase |
|||
from odoo.fields import Date |
|||
from datetime import timedelta |
|||
from odoo.exceptions import AccessError |
|||
|
|||
|
|||
class EMCLoanCase(EMCBaseCase): |
|||
def test_complete_loan_flow(self): |
|||
|
|||
loan_issue_values = { |
|||
"name": "test loan issue", |
|||
"is_bond": False, |
|||
"is_loan": True, |
|||
"default_issue": "xx", |
|||
"subscription_start_date": Date.today(), |
|||
"subscription_end_date": Date.today() + timedelta(days=60), |
|||
"user_id": self.ref("easy_my_coop.res_users_manager_emc_demo"), |
|||
"term_date": Date.today() + timedelta(days=600), # ? |
|||
"rate": 0.03, |
|||
"face_value": 100, |
|||
"minimum_amount": 4000, |
|||
"maximum_amount": 10, # ? |
|||
"maximum_amount_per_sub": 1000, |
|||
"interest_payment": "yearly", |
|||
"by_company": True, |
|||
"by_individual": True, |
|||
"display_on_website": True, |
|||
"taxes_rate": 0.08, |
|||
} |
|||
|
|||
self.as_emc_manager() |
|||
loan_issue = self.env["loan.issue"].create(loan_issue_values) |
|||
loan_issue.action_confirm() |
|||
loan_issue.action_open() |
|||
loan_issue.action_cancel() |
|||
loan_issue.action_draft() |
|||
loan_issue.action_open() |
|||
|
|||
def test_emc_user_cannot_manager_loan_issue(self): |
|||
self.as_emc_user() |
|||
|
|||
loan_issue_values = { |
|||
"name": "test loan issue", |
|||
"is_bond": False, |
|||
"is_loan": True, |
|||
"default_issue": True, |
|||
"user_id": self.ref("easy_my_coop.res_users_manager_emc_demo"), |
|||
"subscription_start_date": Date.today(), |
|||
"subscription_end_date": Date.today() + timedelta(days=60), |
|||
"term_date": Date.today() + timedelta(days=600), # ? |
|||
"rate": 0.03, |
|||
"face_value": 100, |
|||
"minimum_amount": 2000, |
|||
"maximum_amount": 10000, # ? |
|||
"maximum_amount_per_sub": 1000, |
|||
"interest_payment": "yearly", |
|||
"by_company": True, |
|||
"by_individual": True, |
|||
"display_on_website": True, |
|||
"taxes_rate": 0.08, |
|||
} |
|||
|
|||
with self.assertRaises(AccessError): |
|||
self.env["loan.issue"].create(loan_issue_values) |
|||
|
|||
loan_issue = self.browse_ref("easy_my_coop_loan.loan_issue_1_demo") |
|||
|
|||
with self.assertRaises(AccessError): |
|||
loan_issue.name = "some name" |
|||
with self.assertRaises(AccessError): |
|||
loan_issue.action_confirm() |
|||
with self.assertRaises(AccessError): |
|||
loan_issue.action_open() |
|||
with self.assertRaises(AccessError): |
|||
loan_issue.action_cancel() |
|||
with self.assertRaises(AccessError): |
|||
loan_issue.action_draft() |
|||
with self.assertRaises(AccessError): |
|||
loan_issue.action_open() |
|||
|
|||
self.as_emc_manager() |
|||
loan_issue_manager = self.browse_ref( |
|||
"easy_my_coop_loan.loan_issue_1_demo" |
|||
) |
|||
loan_issue_manager.action_confirm() |
|||
loan_issue_manager.action_open() |
|||
|
|||
self.as_emc_user() |
|||
line = self.env["loan.issue.line"].create( |
|||
{ |
|||
"loan_issue_id": loan_issue.id, |
|||
"quantity": 3, |
|||
"partner_id": self.browse_ref( |
|||
"easy_my_coop.res_partner_cooperator_4_demo" |
|||
).id, |
|||
} |
|||
) |
|||
line.action_validate() |
|||
line.action_cancel() |
|||
line.action_draft() |
|||
line.action_validate() |
|||
line.action_request_payment() |
|||
line.action_paid() |
|||
|
|||
# loan_issue.compute_loan_interest() |
|||
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue