upstage-org / upstage

UpStage is a platform for cyberformance: remote players combine digital media in real-time for an online audience. All you need is a web browser!
https://upstage.org.nz
GNU General Public License v3.0
21 stars 0 forks source link

Pycoverage testing, managing test DB for this purpose, other notes. #1329

Open gloriajw opened 2 months ago

gloriajw commented 2 months ago

Unit tests for each module should be invoked by pycoverage. Please create and destroy the test DB outside of the test framework, so that each setUp and tearDown is not recreating it. This implies the need for a control script that does setup, runs all tests under pycoverage, and then does the teardown.

Please start with the auth system and the current tests you have, and let's see the coverage we're getting.

nnguyenquangg commented 2 months ago
cp .env.unit_test .env
export $(grep -v '^#' .env | xargs)

export PGPASSWORD=$DATABASE_PASSWORD
psql -h $DATABASE_HOST -p $DATABASE_PORT -U $DATABASE_USER -c "DROP DATABASE IF EXISTS $DATABASE_NAME;"
psql -h $DATABASE_HOST -p $DATABASE_PORT -U $DATABASE_USER -c "CREATE DATABASE $DATABASE_NAME;"
alembic upgrade head
coverage run -m pytest
psql -h $DATABASE_HOST -p $DATABASE_PORT -U $DATABASE_USER -c "DROP DATABASE IF EXISTS $DATABASE_NAME;"

@gloriajw here is the setup when run tests with create and destroy the database

nnguyenquangg commented 2 months ago

image Here is the result when I run coverage report

gloriajw commented 2 months ago

Beautiful! Try to get it as close to 100 as possible. very good.

gloriajw commented 2 months ago
cp .env.unit_test .env
export $(grep -v '^#' .env | xargs)

export PGPASSWORD=$DATABASE_PASSWORD
psql -h $DATABASE_HOST -p $DATABASE_PORT -U $DATABASE_USER -c "DROP DATABASE IF EXISTS $DATABASE_NAME;"
psql -h $DATABASE_HOST -p $DATABASE_PORT -U $DATABASE_USER -c "CREATE DATABASE $DATABASE_NAME;"
alembic upgrade head
coverage run -m pytest
psql -h $DATABASE_HOST -p $DATABASE_PORT -U $DATABASE_USER -c "DROP DATABASE IF EXISTS $DATABASE_NAME;"

@gloriajw here is the setup when run tests with create and destroy the database

Please use the same backend settings convention for test configuration as we use for standard configuration. Call the test config file test_config.py, place it in the same config dir as the server one, and use it to do this configuration. The rest looks good!

gloriajw commented 1 month ago

Please add pycoverage test results here for the asset code you've completed. Thank you!

nnguyenquangg commented 1 month ago

image Hi @gloriajw

Here is the current coverage tests Next path , I will add coverage test for stage module and fix for asset module

nnguyenquangg commented 1 month ago

Report 26/09/2024 Hi @gloriajw Here is the current coverage tests I'm adding for module and fix for asset module

image
nnguyenquangg commented 1 month ago

Report 27/09/2024

Hi @gloriajw Here is the current coverage tests

image
nnguyenquangg commented 1 month ago

Report 3/10/2024

Writing coverage tests for stages and studio module

nnguyenquangg commented 1 month ago

Report 06/10/2024

Hi @gloriajw Here is the current coverage test result

image

nnguyenquangg commented 1 month ago

Report 7/10/2024 Hi @gloriajw I'm adding pycoverage test for studio module

nnguyenquangg commented 1 month ago
image

Hi @gloriajw Report 10/10/2024 Here is the current coverage test result