Skip to content

[games] Revamp user game upload backend functionality with comprehensive tests#1537

Open
Abebes01 wants to merge 13 commits intodevfrom
game-management/uploading-twine-files
Open

[games] Revamp user game upload backend functionality with comprehensive tests#1537
Abebes01 wants to merge 13 commits intodevfrom
game-management/uploading-twine-files

Conversation

@Abebes01
Copy link
Contributor

This PR enhances the existing UploadFileView to provide a robust user game upload system that supports both embedded games and Twine file uploads with proper validation, improved UX, and comprehensive test coverage. The current system had hardcoded values, no form validation, and limited functionality - this update transforms it into a comprehensive upload solution with full test coverage. What is added in this PR specifically is:

Enhanced UploadFileView with GET method to display upload forms and dual POST handling for embedded/Twine games
Added proper form validation for required fields, file extensions, and input types with clear error messaging
Added user attribution system that automatically adds uploaders to game users and tracks ownership
Added a management command test_user_uploads to create sample Twine games for testing functionality
Added new URL route /games/upload/ for dedicated upload access while maintaining backward compatibility
Added comprehensive test suite covering authentication, validation, success scenarios, and error handling
Added edge case testing for file uploads, numeric validation, and proper cleanup of test artifacts

To easily test this PR:
First, run the command python manage.py test_user_uploads. This will create test Twine games and a test user account. Then, visit /games/upload/ while logged in to test the upload form, or visit the direct game URLs provided by the command output to see the uploaded Twine games in action. To run the automated tests, use python manage.py test chigame.games.tests.test_user_uploads -v 2 to see detailed test results.
The files changed in this PR are mainly views.py for the enhanced upload logic, urls.py for the new route, the new management command test_user_uploads.py for generating test data, and the comprehensive test suite test_user_uploads.py that ensures reliability across all upload scenarios.

Previous implimentation of user game upload hardcoded various variables and did not account for new additions such as embedded games. Revamped that functionality, and added a command file to test this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[games] Add user game upload interface to games page [games] Revamp user game upload backend functionality

4 participants