Skip to content

Commit

Permalink
Module: auth_session_timeout: Fixed flake8 lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jmorgannz committed Jul 11, 2017
1 parent 8536373 commit be755ce
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
3 changes: 2 additions & 1 deletion auth_session_timeout/__openerp__.py
Expand Up @@ -9,7 +9,8 @@
'summary': """
This module disable all inactive sessions since a given delay""",

'author': "ACSONE SA/NV, Dhinesh D, Jesse Morgan, Odoo Community Association (OCA)",
'author': "ACSONE SA/NV, Dhinesh D, Jesse Morgan, \
Odoo Community Association (OCA)",
'maintainer': 'Odoo Community Association (OCA)',
'website': "http://acsone.eu",

Expand Down
3 changes: 2 additions & 1 deletion auth_session_timeout/tests/test_ir_config_parameter.py
Expand Up @@ -13,7 +13,8 @@ def setUp(self):
self.db = self.env.cr.dbname
self.param_obj = self.env['ir.config_parameter']
self.data_obj = self.env['ir.model.data']
self.delay = self.env.ref('auth_session_timeout.inactive_session_time_out_delay')
self.delay = self.env.ref(
'auth_session_timeout.inactive_session_time_out_delay')

def test_check_session_params(self):
delay, urls = self.param_obj.get_session_parameters(self.db)
Expand Down
29 changes: 15 additions & 14 deletions auth_session_timeout/tests/test_res_user.py
Expand Up @@ -2,21 +2,23 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

import mock
import os
import errno
from os import strerror
from errno import ENOENT

from openerp.tests import common

_packagepath = 'openerp.addons.auth_session_timeout'

class ResUsers(common.TransactionCase):
def setUp(self):
super(ResUsers, self).setUp()
self.resusers_obj = self.env['res.users']

@mock.patch('openerp.addons.auth_session_timeout.models.res_users.request')
@mock.patch('openerp.addons.auth_session_timeout.models.res_users.root')
@mock.patch('openerp.addons.auth_session_timeout.models.res_users.getmtime')
def test_check_timedout_session_loggedout(self, mock_getmtime, mock_root, mock_request):
@mock.patch(_packagepath + '.models.res_users.request')
@mock.patch(_packagepath + '.models.res_users.root')
@mock.patch(_packagepath + '.models.res_users.getmtime')
def test_check_timedout_session_loggedout(
self, mock_getmtime, mock_root, mock_request):
mock_getmtime.return_value = 0
mock_request.session.uid = self.env.uid
mock_request.session.dbname = self.env.cr.dbname
Expand All @@ -25,15 +27,14 @@ def test_check_timedout_session_loggedout(self, mock_getmtime, mock_root, mock_r
self.resusers_obj._auth_timeout_check()
self.assertTrue(mock_request.session.logout.called)

@mock.patch('openerp.addons.auth_session_timeout.models.res_users.request')
@mock.patch('openerp.addons.auth_session_timeout.models.res_users.root')
@mock.patch('openerp.addons.auth_session_timeout.models.res_users.getmtime')
@mock.patch('openerp.addons.auth_session_timeout.models.res_users.utime')
def test_check_sessionfile_time_readwrite_exception(self, mock_utime, mock_getmtime, mock_root, mock_request):
mock_getmtime.side_effect = OSError(errno.ENOENT, os.strerror(errno.ENOENT), 'non-existent-filename')
@mock.patch(_packagepath + '.models.res_users.request')
@mock.patch(_packagepath + '.models.res_users.root')
@mock.patch(_packagepath + '.models.res_users.getmtime')
@mock.patch(_packagepath + '.models.res_users.utime')
def test_check_sessionfile_time_readwrite_exception(
self, mock_utime, mock_getmtime, mock_root, mock_request):
mock_getmtime.side_effect = OSError(ENOENT, strerror(ENOENT), 'non-existent-filename')
mock_request.session.uid = self.env.uid
mock_request.session.dbname = self.env.cr.dbname
mock_request.session.sid = 123
self.resusers_obj._auth_timeout_check()


0 comments on commit be755ce

Please sign in to comment.