Skip to content

Commit

Permalink
Merge 994bd28 into 2100c25
Browse files Browse the repository at this point in the history
  • Loading branch information
engjames committed Apr 24, 2019
2 parents 2100c25 + 994bd28 commit f284970
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 1 deletion.
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
21 changes: 21 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
language: python
python:
- "3.6"

services:
- postgresql

install:
- pip install -r requirements.txt

before_script:
- psql -c 'create database travis_ci_test;' -U postgres
- python manage.py makemigrations
- python manage.py migrate

script:
- coverage run --source='authors/apps' manage.py test && coverage report

after_success:
- coveralls

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Authors Haven - A Social platform for the creative at heart.
=======
[![Build Status](https://travis-ci.com/andela/ah-backend-invictus.svg?branch=develop)](https://travis-ci.com/andela/ah-backend-invictus)

## Vision
Create a community of like minded authors to foster inspiration and innovation
Expand Down
35 changes: 35 additions & 0 deletions authors/apps/authentication/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Generated by Django 2.1 on 2019-04-23 17:16

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
('auth', '0009_alter_user_last_name_max_length'),
]

operations = [
migrations.CreateModel(
name='User',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('password', models.CharField(max_length=128, verbose_name='password')),
('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
('username', models.CharField(db_index=True, max_length=255, unique=True)),
('email', models.EmailField(db_index=True, max_length=254, unique=True)),
('is_active', models.BooleanField(default=True)),
('is_staff', models.BooleanField(default=False)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')),
('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')),
],
options={
'abstract': False,
},
),
]
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()),
]
4 changes: 4 additions & 0 deletions authors/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@

STATIC_URL = '/static/'

DJANGO_SETTINGS_MODULE = [

]

CORS_ORIGIN_WHITELIST = (
'0.0.0.0:4000',
'localhost:4000',
Expand Down
3 changes: 3 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[pytest]
DJANGO_SETTINGS_MODULE=authors.settings
addopts = --cov=. --cov-report term-missing
15 changes: 15 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
atomicwrites==1.3.0
attrs==19.1.0
certifi==2019.3.9
chardet==3.0.4
coverage==4.5.3
coveralls==1.7.0
Django==2.1
django-cors-middleware==1.3.1
django-extensions==2.1.6
djangorestframework==3.9.2
docopt==0.6.2
idna==2.8
more-itertools==7.0.0
pluggy==0.9.0
py==1.8.0
PyJWT==1.7.1
pytest==4.4.1
pytest-cov==2.6.1
pytz==2019.1
requests==2.21.0
six==1.12.0
urllib3==1.24.2

0 comments on commit f284970

Please sign in to comment.