rctay / tdd-lab-login-form-python-flask

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Login Form Demo

This repository contains a simple web application written in Python.

It has a signup form and login form where you can signup for a new user account and login to an existing user account.

The goal of this kata is to simulate a real world example of how we use Test Driven Development (TDD) on an existing code base. So given a ready made web application, how would you use TDD to drive the introduction of a new feature - in this case, an enhancement to the signup form.

Your facilitators will show you how to use a "Test First" strategy of adding new automated test codes in the test suite (to simulate the new feature), before attempting to build the feature in the leanest way, and then proceed to refactor the code. We hope that you will see how having automated tests helps you in building higher quality code.

If time permits, your facilitators may also introduce you to the idea of refactoring of an existing code base.


Stories


Running the application

Open this folder in your terminal app. And run these commands in the terminal.

  1. Create virtual environment

    pipenv shell
    
  2. Installing packages

    pipenv install -r requirements.txt
    

    You can open this url in your browser to view the app: http://localhost:5000

  3. To run the test:

    Here are the options for pytest

    • v - The verbose view of test case
    python -m pytest -v
    
  4. To run the web application

    flask run
    

Python Packages

  • Flask - Python web framework used for the web application.
  • Jinja - Templating engine for displaying the HTML pages.
  • Pytest - Python testing framework
  • Requests - Elegant and simple HTTP library for Python
  • Pipenv - Python Dev Workflow for Humans

Routes

  1. GET /

    This is the home page. The login form is also here.

  2. GET /signup

    This is the registration form.

  3. POST /signup

    Sign up for new user account.

  4. POST /signin

    This is how you login to the app. You will need to login with email and password.

    The default email is demo@example.com and password is demo1234.

  5. GET /users/welcome

    Landing page after you have successfully logged in with the correct credentials.

  6. GET /users/logout

    URL for logging out of the application.

About


Languages

Language:HTML 50.5%Language:Python 48.5%Language:CSS 1.0%