Commit d25f738b authored by Valentin Samir's avatar Valentin Samir

Add unit test for utils.dictfetchall

parent c6583c92
...@@ -11,9 +11,11 @@ ...@@ -11,9 +11,11 @@
# (c) 2016 Valentin Samir # (c) 2016 Valentin Samir
"""Tests module for utils""" """Tests module for utils"""
from django.test import TestCase, RequestFactory from django.test import TestCase, RequestFactory
from django.db import connection
import six import six
import warnings import warnings
import datetime
from cas_server import utils from cas_server import utils
...@@ -237,3 +239,15 @@ class UtilsTestCase(TestCase): ...@@ -237,3 +239,15 @@ class UtilsTestCase(TestCase):
# version is cached 24h so calling it a second time should return the save value # version is cached 24h so calling it a second time should return the save value
self.assertEqual(version, utils.last_version()) self.assertEqual(version, utils.last_version())
def test_dictfetchall(self):
"""test the function dictfetchall"""
with connection.cursor() as curs:
curs.execute("SELECT * FROM django_migrations")
results = utils.dictfetchall(curs)
self.assertIsInstance(results, list)
self.assertTrue(len(results) > 0)
for result in results:
self.assertIsInstance(result, dict)
self.assertIn('applied', result)
self.assertIsInstance(result['applied'], datetime.datetime)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment