Skip to content

Unit Tests tutorial #810

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 53 commits into
base: 18.0
Choose a base branch
from
Open

Conversation

arthurrrm
Copy link

No description provided.

arthurrrm added 23 commits May 23, 2025 14:25
@robodoo
Copy link

robodoo commented Jun 4, 2025

Pull request status dashboard

Copy link

@vava-odoo vava-odoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very good :-)

Comment on lines +27 to +33
<function model="estate.property.offer" name="action_refuse">
<value eval="[ref('estate.property_offer_1')]"/>
</function>

<function model="estate.property.offer" name="action_refuse">
<value eval="[ref('estate.property_offer_3')]"/>
</function>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

action_refuse works with a recordset

Suggested change
<function model="estate.property.offer" name="action_refuse">
<value eval="[ref('estate.property_offer_1')]"/>
</function>
<function model="estate.property.offer" name="action_refuse">
<value eval="[ref('estate.property_offer_3')]"/>
</function>
<function model="estate.property.offer" name="action_refuse">
<value eval="[ref('estate.property_offer_1'), ref('estate.property_offer_3')]"/>
</function>

Comment on lines +1 to +4
from odoo.tests.common import TransactionCase
from odoo.exceptions import UserError
from odoo.tests import tagged
from odoo.tests import Form

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to follow the guidelines

Suggested change
from odoo.tests.common import TransactionCase
from odoo.exceptions import UserError
from odoo.tests import tagged
from odoo.tests import Form
from odoo.exceptions import UserError
from odoo.tests import tagged, Form
from odoo.tests.common import TransactionCase

{
'name': 'Property 1',
'expected_price': 100000,
'state': 'offer_accepted',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be set after selling the property (so by the action just below)

Suggested change
'state': 'offer_accepted',

],
},
])
cls.properties[0].offer_ids[0].action_accept()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe easier to declare the offer beforehand (but ok).
Also, you only have one property inside properties recordset (same for offers), so this should work

Suggested change
cls.properties[0].offer_ids[0].action_accept()
cls.properties.offer_ids.action_accept()


def test_sell_property(self):
"""Test that selling a property that can be sold updates the right fields."""
self.properties[0].set_sold()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the action_accept call on the offer be sufficient?

Suggested change
self.properties[0].set_sold()

},
])

cls.properties[1].offer_ids[0].action_refuse()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't seem to be useful, is it?

Suggested change
cls.properties[1].offer_ids[0].action_refuse()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants