8000 chore: Added tests for GetAdminUrlForLanguage template tag by filipweidemann · Pull Request #8049 · django-cms/django-cms · GitHub
[go: up one dir, main page]

Skip to content

chore: Added tests for GetAdminUrlForLanguage template tag #8049

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

Merged
merged 14 commits into from
Oct 29, 2024

Conversation

filipweidemann
Copy link
Contributor

Description

This PR catches up on #8044 and adds two new tests targeting the regressed template tag GetAdminUrlForLanguage.
I think this is worth it. Please let me know what you think.

Related resources

#8044

Checklist

  • I have opened this pull request against develop-4
  • I have added or modified the tests when changing logic
  • I have followed the conventional commits guidelines to add meaningful information into the changelog
  • I have read the contribution guidelines and I have joined the channel #pr-reviews on our Discord Server to find a “pr review buddy” who is going to review my pull request.

Copy link
Member
@fsbraun fsbraun left a comment

Choose a reason for hiding this comment

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

Yes, this is a good idea!

However, you'll need to avoid assumptions on the primary keys.

@filipweidemann
Copy link
Contributor Author

@fsbraun Yup, that's right. I added your suggestions in one commit & fixed a spelling issue. Should be fine now! Do you have any other suggestions?

@fsbraun
Copy link
Member
fsbraun commented Oct 29, 2024

@filipweidemann What exactly is the difference between the two tests? Do we need them both?

I can imagine two tests (based on either of yours).

  1. In the test setup call page.get_content_obj("en") before calling the template tag.
  2. In the test setup call page.get_admin_content("en") before calling the template tag.

With a partially filled cache by the two calls, the tests would fail.

@filipweidemann
Copy link
Contributor Author

@fsbraun Yeah wow, I actually forgot the third case, you're right. Was thinking about this before implementing it. I'll add it as well!

About the current ones: I can probably remove the first one and only stick with the "faked" template one. My idea was that we also check if it can be forced to craft the links according to our language but let's be real, it actually is not doing anything here because it uses Django's reverse function. So what I am actually testing is Django and yeah, this is kind of unnecessary.

I'll remove the first one and replace it with the one you suggested because this one is actually missing right now!

@filipweidemann
Copy link
Contributor Author

@fsbraun okay so I deleted the first one and added the method calls before rendering the template.

I also verified that this catches the regression by temporarily adding del self.admin_content_cache["de"] inside the set_admin_content_cache. The test immediately failed.

This is cool. Anything else?

Copy link
Member
@fsbraun fsbraun left a comment

Choose a reason for hiding this comment

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

Nice! Looks good to me!! Thank you so much!

filipweidemann and others added 2 commits October 29, 2024 22:36
Co-authored-by: Fabian Braun <fsbraun@gmx.de>
Co-authored-by: Fabian Braun <fsbraun@gmx.de>
@fsbraun fsbraun changed the title chore: Add tests for GetAdminUrlForLanguage template tag chore: Added tests for GetAdminUrlForLanguage template tag Oct 29, 2024
@fsbraun fsbraun merged commit c41840f into django-cms:develop-4 Oct 29, 2024
52 checks passed
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.

2 participants
0