Skip to content
Snippets Groups Projects
Commit 6fabff83 authored by Robert Habermann's avatar Robert Habermann
Browse files

add SessionIDStore Class

parent b2958cd1
No related branches found
No related tags found
No related merge requests found
...@@ -14,6 +14,7 @@ from .lib import Article # noqa ...@@ -14,6 +14,7 @@ from .lib import Article # noqa
from .lib import Attachment # noqa from .lib import Attachment # noqa
from .lib import Client # noqa from .lib import Client # noqa
from .lib import DynamicField # noqa from .lib import DynamicField # noqa
from .lib import SessionIDStore # noqa
from .lib import Ticket # noqa from .lib import Ticket # noqa
# Set default logging handler to avoid "No handler found" warnings. # Set default logging handler to avoid "No handler found" warnings.
......
...@@ -459,6 +459,15 @@ class Ticket(object): ...@@ -459,6 +459,15 @@ class Ticket(object):
} }
class SessionIDStore(object):
"""Session ID: persistently store to and retrieve from to file"""
def __init__(self, file_path=None):
self.file_path = file_path
def __repr__(self):
return "<{0}>".format(self.__class__.__name__)
class Client(object): class Client(object):
"""PyOTRS Client class - includes Session handling """PyOTRS Client class - includes Session handling
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals # support both Python2 and 3
#
# Name: test_session_id_store.py
# Description: Test for PyOTRS Client class
#
# Author: robert.habermann@dlh.de
# Date: 2016-04-23
# make sure (early) that parent dir (main app) is in path
import unittest2 as unittest
import mock
from pyotrs import SessionIDStore
class SessionIDStoreTests(unittest.TestCase):
def test_init(self):
sis = SessionIDStore()
self.assertIsInstance(sis, SessionIDStore)
#
# def test_session_check_is_valid_no_session_id_error(self):
# """Test"""
# client = Client(baseurl="http://localhost/", webservicename="foo")
# self.assertRaisesRegex(SessionError,
# 'No value set for session_id!',
# client.session_check_is_valid)
#
# @mock.patch('pyotrs.Client._ticket_get_json', autospec=True)
# def test_session_check_is_valid_session_id(self, mock_ticket_get_json):
# """Test session_check_is_valid with a given session id"""
# obj = Client(baseurl="http://localhost/", webservicename="foo")
# obj.session_id = "some_other_value"
# mock_ticket_get_json.return_value = True
#
# result = obj.session_check_is_valid(session_id="some_value")
#
# self.assertEqual(obj.session_id, "some_value")
# self.assertEqual(result, True)
def main():
unittest.main()
if __name__ == '__main__':
main()
# EOF
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment