Skip to content
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

Merged
merged 8 commits into from
Sep 27, 2019

Conversation

Trivedi-Vacha-SerpentCS
Copy link

[Mig][11.0]hr_employee_age:Migration to 11.0.

@Trivedi-Vacha-SerpentCS Trivedi-Vacha-SerpentCS changed the title [Mig][11.0]hr_employee_age:Migration to 11.0. [MIG][11.0]hr_employee_age:Migration to 11.0. Jul 3, 2018
sambarros pushed a commit to sambarros/hr that referenced this pull request Jul 26, 2018
Copy link

@hieulucky111 hieulucky111 left a 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.

Copy link
Member

@nikul-serpentcs nikul-serpentcs left a 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

@JayVora-SerpentCS
Copy link
Sponsor

Good to add unit tests

Copy link
Member

@nikul-serpentcs nikul-serpentcs left a comment

Choose a reason for hiding this comment

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

LGTM

@pedrobaeza
Copy link
Member

Can you please squash a bit commit history and fix that merge commit (rebasing you will get this fixed)?

@Trivedi-Vacha-SerpentCS
Copy link
Author

@pedrobaeza Squshed, Ready to merge

@pedrobaeza pedrobaeza added this to the 11.0 milestone Oct 1, 2018
Copy link
Contributor

@espo-tony espo-tony left a 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()
Copy link
Contributor

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.

Copy link
Member

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.

CC @JayVora-SerpentCS

Copy link
Contributor

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.

Copy link
Member

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.

Copy link
Contributor

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.

Copy link
Member

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.

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

@jarroyomorales nope, not ready ^

@JayVora-SerpentCS
Copy link
Sponsor

JayVora-SerpentCS commented Oct 1, 2018

I realised lately yes, we need asserts!

@Trivedi-Vacha-SerpentCS Trivedi-Vacha-SerpentCS force-pushed the 11.0-hr_employee_age branch 2 times, most recently from a67ef81 to c6f2de8 Compare October 3, 2018 05:08
@Trivedi-Vacha-SerpentCS
Copy link
Author

@espo-tony Fixed Code, please add review
@pedrobaeza @JayVora-SerpentCS Squash done, Ready to Merge

@rafaelbn
Copy link
Member

Hi @Trivedi-Vacha-SerpentCS ,

I'm rebuilding runbot for testing. In any case i saw travis is 🔴 so it's passing again the see what happens

Thanks!!!!

Copy link
Member

@rafaelbn rafaelbn left a 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

@JayVora-SerpentCS
Copy link
Sponsor

Will do, thanks.

@Trivedi-Vacha-SerpentCS
Copy link
Author

@rafaelbn Travis failed due to the issue in module hr_attendance_report_theoretical_time, this module is not in the branch of this PR.

@etobella
Copy link
Member

Then rebase your branch and push force in order to test everything please

@etobella
Copy link
Member

@Trivedi-Vacha-SerpentCS you should rebase not merge

@jarroyomorales
Copy link

Is it ready to merge??

@alexey-pelykh
Copy link
Contributor

@jarroyomorales not all valid change-requests have beed addressed

@jarroyomorales
Copy link

@Trivedi-Vacha-SerpentCS can you attend #458 (comment) so we can discuss about merging it?

@Trivedi-Vacha-SerpentCS
Copy link
Author

Didn't understand what exactly you are asking to change.

@jarroyomorales
Copy link

@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.

@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@alexey-pelykh
Copy link
Contributor

/ocabot merge

@OCA-git-bot
Copy link
Contributor

On my way to merge this fine PR!
Prepared branch 11.0-ocabot-merge-pr-458-by-alexey-pelykh-bump-no, awaiting test results.

OCA-git-bot added a commit that referenced this pull request Sep 27, 2019
Signed-off-by alexey-pelykh
@OCA-git-bot
Copy link
Contributor

It looks like something changed on 11.0 in the meantime.
Let me try again (no action is required from you).
Prepared branch 11.0-ocabot-merge-pr-458-by-alexey-pelykh-bump-no, awaiting test results.

OCA-git-bot added a commit that referenced this pull request Sep 27, 2019
Signed-off-by alexey-pelykh
@OCA-git-bot OCA-git-bot merged commit 34e1adb into OCA:11.0 Sep 27, 2019
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 0e9f6c3. Thanks a lot for contributing to OCA. ❤️

@Trivedi-Vacha-SerpentCS Trivedi-Vacha-SerpentCS deleted the 11.0-hr_employee_age branch September 4, 2020 10:01
Mraimou pushed a commit to camptocamp/hr that referenced this pull request Feb 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet