Year of Bird(YOB) is a web application built with Flask for managing user profiles, votes, and more. This application supports user registration, login, profile management, voting, and administrative functions.
- User authentication (login, registration, logout)
- User profile management
- competition setup
- vote
- Admin and moderator roles
- Profile image upload and deletion
- Error handling pages for common HTTP errors (400, 404, 500)
Before you begin, ensure you have the following installed on your system:
- Python 3.x
- pip (Python package installer)
- MySQL or compatible database
-
Clone the repository:
git clone https://github.com/yourusername/COMP639S2_project_1_Nu.git cd COMP639S2_project_1_Nu -
Create a virtual environment and activate it:
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
-
Install the required Python packages:
pip install -r requirements.txt
-
Configure the database connection. Create a
connect.pyfile in the project root with your database settings:DB_HOST = 'localhost' DB_USER = 'your_db_user' DB_PASSWORD = 'your_db_password' DB_NAME = 'your_db_name' SECRET_KEY = 'your_secret_key'
-
Initialize the database with the required tables. You can find the SQL scripts in the
sql/directory. Run the scripts using your preferred method (e.g., MySQL Workbench, command line).
-
Ensure your MySQL database server is running and accessible.
-
Start the Flask application:
FLASK_APP=run.py flask run
-
Open your web browser and navigate to
http://localhost:5000.
- Navigate to the registration page (
http://localhost:5000/register). - Fill in the required fields and submit the form to create a new account.
- Navigate to the login page (
http://localhost:5000/login). - Enter your username and password to log in.
- After logging in, navigate to your profile page (
http://localhost:5000/profile/<your_user_id>). - Update your profile information and save changes.
- Admin users can access the admin home page (
http://localhost:5000/users) to manage user accounts.
app/: Contains the Flask application modules and templatesstatic/: Static files (e.g., CSS, JavaScript, images)templates/: HTML templates for rendering pagesyob/: Application logic and utility functionstests: Test functionsconfig.py: Configuration settings for the applicationconnect.py: Database settings for the applicationrequirements.txt: Python dependencies
This project uses Cypress for end-to-end (E2E) testing, providing a robust and reliable solution for testing. Cypress stands out from other testing frameworks with its ability to perform tests directly in the browser, offering real-time reloading, automatic waiting, and an interactive GUI, making it easier to debug and develop tests.
-
Install Node.js
Ensure you have Node.js installed, as Cypress requires it to run. -
Install Dependencies
Navigate to thetests/e2edirectory and run the following command to install all required dependencies:
npm installYou can run Cypress tests in two different modes:
Open Cypress in interactive mode to visually see the tests running in the browser:
npm run openRun all tests in headless mode without opening the GUI, useful for CI/CD pipelines:
npm run testThis command will execute all the E2E tests in the terminal and generate a test report.
- Test Files: All test cases are located in the
tests/e2e/cypress/e2edirectory. The test files are written in JavaScript. - Configuration: Cypress configuration settings are managed in the
cypress.config.jsfile. - Test Reports: Test results, including screenshots and videos (in headless mode), are stored in the `tests/e2e/cypress/reports directory.
Contributions are welcome! Please submit a pull request