bmswens / Flask-Capstone

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Capstone Test

Proposed capstone test for individuals learning Python and Flask.

Requirements

Installation

Linux

git clone https://github.com/bmswens/Flask-Capstone.git
cd 'Flask-Capstone'
python3 -m venv venv
source venv/bin/activate
pip3 install -r requirements.txt

Windows (Powershell)

git clone https://github.com/bmswens/Flask-Capstone.git
cd 'Flask-Capstone'
python -m venv venv
.\venv\Scripts\Activate.ps1
pip install -r requirements.txt

Database

About

The tests will automatically generate a SQLite database for you with the following form:

CREATE TABLE people 
( 
    id INTEGER PRIMARY KEY AUTOINCREMENT, 
    first_name TEXT NOT NULL, 
    last_name TEXT NOT NULL, 
    age INTEGER NOT NULL, 
    gender TEXT CHECK( gender IN ('male', 'female')) NOT NULL, 
    income INTEGER NOT NULL, 
    job_title TEXT NOT NULL 
);

Usage

The Database object comes with the __enter__ and __exit__ dunders already implemented so the database can automatically open the file and commit changes.

The Database.query() method will allow you to pass SQL as a string and return a list of lists for the results.

Example:

with Database("db.sqlite3") as db:
    rows = db.query("SELECT * FROM people limit 2")
print(rows)

prints

[(1, 'Monique', 'Gilbert', 95, 'male', 50864, 'programmer'), (2, 'Vernon', 'Taylor', 56, 'male', 89832, 'chef')]

Note: the order of the list will always remain the same when all items are selected, this can be used to your advantage.

Testing

About Testing


This method of writing software in this capstone is called Test Driven Development (TDD) and is a common and accepted best practice.


Students are expected to implement the functions that currently pass in accordance with both their documentation and tests.

The expected order of completion is:

  • app/database.py
    • rows_to_list_of_dicts()
    • get_average_income()
    • get_clean_column_names()
    • get_gender_count(gender)
  • app/analysis.py
    • standard_deviation(column)
    • variance(column)
  • app/webapp.py

Running Tests

Tests can be run with the following commands:

Linux

./bin/test.sh

Windows (Powershell)

.\bin\test.ps1

Reviewing Tests

Reports will be generated in the reports folder in .html format and can be viewed through your computer's browser.

The project is complete when both reports/pytest.html and reports/flake8/index.html report no issues or violations.

Reports can be opened via a file explorer, or with the following commands:

Linux

./bin/review.sh

Windows (Powershell)

.\bin\review.sh

Contributors

About

License:Apache License 2.0


Languages

Language:Python 85.1%Language:HTML 11.5%Language:PowerShell 1.9%Language:Shell 1.5%