Skip to content

Student project #8 - Improve a Python web application through testing and debugging.

Notifications You must be signed in to change notification settings

KDerec/Python_Testing

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Logo

Test and debug a Python project

This student project is the #8 of my training.
You can follow the previous here and next one here.

Table of Contents
  1. About The Project
  2. Built With
  3. Installation
  4. Usage
  5. Contact

About The Project

🌱 Developped skills

  • Analyze application performance with Locust.
  • Implement a Python test suite.
  • Handle errors and exceptions in Python.
  • Debug the code of a Python application.

📖 Scenario

I work for Güdlft, a company that created a digital platform to coordinate strength competitions (deadlifting 🏋🏻‍♂️, strongman) exclusively for branded fitness apparel companies.

Now, Güdlft has created a team called Regional Outreach to create a lighter (and less expensive) version of their current platform for regional organizers.

The team drew up a list of functional specifications for a prototype, broken down into several phases.
Sam, the main developer took care of phase 1, but he's getting sick, so I'm in charge of fixing the bugs in phase 1 and adding the feature expected in phase 2.

🚧 Project goal

The goal of the application is to streamline the management of competitions between clubs (hosting, registration, fees and administration).
This is a proof of concept (POC) project, The aim is the keep things as light as possible, and use feedback from the users to iterate.
The app is powered by JSON files. 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.

With the forked project, correct the error, bugs and add the feature of this issues section here.

Create tests and performance report.

🚀 Deliverable

pytest-coverage

See complete report with request, response time statistics and beautiful charts here.

Unit tests for server.py and utils.py

(back to top)

Built With

Before you begin, please ensure you have this installed globally.

(back to top)

Installation

  1. Install Python ;
  2. Clone the project in desired directory ;
    git clone https://github.com/KDerec/Python_Testing.git
  3. Change directory to project folder ;
    cd path/to/Python_Testing
  4. Create a virtual environnement ;
    virtualenv .
  5. Activate the virtual environment ;
    • For Windows :
      Scripts\activate
    • For Linux :
      source bin/activate
  6. Install package of requirements.txt ;
    pip install -r requirements.txt

(back to top)

Python installation

  1. Install Python. If you are using Linux or macOS, it should be available on your system already. If you are a Windows user, you can get an installer from the Python homepage and follow the instructions to install it:

    • Go to python.org
    • Under the Download section, click the link for Python "3.xxx".
    • At the bottom of the page, click the Windows Installer link to download the installer file.
    • When it has downloaded, run it.
    • On the first installer page, make sure you check the "Add Python 3.xxx to PATH" checkbox.
    • Click Install, then click Close when the installation has finished.
  2. Open your command prompt (Windows) / terminal (macOS/ Linux). To check if Python is installed, enter the following command (this should return a version number.):

    python -V
    # If the above fails, try:
    python3 -V
    # Or, if the "py" command is available, try:
    py -V

(back to top)

Usage

Run the server

  1. Change directory to flaskr folder ;

    cd path/to/Python_Testing/flaskr
  2. Run the server ;

    python server.py
  3. Go to http://127.0.0.1:5000/, login with an email accounts of clubs.json, for example, [email protected] and enjoy.

Tests and coverage test

  1. To run tests and coverage test, go to ;
    cd path/to/Python_Testing/tests
  2. Enter the two commands below ;
    coverage run -m pytest
    coverage report -m

Performance test

  1. Run server (see above) ;
  2. Go to ;
    cd path/to/Python_Testing/tests/performance_tests
  3. Enter ;
    locust
  4. Go to http://localhost:8089/, enter a number of users, spawn rate and host (http://127.0.0.1:5000/ by default) and click on "Start swarming".

(back to top)

Contact

Kévin Dérécusson 👇🏻
Email : [email protected]
LinkedIn : https://www.linkedin.com/in/kevin-derecusson/

(back to top)

This student project is the #8 of my training.
You can follow the previous here and next one here.

About

Student project #8 - Improve a Python web application through testing and debugging.

Topics

Resources

Stars

Watchers

Forks

Languages

  • Python 86.6%
  • HTML 13.4%