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

Refactor settings to make override_settings in tests more consistent #168

Merged

Conversation

protoroto
Copy link
Member

Description

Refactor settings to make override_settings in tests more consistent

References

Fix #167

Checklist

  • I have read the contribution guide
  • Code lint checked via inv lint
  • changes file included (see docs)
  • Usage documentation added in case of new features
  • Tests added

@protoroto protoroto requested a review from yakky August 25, 2023 15:11
@protoroto protoroto force-pushed the feature/issue-167-refactor-settings branch from 6c240da to a8d4fa0 Compare August 25, 2023 15:18
@coveralls
Copy link

coveralls commented Aug 25, 2023

Coverage Status

coverage: 98.272% (+0.01%) from 98.261% when pulling 9d110fd on protoroto:feature/issue-167-refactor-settings into 0ac87d3 on nephila:develop.

cms_helper.py Outdated
META_USE_SITES=True,
META_USE_OG_PROPERTIES=True,
META_USE_TWITTER_PROPERTIES=True,
META_USE_SCHEMAORG_PROPERTIES=True,
Copy link
Member

Choose a reason for hiding this comment

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

these are meant to be used when running app_helper.py server to run the sample project

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, ok, I see... if I leave them there, some tests are failing somehow because I think tests use those settings.

For instance, test_meta.py::MetaObjectTestCase::test_defaults fails because self.assertEqual(m.use_og, False) is actually True, because of META_USE_OG_PROPERTIES=True in cms_helper.py

What's the best approach here? Override those settings globally in every test class, in order to reflect the actual default defined in settings.py?

Copy link
Member

Choose a reason for hiding this comment

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

I see

I can't think of a clean solution, so maybe the cleanest is to use override_settings on BaseTestClass to ensure all the tests use the desired setting no matter what cms_helper sets?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

@codecov
Copy link

codecov bot commented Aug 27, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.01% 🎉

Comparison is base (0ac87d3) 97.60% compared to head (9d110fd) 97.62%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #168      +/-   ##
===========================================
+ Coverage    97.60%   97.62%   +0.01%     
===========================================
  Files            8        8              
  Lines          460      463       +3     
  Branches        78       79       +1     
===========================================
+ Hits           449      452       +3     
  Misses           8        8              
  Partials         3        3              
Flag Coverage Δ
unittests 97.40% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
meta/models.py 93.97% <100.00%> (-0.08%) ⬇️
meta/settings.py 100.00% <100.00%> (ø)
meta/templatetags/meta.py 100.00% <100.00%> (ø)
meta/views.py 98.13% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@protoroto protoroto merged commit d47660a into nephila:develop Aug 28, 2023
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.

Refactor settings
3 participants