Skip to content

Commit

Permalink
Merge branch 'ch-setup-travis-165273464' of https://github.com/andela…
Browse files Browse the repository at this point in the history
…/ah-backend-invictus into ch-setup-travis-165273464

ch(setup travis): To enable CI of tests through TDD

Add travis.yml file
Add pytest.ini to setup pytest setting
Update the requirements.txt file
Add a badge to the readme file
Add tests to test for a user signup
Add a name in the authentication url
Modify travis file to run the tests
Add .coveragerc file to omit some unnecessary file
[Starts #165273464]
  • Loading branch information
engjames committed Apr 23, 2019
2 parents 6e2a2ba + 0c2a27e commit fc12e11
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 3 deletions.
16 changes: 16 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[report]
omit =
*/python?.?/*
*/site-packages/nose/*
*/__pycache__/*
*.pyc
*/venv/*
*/home/travis/virtualenv/*
*/usr/lib/python3/*
*/__init__.py
*settings/*
*/settings.py
*migrations/*
*/manage.py
*/urls/*
*/urls.py
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: python
python:
- "3.6.0"
- "3.6"

services:
- postgresql
Expand All @@ -15,7 +15,7 @@ install:
script:
- python manage.py makemigrations
- python manage.py migrate
- py.test
- python manage.py test

after_success:
- coveralls
Empty file.
30 changes: 30 additions & 0 deletions authors/apps/authentication/tests/test_signup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""imports relevant to our tests."""
import pytest
from django.urls import reverse
from rest_framework import status
from rest_framework.test import APITestCase, APIClient


class USERAPITESTCASE(APITestCase):
"""class USERAPI inherits from the APITESTCASE."""

def setUp(self):
# Initialize client
self.client = APIClient()


class UserSignUp(USERAPITESTCASE):
"""Test user signup."""

@pytest.mark.django_db
def test_user_signup(self):
url = reverse('signup')
data = {
"user": {
"username": "james",
"email": "james@gmail.com",
"password": "12345678"
}
}
response = self.client.post(url, data, format="json")
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
2 changes: 1 addition & 1 deletion authors/apps/authentication/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

urlpatterns = [
path('user/', UserRetrieveUpdateAPIView.as_view()),
path('users/', RegistrationAPIView.as_view()),
path('users/', RegistrationAPIView.as_view(), name="signup"),
path('users/login/', LoginAPIView.as_view()),
]

0 comments on commit fc12e11

Please sign in to comment.