Fix broken tests
This commit is contained in:
+6
-4
@@ -1,11 +1,13 @@
|
||||
"""File containing Infoscreen tests."""
|
||||
|
||||
from django.test import TestCase
|
||||
from django.test import TestCase, Client
|
||||
from infoscreen.models import Rotation
|
||||
from infoscreen.models import SossoInfoItem
|
||||
from django.http import HttpRequest
|
||||
import infoscreen.views
|
||||
|
||||
import logging
|
||||
|
||||
|
||||
class InfoscreenTestCase(TestCase):
|
||||
"""Test cases for testing infoscreen methods."""
|
||||
@@ -14,6 +16,7 @@ class InfoscreenTestCase(TestCase):
|
||||
"""Create some dummy models."""
|
||||
Rotation.objects.create(name="test_rot")
|
||||
SossoInfoItem.objects.create()
|
||||
self.c = Client()
|
||||
|
||||
def test_rotation_created(self):
|
||||
"""Check if the dummy model actually exists."""
|
||||
@@ -32,7 +35,6 @@ class InfoscreenTestCase(TestCase):
|
||||
That would mean that something meaningful has been included
|
||||
in the response.
|
||||
"""
|
||||
req = HttpRequest()
|
||||
resp = infoscreen.views.info_items(req)
|
||||
content = resp.content.decode('utf-8')
|
||||
resp = self.c.get('/infoscreen/items')
|
||||
content = resp.json()
|
||||
self.assertTrue(len(content) > 0)
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
from django.shortcuts import render
|
||||
from django.http import HttpResponse, HttpResponseBadRequest
|
||||
from django.http import HttpResponse, JsonResponse, HttpResponseBadRequest
|
||||
from django.views.decorators.http import require_http_methods
|
||||
|
||||
from infoscreen.models import Rotation, InfoItem, InfoInstance
|
||||
from infoscreen.hsl_fetcher import HSLFetcher
|
||||
|
||||
import json
|
||||
import logging
|
||||
|
||||
|
||||
@require_http_methods(["GET"])
|
||||
@@ -72,7 +73,8 @@ def info_items(request, *args, **kwargs):
|
||||
for c in classes:
|
||||
for i in c.objects.all():
|
||||
items.append(i.get_dict())
|
||||
return HttpResponse(json.dumps(items))
|
||||
|
||||
return JsonResponse(items, safe=False)
|
||||
|
||||
|
||||
@require_http_methods(["GET"])
|
||||
|
||||
@@ -206,7 +206,6 @@ def member_edit(request, *args, **kwargs):
|
||||
|
||||
class MemberAutoComplete(autocomplete.Select2QuerySetView):
|
||||
|
||||
@method_decorator(login_required(login_url='/login'))
|
||||
def get_queryset(self):
|
||||
qs = Member.objects.all()
|
||||
|
||||
|
||||
@@ -251,6 +251,9 @@ STATICFILES_DIRS = (
|
||||
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
|
||||
MEDIA_URL = '/media/'
|
||||
|
||||
LOGIN_URL = '/login/'
|
||||
LOGIN_REDIRECT_URL = '/admin'
|
||||
|
||||
SUIT_CONFIG = {
|
||||
# header
|
||||
'ADMIN_NAME': 'SIK Admin',
|
||||
|
||||
Reference in New Issue
Block a user