#249 Add Test Cases for URLs
Closed 4 years ago by alishapapun. Opened 4 years ago by alishapapun.
fedora-commops/ alishapapun/fedora-happiness-packets add/pytest-migrations  into  master

file added
+2
@@ -0,0 +1,2 @@ 

+ **/*.pyc

+ **/__pycache__

file modified
+2
@@ -5,6 +5,8 @@ 

  

  [dev-packages]

  pytest = "*"

+ pytest-django = "*"

+ pytest-sugar = "*"

  

  [packages]

  

file modified
+23 -1
@@ -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",

file removed
-36
@@ -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"

@@ -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

file modified
+4
@@ -55,3 +55,7 @@ 

  # WYSIWYG addition

  django-ckeditor==5.7.0

  

+ #Testing using pytest

+ pytest-django==3.5.0

+ pytest==4.6.3

+ pytest-cov==2.7.1

file removed
-21
@@ -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

- 

- 

- 

file modified
+3
@@ -1,3 +1,6 @@ 

+ [tool:pytest]

+ DJANGO_SETTINGS_MODULE = happinesspackets.settings.tsting

+ 

  [flake8]

  exclude=happinesspackets/*/migrations/*

  ignore=E124,E201,E128,E501

t
file removed
-2
@@ -1,2 +0,0 @@ 

- export DJANGO_SETTINGS_MODULE=happinesspackets.settings.tsting &&

- coverage report --fail-under=100

This PR addresses 3 issues:
1. Adding dependency pytest, pytest-Django and pytest-cov to requirements.
2. Adding a .dockerignore
- While running test cases, pycache was getting created thus failing docker to get build.
- So, pycache was added to .dockerignore
3. Adding Test Cases for the urls.

This is for the first time I am writing test-case. Do lemme know @jflory7 if I did any mistake.

Pull-Request has been closed by alishapapun

4 years ago