Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PyOTRS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coopdevs
Som Connexió
OTRS
PyOTRS
Commits
6fabff83
Commit
6fabff83
authored
8 years ago
by
Robert Habermann
Browse files
Options
Downloads
Patches
Plain Diff
add SessionIDStore Class
parent
b2958cd1
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pyotrs/__init__.py
+1
-0
1 addition, 0 deletions
pyotrs/__init__.py
pyotrs/lib.py
+9
-0
9 additions, 0 deletions
pyotrs/lib.py
tests/test_session_id_store.py
+50
-0
50 additions, 0 deletions
tests/test_session_id_store.py
with
60 additions
and
0 deletions
pyotrs/__init__.py
+
1
−
0
View file @
6fabff83
...
@@ -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.
...
...
This diff is collapsed.
Click to expand it.
pyotrs/lib.py
+
9
−
0
View file @
6fabff83
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
tests/test_session_id_store.py
0 → 100644
+
50
−
0
View file @
6fabff83
# -*- 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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment