Skip to content

Commit

Permalink
bug testing
Browse files Browse the repository at this point in the history
  • Loading branch information
ameek committed Aug 2, 2018
1 parent 6e09572 commit 781fb9f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
12 changes: 7 additions & 5 deletions medicine_reminder/api/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@ def test_model_can_create_a_bucketlist(self):
self.assertNotEqual(old_count, new_count)

class ViewTestCase(TestCase):
"""Test suite for the api views."""

def setUp(self):
"define the tet client and other test variables"
"""Define the test client and other test variables."""
self.client = APIClient()
self.bucketlist_data = {'name': "Go to Ibiza"}
self.bucketlist_data = {'name': 'Go to Ibiza'}
self.response = self.client.post(
reverse('create'),
self.bucketlist_data
format="Json"
)
self.bucketlist_data,
format="json")

def test_api_can_create_a_bucketlist(self):
"""Test the api has bucket creation capability."""
self.assertEqual(self.response.status_code, status.HTTP_201_CREATED)
4 changes: 3 additions & 1 deletion medicine_reminder/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from rest_framework.urlpatterns import format_suffix_patterns
from .views import CreateView

urlpatterns = {url(r'^bucketlists/$',CreateView.as_view(), name="create"),
urlpatterns = {
url(r'^bucketlists/$', CreateView.as_view(), name="create"),
}

urlpatterns = format_suffix_patterns(urlpatterns)
9 changes: 4 additions & 5 deletions medicine_reminder/api/views.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#from django.shortcuts import render

from rest_framework import generics
from .serializers import BucketlistSerializer
from .models import Bucketlist

# Create your views here.
Class CreateView(generics.ListCreateAPIView):
class CreateView(generics.ListCreateAPIView):
"""This class defines the create behavior of our rest api."""
queryset = Bucketlist.objects.all()
serializer_class = BucketlistSerializer

def perform_create(self, serializers):
def perform_create(self, serializer):
"""Save the post data when creating a new bucketlist."""
serializer.save()
Binary file not shown.
2 changes: 1 addition & 1 deletion medicine_reminder/medicine_reminder/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
# from django.contrib import admin
from django.contrib import admin
# from django.urls import path

# urlpatterns = [
Expand Down

0 comments on commit 781fb9f

Please sign in to comment.