-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
base: 18.0
Are you sure you want to change the base?
Unit Tests tutorial #810
Conversation
…ance offer validation logic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very good :-)
<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> |
There was a problem hiding this comment.
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
<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> |
from odoo.tests.common import TransactionCase | ||
from odoo.exceptions import UserError | ||
from odoo.tests import tagged | ||
from odoo.tests import Form |
There was a problem hiding this comment.
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
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', |
There was a problem hiding this comment.
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)
'state': 'offer_accepted', |
], | ||
}, | ||
]) | ||
cls.properties[0].offer_ids[0].action_accept() |
There was a problem hiding this comment.
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
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() |
There was a problem hiding this comment.
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?
self.properties[0].set_sold() |
}, | ||
]) | ||
|
||
cls.properties[1].offer_ids[0].action_refuse() |
There was a problem hiding this comment.
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?
cls.properties[1].offer_ids[0].action_refuse() |
No description provided.