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