bartczak-pa / Cookbook

0 stars 0 forks source link

Fixed issues with views and tests #17

Closed bartczak-pa closed 2 months ago

bartczak-pa commented 2 months ago

Summary by Sourcery

Refactor the test suite to focus on RecipeDetailView, fixing issues with test setup and handling of non-existent entities. Enhance test coverage by adding parameterized tests and ensuring proper exception handling.

Bug Fixes:

Enhancements:

sourcery-ai[bot] commented 2 months ago

Reviewer's Guide by Sourcery

This pull request addresses issues with views and tests in the recipes app. The main changes include refactoring the TestRecipeDetailView class, updating the CategoryRecipeListView, and fixing some redundancies in the views.py file.

File-Level Changes

Change Details Files
Refactored TestRecipeDetailView class
  • Renamed TestCategoryRecipeListView to TestRecipeDetailView
  • Updated setup fixture to create a single recipe with associated ingredients and instructions
  • Added new test methods: test_get_object, test_get_object_404, test_get_queryset, and test_get_context_data
  • Removed old test methods that were specific to CategoryRecipeListView
  • Updated parametrize decorators to match new test scenarios
recipes/tests/test_views.py
Updated CategoryRecipeListView in views.py
  • Removed duplicate model and template_name declarations
  • Added context_object_name attribute
recipes/views.py
Improved test coverage and error handling
  • Added tests for non-existent recipes and categories
  • Implemented proper Http404 exception handling in tests
  • Added assertions to verify queryset and context data in RecipeDetailView
recipes/tests/test_views.py

Tips - Trigger a new Sourcery review by commenting `@sourcery-ai review` on the pull request. - Continue your discussion with Sourcery by replying directly to review comments. - You can change your review settings at any time by accessing your [dashboard](https://app.sourcery.ai): - Enable or disable the Sourcery-generated pull request summary or reviewer's guide; - Change the review language; - You can always [contact us](mailto:support@sourcery.ai) if you have any questions or feedback.