def test_view_event_list_all(self): request = self.request_factory.get(reverse('events_list')) request.user = self.user1 response = EventList.as_view()(request, *[], **{}) self.assertEqual(response.status_code, HTTP_OK) self.assertInHTML(self.organised_event.title, response.content.decode()) self.assertInHTML(self.attending_event.title, response.content.decode())
from django.urls import path, include from events.views import EventList urlpatterns = [ path('events', EventList.as_view()), # path('events/<int:pk>/', my_view) ]
from django.conf.urls import patterns, url from comments.views import SortByLikesView, PostCommentView from events.views import EventList, PublishEventView, EventDetailView, AddAssistantView, RemoveAssistantView, \ EventSuggestedView urlpatterns = patterns('', url(r'^$', EventList.as_view(), name='list'), url(r'^suggested/$', EventSuggestedView.as_view(), name='suggested'), url(r'^add/$', PublishEventView.as_view(), name='add'), url(r'^assist/(?P<event_id>\w+)/$', AddAssistantView.as_view(), name='assist'), url(r'^not_assist/(?P<event_id>\w+)/$', RemoveAssistantView.as_view(), name='not_assist'), url(r'^detail/(?P<event_id>\w+)/$', EventDetailView.as_view(), name='detail'), url(r'^detail/(?P<event_id>\w+)/comments/$', PostCommentView.as_view(), name='post_comment'), url(r'^detail/(?P<event_id>\w+)/comments/(?P<comment_id>\w+)/$', PostCommentView.as_view(), name='post_reply'), url(r'^detail/(?P<event_id>\w+)/comments/sorted$', SortByLikesView.as_view(), name='sort_likes'), )
def test_event_person_create(self): request = self.factory.post('/events/category/', {'title': '@test'}) view = EventList.as_view() response = view(request) self.assertEqual(response.status_code, 201)
def test_event_category_get(self): request = self.factory.get('/events/category/') view = EventList.as_view() response = view(request) self.assertEqual(response.status_code, 200)
def test_event_detail_put(self): request = self.factory.put('events/112/', {'title': 'Testing #api with @put'}) view = EventList.as_view() response = view(request) self.assertEqual(response.status_code, 405)
def test_event_detail_create(self): request = self.factory.post('/events/1/', {'title': 'Testing #api with @test'}) view = EventList.as_view() response = view(request) self.assertEqual(response.status_code, 201)
def test_view_event_list_not_authenticated(self): request = self.request_factory.get(reverse('events_list')) request.user = AnonymousUser() response = EventList.as_view()(request, *[], **{}) self.assertEqual(response.status_code, HTTP_REDIRECT) self.assertIn('login', response.url)
def test_event_time_post(self): request = self.factory.post('/events/time/2015/1/1', {'title': '@time with #time'}) view = EventList.as_view() response = view(request) self.assertEqual(response.status_code, 201)
from django.urls import include, path from events.views import (EventChangeWeight, EventCreate, EventDelete, EventDownloadXlsx, EventFinish, EventList, EventManageUsers, EventRemoveUser, EventSelfRegistration, EventUpdate, EventUploadXlsx) events_patterns = [ path( 'events/', include([ path('', EventList.as_view(), name='url_event_list'), path('create/', EventCreate.as_view(), name='url_event_create'), path( '<int:pk>/', include([ path('update/', EventUpdate.as_view(), name='url_event_update'), path('finish/', EventFinish.as_view(), name='url_event_finish'), path('delete/', EventDelete.as_view(), name='url_event_delete'), path('self_registration/', EventSelfRegistration.as_view(), name='url_event_self_registration'), path('users/', EventManageUsers.as_view(), name='url_event_manage_users'),
from django.conf.urls import patterns, url from events.views import EventList urlpatterns = patterns( '', url( regex='^$', view=EventList.as_view(), name='events-list', ), )
def test_view_event_list_page_empty(self): request = self.request_factory.get(reverse('events_list'), data={'page': 999, 'filter': 'a'}) request.user = self.user1 response = EventList.as_view()(request, *[], **{}) self.assertEqual(response.status_code, HTTP_OK) self.assertInHTML(self.attending_event.title, response.content.decode())
def test_view_event_list_past(self): request = self.request_factory.get(reverse('events_list'), data={'filter': 'p'}) request.user = self.user1 response = EventList.as_view()(request, *[], **{}) self.assertEqual(response.status_code, HTTP_OK) self.assertInHTML(self.expired_event.title, response.content.decode())
from django.urls import path from events.views import EventList, EventDetail, EventView urlpatterns = [ path('add/', EventView.as_view(), name='event_add'), path('edit/<int:pk>', EventView.as_view(), name='event_edit'), path('list/', EventList.as_view(template_name='event_list.html'), name='event_list'), path('<slug:slug>', EventDetail.as_view(), name='event_detail'), ]
def test_event_time_get(self): request = self.factory.get('/events/time/2015/1/1') view = EventList.as_view() response = view(request) self.assertEqual(response.status_code, 200)
from django.urls import path, include from events.views import EventList, EventDetail, AllEventsGuests, EventGuests urlpatterns = [ path("events", EventList.as_view()), path("events/<int:pk>", EventDetail.as_view()), path("events/guests", AllEventsGuests.as_view()), path("events/<int:pk>/guests", EventGuests.as_view()), # path('events/<int:pk>/', my_view) ]
from django.conf.urls import patterns, url from events.views import EventList rest_patterns = patterns( '', url(r'(?P<interview_id>[0-9]+)/events/?$', EventList.as_view(), name='event-list')) urlpatterns = rest_patterns