From b9ed0ce828ae31c4648ad3bc719bb97c25b1c8d7 Mon Sep 17 00:00:00 2001 From: Justin W. Flory Date: Jun 09 2019 22:30:29 +0000 Subject: [PATCH 1/6] tests: Retire previous test framework (coverage) --- diff --git a/circle.yml b/circle.yml deleted file mode 100644 index e404836..0000000 --- a/circle.yml +++ /dev/null @@ -1,36 +0,0 @@ -machine: - services: - - rabbitmq-server - environment: - EMAIL_USER: notused - EMAIL_PASSWORD: notused - MESSAGEBIRD_USERNAME: notused - MESSAGEBIRD_KEY: notused - DB_NAME: circle_test - DB_USERNAME: ubuntu - DB_PASSWORD: - DJANGO_HOSTNAME: localhost:8000 - DJANGO_ALLOWED_HOSTS: '*' - DJANGO_LOGFILE: /tmp/django.log - SECRET_KEY: 'integration-test-only' - DJANGO_SETTINGS_MODULE: happinesspackets.settings.ci - PORTAL_CELERY_TASK_QUEUE: celery - PYTHONUNBUFFERED: x - -dependencies: - override: - - pip install -U --exists-action=s -r requirements/ci.txt || (echo 'Retrying pip'; pip install -U --exists-action=s -r requirements/ci.txt) || (echo 'Retrying pip 2'; pip install -U --exists-action=s -r requirements/ci.txt) - -test: - pre: - - ./manage.py collectstatic --noinput: - parallel: true - override: - - ./run_ci_tests.bash: - parallel: true - timeout: 600 - -general: - artifacts: - - "selenium-screenshots" - - "htmlcov" diff --git a/run_ci_tests.bash b/run_ci_tests.bash deleted file mode 100755 index bbcb3c2..0000000 --- a/run_ci_tests.bash +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -x -# This is a simple script to run our integration tests in parallel on CircleCI. This will be called from circle.yml. -# At this time, the script only works for having two nodes. - -ret=0 - -case $CIRCLE_NODE_INDEX in - 0) - coverage run ./manage.py test -v 2 --noinput && coverage html --fail-under=90 || ret=$? - ;; - - 1) - flake8 happinesspackets || ret=$? - ./manage.py makemigrations --dry-run --noinput | grep -i 'no changes detected' || ret=$? - ;; -esac - -exit $ret - - - diff --git a/t b/t deleted file mode 100755 index ae3ee29..0000000 --- a/t +++ /dev/null @@ -1,2 +0,0 @@ -export DJANGO_SETTINGS_MODULE=happinesspackets.settings.tsting && -coverage report --fail-under=100 From 14e92dbdda17b1a226545fb3b3c423280a24b5f1 Mon Sep 17 00:00:00 2001 From: Justin W. Flory Date: Jun 09 2019 22:39:56 +0000 Subject: [PATCH 2/6] dependencies: Add more pytest plugin to dev-packages --- diff --git a/Pipfile b/Pipfile index e903013..d48b641 100644 --- a/Pipfile +++ b/Pipfile @@ -5,6 +5,8 @@ verify_ssl = true [dev-packages] pytest = "*" +pytest-django = "*" +pytest-sugar = "*" [packages] diff --git a/Pipfile.lock b/Pipfile.lock index c7e279b..c817fbc 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "fe5873b873c525eda6223e20fd22f4c9ec625addba1f0a5f9eb3c9b94c1d8b2d" + "sha256": "c1b8d37f8bafd0f7f115370ef14c97d96c8f9bf7d7458fa8ceef42f44753acb0" }, "pipfile-spec": 6, "requires": { @@ -82,6 +82,22 @@ "index": "pypi", "version": "==4.6.2" }, + "pytest-django": { + "hashes": [ + "sha256:11a9ab9fceb2f819a0e94ba4eab791f998542f4e29eb36500cb9464dd3b4c3b6", + "sha256:581d699fbe955ba40c2da9c9cd3b49442d95e9d1a3f8c4d13ca5a29332467fea" + ], + "index": "pypi", + "version": "==3.5.0" + }, + "pytest-sugar": { + "hashes": [ + "sha256:26cf8289fe10880cbbc130bd77398c4e6a8b936d8393b116a5c16121d95ab283", + "sha256:fcd87a74b2bce5386d244b49ad60549bfbc4602527797fac167da147983f58ab" + ], + "index": "pypi", + "version": "==0.9.2" + }, "six": { "hashes": [ "sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c", @@ -89,6 +105,12 @@ ], "version": "==1.12.0" }, + "termcolor": { + "hashes": [ + "sha256:1d6d69ce66211143803fbc56652b41d73b4a400a2891d7bf7a1cdf4c02de613b" + ], + "version": "==1.1.0" + }, "wcwidth": { "hashes": [ "sha256:3df37372226d6e63e1b1e1eda15c594bca98a22d33a23832a90998faa96bc65e", From 888ae092f2651585fd513b0346fb0a6b57216f98 Mon Sep 17 00:00:00 2001 From: Justin W. Flory Date: Jun 09 2019 22:41:06 +0000 Subject: [PATCH 3/6] tests: Add pytest options to setup.cfg --- diff --git a/setup.cfg b/setup.cfg index f5a7d59..d793c0b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,3 +1,6 @@ +[tool:pytest] +DJANGO_SETTINGS_MODULE = happinesspackets.settings.tsting + [flake8] exclude=happinesspackets/*/migrations/* ignore=E124,E201,E128,E501 From 22a956ca1647cd002a69d7b63615b261d874e9a7 Mon Sep 17 00:00:00 2001 From: Alisha Mohanty Date: Jun 19 2019 18:54:37 +0000 Subject: [PATCH 4/6] Add pytest as dependency --- diff --git a/requirements/base.txt b/requirements/base.txt index ac66553..678c2ea 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -55,3 +55,7 @@ pyyaml==5.1 # WYSIWYG addition django-ckeditor==5.7.0 +#Testing using pytest +pytest-django==3.5.0 +pytest==4.6.3 +pytest-cov==2.7.1 From 0f6820d62fd7078969cf269c8cb2d2e886d43166 Mon Sep 17 00:00:00 2001 From: Alisha Mohanty Date: Jun 19 2019 20:09:27 +0000 Subject: [PATCH 5/6] Add __pycache__ and .pyc files to .dockerignore --- diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..3dbed02 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +**/*.pyc +**/__pycache__ From fc1a07d0e3fb33023612664cd9c76c4bda589b18 Mon Sep 17 00:00:00 2001 From: Alisha Mohanty Date: Jun 24 2019 20:21:34 +0000 Subject: [PATCH 6/6] Add Test Cases for URLs --- diff --git a/happinesspackets/messaging/tests/test_urls.py b/happinesspackets/messaging/tests/test_urls.py new file mode 100755 index 0000000..fcd35e3 --- /dev/null +++ b/happinesspackets/messaging/tests/test_urls.py @@ -0,0 +1,59 @@ +from django.urls import reverse, resolve + +class TestUrls: + + def test_start_url(self): + path = reverse('messaging:start') + assert resolve(path).view_name == 'messaging:start' + + def test_faq_url(self): + path = reverse('messaging:faq') + assert resolve(path).view_name == 'messaging:faq' + + def test_archive_url(self): + path = reverse('messaging:archive') + assert resolve(path).view_name == 'messaging:archive' + + def test_inspiration_url(self): + path = reverse('messaging:inspiration') + assert resolve(path).view_name == 'messaging:inspiration' + + def test_received_messages_url(self): + path = reverse('messaging:received_messages') + assert resolve(path).view_name == 'messaging:received_messages' + + def test_sent_messages_url(self): + path = reverse('messaging:sent_messages') + assert resolve(path).view_name == 'messaging:sent_messages' + + def test_blacklist_email_url(self): + path = reverse('messaging:blacklist_email', kwargs = {'email':'foobar@gmail.com','digest':'f47850e34f1588b79e5970d409325625264b7d60'}) + assert resolve(path).view_name == 'messaging:blacklist_email' + + def test_send_url(self): + path = reverse('messaging:send') + assert resolve(path).view_name == 'messaging:send' + + def test_sender_confirmation_sent_url(self): + path = reverse('messaging:sender_confirmation_sent') + assert resolve(path).view_name == 'messaging:sender_confirmation_sent' + + def test_sender_confirm_url(self): + path = reverse('messaging:sender_confirm', kwargs = {'identifier':'M4ZK-R88T-BTGC-MTDM', 'token':'M4ZK-R88T-BTGC-MTDM'}) + assert resolve(path).view_name == 'messaging:sender_confirm' + + def test_sender_confirmed_url(self): + path = reverse('messaging:sender_confirmed') + assert resolve(path).view_name == 'messaging:sender_confirmed' + + def test_recipient_message_update_url(self): + path = reverse('messaging:recipient_message_update', kwargs = {'identifier':'M4ZK-R88T-BTGC-MTDM', 'token':'M4ZK-R88T-BTGC-MTDM'}) + assert resolve(path).view_name == 'messaging:recipient_message_update' + + def test_fasid_check_url(self): + path = reverse('messaging:fasid_check') + assert resolve(path).view_name == 'messaging:fasid_check' + + def test_search_url(self): + path = reverse('messaging:search') + assert resolve(path).view_name == 'messaging:search' \ No newline at end of file