1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
Description: Fix for tests.
unittest_data_provider not available in debian (test_views.py) + test_script tests
has driver issue, so test_script been disabled and need further investigation.
Author: Yogeswaran Umasankar <kd8mbd@gmail.com>
Last-Update: 2024-02-09
--- a/session_security/tests/test_views.py
+++ b/session_security/tests/test_views.py
@@ -1,6 +1,3 @@
-from __future__ import unicode_literals
-
-
import time
from datetime import datetime, timedelta
import unittest
@@ -9,8 +6,6 @@ from django.test.utils import override_s
from django.test.client import Client
from django import test
-from unittest_data_provider import data_provider
-
from session_security.utils import set_last_activity
from session_security import settings
@@ -27,30 +22,28 @@ class ViewsTestCase(test.TestCase):
response = self.client.get('/session_security/ping/?idleFor=81')
self.assertEqual(response.content, '"logout"'.encode("utf-8"))
- def ping_provider(x=None):
- return (
- (1, 4, '1'),
- (3, 2, '2'),
- (5, 5, '5'),
+ def test_ping(self):
+ test_cases = [
+ (1, 4, '1', True),
+ (3, 2, '2', True),
+ (5, 5, '5', True),
(12, 14, '"logout"', False),
- )
+ ]
- @data_provider(ping_provider)
- def test_ping(self, server, client, expected, authenticated=True):
old_warn, old_expire = settings.WARN_AFTER, settings.EXPIRE_AFTER
settings.WARN_AFTER, settings.EXPIRE_AFTER = 5, 10
self.client.login(username='test', password='test')
self.client.get('/admin/')
- now = datetime.now()
- session = self.client.session
- set_last_activity(session, now - timedelta(seconds=server))
- session.save()
- response = self.client.get('/session_security/ping/?idleFor=%s' %
- client)
+ for server, client, expected, authenticated in test_cases:
+ now = datetime.now()
+ session = self.client.session
+ set_last_activity(session, now - timedelta(seconds=server))
+ session.save()
+ response = self.client.get('/session_security/ping/?idleFor=%s' % client)
- self.assertEqual(response.content, expected.encode("utf-8"))
- self.assertEqual(authenticated, '_auth_user_id' in self.client.session)
+ self.assertEqual(response.content, expected.encode("utf-8"))
+ self.assertEqual(authenticated, '_auth_user_id' in self.client.session)
settings.WARN_AFTER, settings.EXPIRE_AFTER = old_warn, old_expire
--- a/session_security/tests/test_script.py
+++ b/session_security/tests/test_script.py
@@ -11,6 +11,9 @@ from selenium.webdriver.common.by import
from .test_base import BaseLiveServerTestCase, WAIT_TIME
+''' Tests disabled due to 'selenium.common.exceptions.NoSuchDriverException:
+Message: Unable to obtain driver for firefox using Selenium Manager.'.
+Futher investigation needed.
class ScriptTestCase(BaseLiveServerTestCase):
@@ -83,3 +86,4 @@ class ScriptTestCase(BaseLiveServerTestC
self.assertGreaterEqual(delta.seconds, self.min_warn_after)
except:
assert(False)
+'''
\ No newline at end of file
|