Test files are located in dev-backend/flask_docker/test
For now, to run this test:

cd to docker_code and run 'python3 -m unittest tests/models/<file to test>' to test models and run 'python3 -m unittest tests/views/<file to test>' to test views

Note: Please run the unit test in the docker container: under www/var (reference: Dev/Debug in Container)
Otherwise, you will need to install all dependencies in your local env.


views/samples_test.py

functions

Doc
get_user_auth
helper function to get auth for a mock user
upload_sample_image
helper function to upload a sample image
upload_sample_survey
helper function to upload sample survey (sample data)
get_sample_survey
helper function to get survey data of a sample
test_upload_sample
test if a user can upload a sample
test_get_sample
test if a user can get a specific sample
test_get_sample_count_total
test if a user can get the sample count
test_get_samples
test if a user can get a sample list

  

views/users_test.py

functions

Doc
test_make_user

test if we can create a user successfully


views/authentication_test.py

functions

Doc
test_authenticate_no_such_usertest authenticating non-existed user
test_authenticate_pwd_is_nonetest authenticating a user who has not set password will send a password set email
test_authenticate_diff_pwdtest authenticating a user with the wrong password
test_authenticatetest authenticating a normal user
test_reset_password_invalid_email_addresstest resetting password given an invalid email address
test_reset_password_update_pwdtest resetting password
test_reset_password_unauthorizedtest resetting password for an unauthorized user
test_request_password_reset_invalid_emailtest requesting password reset with an invalid email address
test_request_password_reset_no_user_datatest requesting password reset with non-existed user
test_request_password_resettest requesting password reset
test_logouttest if a user can log out successfully

views/survey_test.py

functions

Doc
get_user_authhelper function to get auth for a mock user
test_upload_survey

Test to see if a valid survey is able to uploaded and stored in the database with a survey name

test_survey_retrievalTest to see if the survey can be retrieved in the right format in addition to the ability to return responses for the survey



views/upload_test.py

functions

Doc
get_user_authhelper function to get auth for a mock user
test_upload_read

Test to see if a valid read is able to be uploaded and stored in the database and retrieved using barcode id.

test_get_reads

Test to see if all the reads can be retrieved in the right format in addition to the ability to return responses for the survey.









  • No labels