diff --git a/Makefile b/Makefile index 0c689738..2082bb82 100644 --- a/Makefile +++ b/Makefile @@ -3,9 +3,17 @@ PACKAGES = notesserver notesapi validate: test.requirements test +pytest: test-start-services test test-stop-services + test: clean python -Wd -m pytest +test-start-services: + docker compose -f notesserver/docker-compose.test.yml --project-name=edxnotesapi_test up -d --remove-orphans + +test-stop-services: + docker compose -f notesserver/docker-compose.test.yml --project-name=edxnotesapi_test stop + pii_check: test.requirements pii_clean DJANGO_SETTINGS_MODULE=notesserver.settings.test code_annotations django_find_annotations --config_file .pii_annotations.yml \ --lint --report --coverage diff --git a/README.rst b/README.rst index fbaaec7e..321452c0 100644 --- a/README.rst +++ b/README.rst @@ -47,8 +47,21 @@ Configuration Running Tests ************* -Run ``make validate`` install the requirements, run the tests, and run -lint. +Install requirements:: + + make test.requirements + +Start mysql/elasticsearch services:: + + make test-start-services + +Run unit tests:: + + make test + +Run quality checks:: + + make quality How To Resync The Index *********************** diff --git a/notesserver/docker-compose.test.yml b/notesserver/docker-compose.test.yml new file mode 100644 index 00000000..0dc73b6c --- /dev/null +++ b/notesserver/docker-compose.test.yml @@ -0,0 +1,18 @@ +services: + mysql: + image: mysql:8.0 + environment: + MYSQL_ROOT_PASSWORD: + MYSQL_ALLOW_EMPTY_PASSWORD: "yes" + MYSQL_DATABASE: "edx_notes_api" + ports: + - 127.0.0.1:3306:3306 + + elasticsearch: + image: elasticsearch:7.13.4 + environment: + discovery.type: single-node + bootstrap.memory_lock: "true" + ES_JAVA_OPTS: "-Xms512m -Xmx512m" + ports: + - 127.0.0.1:9200:9200