This assignment involved extending the previous assignment to persist changes using a database. SQLAlchemy's ORM was used with simple in-memory caching added using Flask-Caching. TDD practices were applied throughout development with unit and integration tests being implemented for the ORM and database repository respectively.
The site has been deployed on Heroku with a PostgreSQL database and can be found at mymovielist-is-taken.herokuapp.com. To stay within the limits of Heroku's free tier (max 10,000 database rows) only a subset of the movies have been loaded there. Additionally the free tier goes to sleep after ~30 minutes if there hasn't been any activity, so initial page load can be slow.
These setup instructions assume you already have Python and virtualenv installed. The following will clone this repository, setup and activate a virtual environment, and install dependencies.
git clone https://github.com/NeedsSoySauce/COMPSCI-235-A3.git
cd .\COMPSCI-235-A3\
virtualenv .virtualenv
.\.virtualenv\Scripts\activate
pip install -r requirements.txt
git clone https://github.com/NeedsSoySauce/COMPSCI-235-A3.git
cd .\COMPSCI-235-A3\
virtualenv .virtualenv
source .\.virtualenv\Scripts\activate
pip install -r requirements.txt
The .env file at the project's root contains configuration settings. They are defined as follows:
FLASK_APP
: Entry point of the application (should always bewsgi.py
).FLASK_ENV
: The environment in which to run the application (eitherdevelopment
orproduction
).SECRET_KEY
: Secret key used to encrypt session data.TESTING
: Set to False for running the application. Overridden and set to True automatically when testing the application. Can be set to true to force the database repository to be repopulated on each run.WTF_CSRF_SECRET_KEY
: Secret key used by the WTForm library.SQLALCHEMY_DATABASE_URI
: URI for the database SQLAlchemy will use.SQLALCHEMY_ECHO
: Set to True to log debugging information from SQLAlchemy.REPOSITORY
: Specifies what repository to use. Either 'memory' or 'database'.MAX_LINES_TO_LOAD
: Integer. Specifies the maximum number of movies to populate the repository with. If not specified all available movies are loaded.
Additionally, if deploying to an environment like Heroku, the environment variables specified there will take precedence. Additionally, the
From the project's root and within the activated virtual environment:
flask run
From the project's root and within the activated virtual environment:
python -m pytest
To run tests with coverage:
coverage run --source ./movie -m pytest
coverage report