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

[16.0][IMP] hr_timesheet_sheet: split test file to reuse setup #706

Merged
merged 1 commit into from
Aug 19, 2024

Conversation

bealdav
Copy link
Member

@bealdav bealdav commented Aug 17, 2024

blame is kept after split files

use case #704

cc @pedrobaeza @MiquelRForgeFlow

EDIT :

finally a shorter commit.

Thanks to all for your review and advices

@bealdav bealdav changed the title Hr_timesheet_sheet: split test file to reuse setup [IMP][16.0] hr_timesheet_sheet: split test file to reuse setup Aug 17, 2024
@bealdav bealdav marked this pull request as ready for review August 17, 2024 13:08
Copy link
Member

@pedrobaeza pedrobaeza left a comment

Choose a reason for hiding this comment

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

The tag can be [REF], as this is a refactoring.

@@ -1,3 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import test_hr_timesheet_sheet
from . import test_hr_timesheet_sheet_
Copy link
Member

Choose a reason for hiding this comment

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

Why changing this?

Copy link
Member Author

Choose a reason for hiding this comment

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

To keep blame as before I use this flow:

cp file new; mv file new2; commit; upd files; commit

Then I need to rename initial file. If not blame is moved to my name

Copy link
Member

Choose a reason for hiding this comment

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

No, that's not something you can control. Try to blame on your fork and you'll see. One of the 2 parts won't have knowledge of this "split". I also prefer to keep them together. The common.py file is not following the naming convention (using the class name as the file name), and may be a disaster box for a lot of classes.

Copy link
Contributor

Choose a reason for hiding this comment

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

test_hr_timesheet_sheet_common?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Good that this works. I think that when more and more the diff diverges, Git/GitHub won't be able to distinguish the split. I have already found it when blaming long history files.

from odoo.tests.common import TransactionCase


class HrTimesheetSheetCommon(TransactionCase):
Copy link
Member

Choose a reason for hiding this comment

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

Please don't change the file, as this is not friendly for blame operations. Keep it everything in the same file.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hi Pedro don't blame me ;- ), I use setup in my PR.
That's the purpose of this PR

Check #704

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe you want I change class to setup but let code in the same file ?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, that's what I'm stating: I want to split the test classes, but in the same file, not putting the common.py file.

Copy link
Member Author

Choose a reason for hiding this comment

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

Now fixed

@pedrobaeza pedrobaeza added this to the 16.0 milestone Aug 19, 2024
Copy link
Member

@pedrobaeza pedrobaeza left a comment

Choose a reason for hiding this comment

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

Much better in readability. About the guideline of splitting, there are 2 things:

  1. I don't like to call it common.py. That's a convention not asked for and not self-descriptive. I know it's somehow inherited from Odoo core, but we mimic from them the things that are OK, and this one isn't personally. Instead, I prefer to still name it with the class name. For this case: test_hr_timesheet_common.py.
  2. I agree about having separate files for classes, but when the splitting is in the middle of the lifecycle of the module, better to keep it in the same file for all the blame and diff related queries.

/ocabot merge patch

@OCA-git-bot
Copy link
Contributor

On my way to merge this fine PR!
Prepared branch 16.0-ocabot-merge-pr-706-by-pedrobaeza-bump-patch, awaiting test results.

OCA-git-bot added a commit that referenced this pull request Aug 19, 2024
Signed-off-by pedrobaeza
@pedrobaeza pedrobaeza changed the title [IMP][16.0] hr_timesheet_sheet: split test file to reuse setup [16.0][IMP] hr_timesheet_sheet: split test file to reuse setup Aug 19, 2024
@OCA-git-bot
Copy link
Contributor

What a great day to merge this nice PR. Let's do it!
Prepared branch 16.0-ocabot-merge-pr-706-by-pedrobaeza-bump-patch, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 76bad81 into OCA:16.0 Aug 19, 2024
9 checks passed
@OCA-git-bot
Copy link
Contributor

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

@bealdav
Copy link
Member Author

bealdav commented Aug 19, 2024

Thanks a lot @pedro for this quick merge

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.

6 participants