test: add unit tests for file_upload view#451
Open
andrianbalanesq wants to merge 1 commit into
Open
Conversation
Add comprehensive tests for the massmail file_upload view: - Anonymous user redirected to admin login - Non-staff user redirected to admin login - Staff user can access the upload form (GET) - Valid image upload saves file and returns close script (POST) - Invalid file extension is rejected with error message Closes DjangoCRM#410
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add comprehensive unit tests for the
file_uploadview inmassmail/views/file_upload.py, as requested in #410.Tests Added
All tests are in
tests/massmail/views/test_file_upload.pyand follow the existing test patterns in the project (inheriting fromBaseTestCase, using@tag('TestCase'), loading project fixtures):test_anonymous_user_redirected— Verifies that anonymous users are redirected to the admin login page (302).test_non_staff_user_redirected— Verifies that authenticated non-staff users are redirected to the admin login page (302).test_staff_user_get_upload_form— Verifies that staff users receive the upload form with the correct multipart enctype and file input field on a GET request (200).test_successful_image_upload— Verifies that a POST with a valid PNG file saves the file toMEDIA_ROOT/pics/and returns the window-close script.test_invalid_file_extension— Verifies that a POST with a disallowed file extension (.txt) is rejected with an error message.Test Results
Closes #410