This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
from django.conf import settings
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.urls import reverse
|
||||
|
||||
from dav_base.tests.generic import Url, UrlsTestCase
|
||||
from .generic import EventMixin
|
||||
|
||||
from .. import views
|
||||
|
||||
url_prefix = settings.MODULE_CONFIG.modules['dav_events'].url_prefix
|
||||
|
||||
|
||||
class TestCase(UrlsTestCase):
|
||||
class TestCase(EventMixin, UrlsTestCase):
|
||||
urls = (
|
||||
Url('/{}/home'.format(url_prefix), 'dav_events:root', views.base.HomeView.as_view()),
|
||||
Url('/{}/'.format(url_prefix), 'dav_events:list', views.events.EventListView.as_view(),
|
||||
@@ -16,3 +19,38 @@ class TestCase(UrlsTestCase):
|
||||
redirect='/auth/login?next=/{}/export'.format(url_prefix)),
|
||||
Url('/{}/create'.format(url_prefix), 'dav_events:create', views.events.EventCreateView.as_view()),
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
self.event = self.create_event_by_model()
|
||||
model = get_user_model()
|
||||
self.username = 'root'
|
||||
self.password = 'mellon'
|
||||
self.user = model.objects.create_superuser(username=self.username, password=self.password,
|
||||
email='root@localhost')
|
||||
|
||||
def test_registrations(self):
|
||||
pk = self.event.pk
|
||||
expected_location = '/{}/{}/registrations'.format(url_prefix, pk)
|
||||
location = reverse('dav_events:registrations', kwargs={'pk': pk})
|
||||
self.assertEqual(location, expected_location)
|
||||
self.client.login(username=self.username, password=self.password)
|
||||
response = self.client.get(location)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_update(self):
|
||||
pk = self.event.pk
|
||||
expected_location = '/{}/{}/edit'.format(url_prefix, pk)
|
||||
location = reverse('dav_events:update', kwargs={'pk': pk})
|
||||
self.assertEqual(location, expected_location)
|
||||
self.client.login(username=self.username, password=self.password)
|
||||
response = self.client.get(location)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_detail(self):
|
||||
pk = self.event.pk
|
||||
expected_location = '/{}/{}/'.format(url_prefix, pk)
|
||||
location = reverse('dav_events:detail', kwargs={'pk': pk})
|
||||
self.assertEqual(location, expected_location)
|
||||
self.client.login(username=self.username, password=self.password)
|
||||
response = self.client.get(location)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
Reference in New Issue
Block a user