Flask web application for group project. Please see this file for the lab instructions for end-to-end (E2E) testing.
- Clone this repository and
cd
into it - Create a python virtual environment in the root directory.
python3 -m venv .venv
- Activate the virtual environment according to your platform.
NOTE: You will need to re-activate the virtual environment if your terminal is closed (shutting off PC, closing terminal app, etc.). Always ensure that the virtual environment is active before attempting to run the application, and always ensure that it is NOT active when you are not working with the application, but are still using the terminal.
Linux/Mac (bash/zsh/Any Bourne-compatible shell):
source .venv/bin/activate
Windows (PowerShell):
.venv\Scripts\Activate.ps1
Windows (cmd.exe):
.venv\Scripts\Activate.bat
- Lastly, install the dependencies for the application
pip3 install -r requirements.txt
-
Make sure the python virtual environment is activated (see above)
-
Initialize the database
flask --app clothing_store init-db
- Run the application, the
--debug
option will automatically rerun the application when files change. However, you will still have to refresh the browser to see the changes.
flask --app clothing_store run --debug
- Open the web app in a browser at http://localhost:5000
-
For testing with
pytest
to work you will need to install the clothing store application withpip
. Make sure you are in the root project directoryWeb-App
and your virtual environment is activated.pip install -e .
-
Follow these lab instructions to learn a little bit about how to create and run end-to-end (E2E) testing for web applications.
OR
-
From the root of the repository run the
pytest tests/pytest
command to run default test scripts.IMPORTANT: The
tests
directory also contains Selenium and API tests, which ARE NOT Pytest scripts. Runningpytest
on its own will cause it to source incompatible files, which will create errors and fail to run the actual test scripts. Anytime you want to runpytest
orcoverage
, you MUST specify thetests/pytest
directory in the command to make sure only the appropriate test scripts are sourced.pytest tests/pytest
To measure code coverage of the tests, use the coverage
command to run pytest
instead of running it directly.
coverage run -m pytest tests/pytest
- When working with the application, always make sure you are in the root directory
Web-App
and the virtual environment is active. - To check if the virtual environment is active, run
which python
, which should print out a path to the project's virtual environment in the rootWeb-App
directory if the virtual environment is active