-
-
Notifications
You must be signed in to change notification settings - Fork 664
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
[MIG][11.0]hr_employee_age:Migration to 11.0. #458
[MIG][11.0]hr_employee_age:Migration to 11.0. #458
Conversation
4c1496a
to
4e2ccee
Compare
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.
Some minors adjustment, LGTM over all.
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.
Add Unit test case too
Good to add unit tests |
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.
LGTM
Can you please squash a bit commit history and fix that merge commit (rebasing you will get this fixed)? |
972da5d
to
0628197
Compare
@pedrobaeza Squshed, Ready to merge |
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.
Please, tests should also verify the correctness of the result.
}) | ||
|
||
def test_compute_age(self): | ||
self.emp_root._compute_age() |
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 test only checks that the code runs correctly. It doesn't do any check about it providing the correct result.
Please, add some simple assertion on self.emp_root.age
field.
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.
@espo-tony here an only call _compute_age method, and one more thing we pass birthday
field.
Ex. Today age is 28 but next year 29 that time assertion is False so we directly use this method
here we use manually assertEqual(self.emp_root.age, 28)
but it's wrong to logically.
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.
@nikul-serpentcs Of course the assert needs to be dinamic: 28 shouldn't be hardcoded but computed within the test.
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.
@espo-tony compute nothing to return, we have only one variable like self.emp_root.age
then how to assert. and how to check another one.if you have any idea about that.
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.
Something like:
age = relativedelta(
fields.Date.from_string(fields.Date.today()),
fields.Date.from_string(self.emp_root.birthday)).years
assertEqual(self.emp_root.age, age)
Otherwise you can do something like this:
self.emp_root.birthday = fields.Date.from_string(
fields.Date.today() - relativedelta(years=28))
self.emp_root._compute_age()
assertEqual(self.emp_root.age, 28)
Or I guess you can find another couple of ways to achieve the same goal. The point is that the test as it's written is not proving the code is functionally correct because it doesn't do any assertion on its result.
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.
@espo-tony Ok, In UT one more time Calculate age and after check assertion.
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.
On the assert equal we are comparing two variables that are computed using the same instruction so the will obviously be equal. I know it is a simple function and probably works fine, but I think it would be better to use the second option proposed by @espo-tony or even using mock to control what fields.Date.today() returns and compare the age against what we expect.
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.
@jarroyomorales nope, not ready ^
I realised lately yes, we need asserts! |
a67ef81
to
c6f2de8
Compare
@espo-tony Fixed Code, please add review |
I'm rebuilding runbot for testing. In any case i saw travis is 🔴 so it's passing again the see what happens Thanks!!!! |
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.
Functional test 👍
Please review travis 🔴 ! before merging
Will do, thanks. |
@rafaelbn Travis failed due to the issue in module hr_attendance_report_theoretical_time, this module is not in the branch of this PR. |
Then rebase your branch and push force in order to test everything please |
@Trivedi-Vacha-SerpentCS you should rebase not merge |
c6f2de8
to
34e1adb
Compare
Is it ready to merge?? |
@jarroyomorales not all valid change-requests have beed addressed |
@Trivedi-Vacha-SerpentCS can you attend #458 (comment) so we can discuss about merging it? |
Didn't understand what exactly you are asking to change. |
@Trivedi-Vacha-SerpentCS I thought the second option proposed by @espo-tony in #458 (comment) made more sense, but if you want to keep it like this forget about my comment, at the end is a simple calculation. |
This PR has the |
/ocabot merge |
On my way to merge this fine PR! |
It looks like something changed on |
Congratulations, your PR was merged at 0e9f6c3. Thanks a lot for contributing to OCA. ❤️ |
[Mig][11.0]hr_employee_age:Migration to 11.0.