From d25f738b034b9d7826a3c7f2de6daecbcd90d93b Mon Sep 17 00:00:00 2001 From: Valentin Samir Date: Mon, 1 Aug 2016 18:29:05 +0200 Subject: [PATCH] Add unit test for utils.dictfetchall --- cas_server/tests/test_utils.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cas_server/tests/test_utils.py b/cas_server/tests/test_utils.py index e46459f..d0199ce 100644 --- a/cas_server/tests/test_utils.py +++ b/cas_server/tests/test_utils.py @@ -11,9 +11,11 @@ # (c) 2016 Valentin Samir """Tests module for utils""" from django.test import TestCase, RequestFactory +from django.db import connection import six import warnings +import datetime from cas_server import utils @@ -237,3 +239,15 @@ class UtilsTestCase(TestCase): # version is cached 24h so calling it a second time should return the save value 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)