def test_create_003(self): """Success Case for 'audiobook' audio type""" dummy_data = self.json_parameters_template.copy() dummy_data['audioFileType'] = 'audiobook' request = self.client.post( path='/server/create/', data=json.dumps(dummy_data), content_type='application/json').wsgi_request response = CreateAudioResource.as_view()(request) self.assertEqual(response.status_code, 200)
def test_delete_002(self): """Success Case delete Audio Resource Info with incorrect audioFileID""" data = self.fixtures_data.copy() request = self.client.post( "/server/create/", data=data, content_type="application/json").wsgi_request response = CreateAudioResource.as_view()(request) if self.assertEqual(response.status_code, 200): request = self.client.get("/server/delete/song/2/", ).wsgi_request response = DeleteAudioResource.as_view()(request) self.assertEqual(response.status_code, 400)
def test_create_009(self): """Missing Parameter(s): Case 'audioFileMetadata' for 'podcast' audio type""" dummy_data = self.json_parameters_template.copy() dummy_data['audioFileType'] = 'podcast' del (dummy_data['audioFileMetadata']) request = self.client.post( path='/server/create/', data=json.dumps(dummy_data), content_type='application/json').wsgi_request response = CreateAudioResource.as_view()(request) self.assertEqual(response.status_code, 400)
def test_update_002(self): """Failure case(incorrect audio file id) for "song" audio file type""" dummy_data = self.fixtures_data.copy() request = self.client.post( "/server/create/", data=json.dumps(dummy_data), content_type="application/json").wsgi_request response = CreateAudioResource.as_view()(request) if self.assertEqual(response.status_code, 200): request = self.client.post("/server/update/song/2/", data=json.dumps(dummy_data), content_type="application/json") response = UpdateAudioResource.as_view()(request) self.assertEqual(response.status_code, 400)
def test_update_008(self): """Success case for "audiobook" audio file type""" dummy_data = self.fixtures_data.copy() request = self.client.post( "/server/create/", data=json.dumps(dummy_data), content_type="application/json").wsgi_request response = CreateAudioResource.as_view()(request) if self.assertEqual(response.status_code, 200): request = self.client.post("/server/update/audiobook/1/", data=json.dumps(dummy_data), content_type="application/json") response = UpdateAudioResource.as_view()(request) self.assertEqual(response.status_code, 200)
def test_delete_005(self): """Success Case delete Audio Resource Info with correct audioFileID""" data = self.fixtures_data.copy() data['audioFileType'] = "audiobook" request = self.client.post( "/server/create/", data=data, content_type="application/json" ).wsgi_request response = CreateAudioResource.as_view()(request) if self.assertEqual(response.status_code, 200): request = self.client.get( "/server/get/audiobook/1/", ).wsgi_request response = GetAudioResource.as_view()(request) self.assertEqual(response.status_code, 200)
def test_create_020(self): """Missing Parameter(s): Case 'duration' for 'audiobook' audio type""" dummy_data = dummy_data = { "audioFileType": "audiobook", "audioFileMetadata": { "duration": 500, "title": "test_audiobook", "author": "test_author", }, } request = self.client.post( path='/server/create/', data=json.dumps(dummy_data), content_type='application/json').wsgi_request response = CreateAudioResource.as_view()(request) self.assertEqual(response.status_code, 400)
def test_create_013(self): """Missing Parameter(s): Case 'duration' for 'podcast' audio type""" dummy_data = dummy_data = { "audioFileType": "podcast", "audioFileMetadata": { "name": "podcast", "duration": 500, "participants": [ "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten" ] }, } request = self.client.post( path='/server/create/', data=json.dumps(dummy_data), content_type='application/json').wsgi_request response = CreateAudioResource.as_view()(request) self.assertEqual(response.status_code, 400)
The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/2.2/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: path('', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') Including another URLconf 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from server.views import CreateAudioResource, DeleteAudioResource, GetAudioResource, UpdateAudioResource from django.urls import path from django.conf.urls import url urlpatterns = [ path('create/', CreateAudioResource.as_view(), name="create"), url(r'^update/(?P<audioFileType>[a-z]+)/(?P<audioFileID>\d+)/$', UpdateAudioResource.as_view(), name="update"), url(r'^get/(?P<audioFileType>[a-z]+)/(?P<audioFileID>\d*)/*$', GetAudioResource.as_view(), name="get"), # url(r'^get/(?P<audioFileType>[a-z]+)/$', GetAudioResource.as_view(), name="get"), url(r'^delete/(?P<audioFileType>[a-z]+)/(?P<audioFileID>\d+)/$', DeleteAudioResource.as_view(), name="delete") ]