Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
2a5131a
Testing folder and files initiated. utils.py created for unit testing…
Jun 1, 2026
232f133
setup des fichiers pour test de coverage. Migration des fonctions uti…
Jun 17, 2026
7568d8f
refactor: switch to Flask application factory and inject test data
Jun 17, 2026
dde1e43
Warning filter added for pytest. Integration tests on login feature i…
Jun 18, 2026
041e262
refactor(book route, utils): improve robustness with safe lookups
Jun 19, 2026
ddcbb9e
feat(purchase): add robust booking validation and flash feedback
Jun 22, 2026
a161a4d
refactor(server): improve booking feedback with purchased places count
Jun 22, 2026
2e1b07c
feat(booking): add client-side place limit validation with dynamic co…
Jun 22, 2026
b805c43
feat(booking): block booking for past competitions and hide link in w…
Jun 22, 2026
2a06d54
refactor(booking): rename validateBooking to isBookingValid and harde…
Jun 24, 2026
0ccc512
feat(purchase): centralize points/places updates in utils after booking
Jun 24, 2026
a8dced3
feat(booking): enforce cumulative 12-place limit per club and competi…
Jun 24, 2026
6ce7ea9
feat(points-board): add public read-only points board
Jun 24, 2026
d2aa75d
feat(auth): store logged-in user in session, add protected navigation…
Jun 26, 2026
fcef370
refactor(auth): centralize login/session helpers in utils, keep flash…
Jun 26, 2026
600a844
refactor: clean up server handlers and modernize templates for semant…
Jun 26, 2026
cdc236b
test: scope pytest collection to tests and add stable login selector …
Jun 30, 2026
0caec5a
Added test directory to distant repo.
Jul 24, 2026
4f00cee
Refactoring: translated all french to english. Transformed all camelC…
Jul 31, 2026
1283b06
Refactoring: updated README.
Jul 31, 2026
b51feb8
Refactoring: updated README. Added docsctrings and typing.
Jul 31, 2026
42a8840
Refactoring: Updated README. Installed Flake8 htlm report. Generated …
Aug 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[run]
omit = tests/*
10 changes: 10 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[flake8]
exclude =
.pytest_cache,
__pycache__,
bin,
htmlcov,
include,
lib
format = html
htmldir = flake8-report
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ bin
include
lib
.Python
tests/
.envrc
__pycache__
__pycache__
.pytest_cache/
.coverage
.DS_Store
239 changes: 212 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,236 @@
# gudlift-registration
# GUDLFT Registration

1. Why
## 📌 About

This is a **proof of concept (POC)** project for a lightweight competition booking platform. The goal is to keep things as simple as possible and iterate based on user feedback.

This is a proof of concept (POC) project to show a light-weight version of our competition booking platform. The aim is the keep things as light as possible, and use feedback from the users to iterate.
---

2. Getting Started
## ⚙️ Prerequisites

This project uses the following technologies:
- **Python 3.10+** (recommended: 3.11 or 3.12)
- **pip** (Python package manager, included with Python 3)
- **Git** (for cloning the repository)

* Python v3.x+
---

* [Flask](https://flask.palletsprojects.com/en/1.1.x/)
## 🚀 Getting Started

Whereas Django does a lot of things for us out of the box, Flask allows us to add only what we need.

### 1️⃣ Clone the Repository

* [Virtual environment](https://virtualenv.pypa.io/en/stable/installation.html)
```bash
git clone https://github.com/Q1009/Python_Testing.git
cd Python_Testing
```

This ensures you'll be able to install the correct packages without interfering with Python on your machine.
---

Before you begin, please ensure you have this installed globally.
## 🛠️ Installation

### Create and Activate a Virtual Environment

3. Installation
A virtual environment isolates dependencies for this project, preventing conflicts with other Python projects on your system.

- After cloning, change into the directory and type <code>virtualenv .</code>. This will then set up a a virtual python environment within that directory.
```bash
# Create a virtual environment in the project directory using virtualenv
virtualenv .

- Next, type <code>source bin/activate</code>. You should see that your command prompt has changed to the name of the folder. This means that you can install packages in here without affecting affecting files outside. To deactivate, type <code>deactivate</code>
# Activate the virtual environment
# On macOS/Linux:
source bin/activate

- Rather than hunting around for the packages you need, you can install in one step. Type <code>pip install -r requirements.txt</code>. This will install all the packages listed in the respective file. If you install a package, make sure others know by updating the requirements.txt file. An easy way to do this is <code>pip freeze > requirements.txt</code>
# On Windows (Command Prompt):
Scripts\activate

- Flask requires that you set an environmental variable to the python file. However you do that, you'll want to set the file to be <code>server.py</code>. Check [here](https://flask.palletsprojects.com/en/1.1.x/quickstart/#a-minimal-application) for more details
# On Windows (PowerShell):
.\Scripts\activate
```

- You should now be ready to test the application. In the directory, type either <code>flask run</code> or <code>python -m flask run</code>. The app should respond with an address you should be able to go to using your browser.
Your terminal prompt should now indicate the virtual environment is active.

4. Current Setup
> **⚠️ Note:** Always activate the virtual environment before running the app or tests.

The app is powered by [JSON files](https://www.tutorialspoint.com/json/json_quick_guide.htm). This is to get around having a DB until we actually need one. The main ones are:

* competitions.json - list of competitions
* clubs.json - list of clubs with relevant information. You can look here to see what email addresses the app will accept for login.
---

5. Testing
### Install Dependencies

You are free to use whatever testing framework you like-the main thing is that you can show what tests you are using.
With the virtual environment active, install all required packages:

We also like to show how well we're testing, so there's a module called
[coverage](https://coverage.readthedocs.io/en/coverage-5.1/) you should add to your project.
```bash
pip install --upgrade pip # Optional: upgrade pip to the latest version
pip install -r requirements.txt
```

> **💡 Tip:** If you add a new package, update `requirements.txt` with:
> ```bash
> pip freeze > requirements.txt
> ```

---

## ▶️ Running the Application

Set the Flask environment variable and start the development server:

```bash
# On macOS/Linux:
export FLASK_APP=server.py
flask run

# On Windows (Command Prompt):
set FLASK_APP=server.py
flask run

# On Windows (PowerShell):
$env:FLASK_APP = "server.py"
flask run
```

The app should start on `http://127.0.0.1:5000/`. Open this address in your browser to access the **GudLift Registration Portal**.

---

## 📂 Project Structure

The application uses **JSON files** for data storage (no database required):

- `competitions.json` – List of available competitions
- `clubs.json` – List of clubs with their email and points

> **🔍 Tip:** Check these files to see valid login emails and available competitions.

---

## 🧪 Running Tests

This project includes **unit tests**, **integration tests**, and **functional tests**.

### Run All Tests

```bash
# Install pytest if not already installed
pip install pytest

# Run all tests
pytest
```
### 📊 Testing Results

Here's an example of pytest testing results:

![Pytest Test Results](./tests/test_results_screenshot.png)


### Run Specific Test Suites

```bash
# Run only unit tests
pytest tests/unit/

# Run only integration tests
pytest tests/integration/

# Run only functional tests
pytest tests/functional/

# Run tests with verbose output
pytest -v
```

### Run Tests with Coverage

To check test coverage (how much of your code is tested):

```bash
# Install coverage if not already installed
pip install coverage

# Run tests with coverage and generate an HTML report
pytest --cov=. --cov-report html

#Open the report in your browser
open htmlcov/index.html # macOS
start htmlcov/index.html # Windows
xdg-open htmlcov/index.html # Linux

```

### 📊 Coverage Test Results

Here's an example of coverage test results:

![Coverage Test Results](./tests/coverage_test_results_screenshot.png)

---

## 🚀 Performance Testing with Locust

[Locust](https://locust.io/) is used for **load testing** to simulate multiple users and check how the application performs under stress.

### Install Locust

```bash
# Install locust if not already installed
pip install locust
```

### Run Locust Tests

```bash
locust -f tests/performance/locustfile.py
```

### Using the Locust Web Interface

1. Open `http://localhost:8089` in your browser.
2. Set the **Number of total users** (e.g., 10).
3. Set the **Spawn rate** (users per second, e.g., 1).
4. Click **Start swarming**.
5. Monitor:
- **Response times** (in ms)
- **Request rate** (RPS)
- **Failure rate**
- **Number of users**

> **💡 Tip:** Stop the test with `Ctrl+C` in the terminal or click **Stop** in the web interface.

### 📊 Locust Performance Test Results

Here's an example of performance test results with Locust:

![Locust Performance Test Results](./tests/performance_test_results_screenshot.png)

---

## 🔍 Code Quality & Linting

This project uses **Flake8** to ensure code compliance with [PEP 8](https://peps.python.org/pep-0008/) style guidelines.

### Generate an HTML Report

With the virtual environment active, to generate and visualize Flake8 results in a browser:

```bash
# Generate a detailed HTML report
flake8 --format=html --htmldir=flake8_report

# Open the report in your browser
open flake8_report/index.html # macOS
start flake8_report/index.html # Windows
xdg-open flake8_report/index.html # Linux
```

### 📊 Flake8 Report

Here's an example of Flake8 html report:

![Locust Performance Test Results](./tests/flake8_report_screenshot.png)

---

## 📝 Notes

- The virtual environment files (`bin/`, `Scripts/`, `lib/`, etc.) are **not committed** to Git (add them to `.gitignore`).
- Always **deactivate** the virtual environment when done:
```bash
deactivate
8 changes: 4 additions & 4 deletions competitions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"competitions": [
{
"name": "Spring Festival",
"date": "2020-03-27 10:00:00",
"numberOfPlaces": "25"
"date": "2026-03-27 10:00:00",
"number_of_places": "25"
},
{
"name": "Fall Classic",
"date": "2020-10-22 13:30:00",
"numberOfPlaces": "13"
"date": "2026-10-22 13:30:00",
"number_of_places": "13"
}
]
}
73 changes: 73 additions & 0 deletions flake8_report/back.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading