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
afa29ace
Commit
afa29ace
authored
8 years ago
by
Robert Habermann
Browse files
Options
Downloads
Patches
Plain Diff
extend tests
parent
16af6a7d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pyotrs/lib.py
+11
-1
11 additions, 1 deletion
pyotrs/lib.py
tests/test_client.py
+41
-1
41 additions, 1 deletion
tests/test_client.py
with
52 additions
and
2 deletions
pyotrs/lib.py
+
11
−
1
View file @
afa29ace
...
...
@@ -491,7 +491,7 @@ class Client(object):
self
.
session_timeout
=
28800
# 8 hours is OTRS default
else
:
self
.
session_timeout
=
session_timeout
self
.
https_verify
=
https_verify
# dummy initialization
...
...
@@ -568,6 +568,8 @@ class Client(object):
# TODO 2016-04-18 (RH): decide what to return here.. bool or result content?
if
self
.
_session_create_json
(
url
,
payload
):
return
self
.
response_json
else
:
return
None
def
session_restore_or_set_up_new
(
self
):
"""
Try to restore Session ID from file otherwise create new one
...
...
@@ -727,6 +729,8 @@ class Client(object):
# TODO 2016-04-18(RH): decide what to return here.. bool or result content? Or full new?
if
self
.
_ticket_create_json
(
url
,
payload
):
return
self
.
response_json
else
:
return
None
def
_ticket_create_json
(
self
,
url
,
payload
):
"""
_ticket_create_json
...
...
@@ -785,6 +789,8 @@ class Client(object):
# TODO 2016-04-13 (RH): decide what to return here.. bool or ticket content
if
self
.
_ticket_get_json
(
url
,
payload
):
return
self
.
response_json
[
'
Ticket
'
][
0
]
else
:
return
None
def
ticket_get_by_number
(
self
,
ticket_number
,
dynamic_fields
=
True
,
all_articles
=
False
):
"""
ticket_get_by_number
...
...
@@ -986,6 +992,8 @@ class Client(object):
# TODO 2016-04-17 (RH): decide what to return here.. bool or result content? Or full new?
if
self
.
_ticket_update_json
(
url
,
payload
):
return
self
.
response_json
else
:
return
None
def
ticket_update_set_pending
(
self
,
ticket_id
,
...
...
@@ -1023,6 +1031,8 @@ class Client(object):
# TODO 2016-04-17 (RH): decide what to return here.. bool or result content? Or full new?
if
self
.
_ticket_update_json
(
url
,
payload
):
return
"
Set pending till {0} with state
\"
{1}
\"
"
.
format
(
pending_till_str
,
new_state
)
else
:
return
None
def
_ticket_update_json
(
self
,
url
,
payload
):
"""
_ticket_update_json
...
...
This diff is collapsed.
Click to expand it.
tests/test_client.py
+
41
−
1
View file @
afa29ace
...
...
@@ -16,9 +16,10 @@ from pyotrs import Client
from
pyotrs.lib
import
NoBaseURL
,
NoWebServiceName
,
ResponseJSONParseError
from
pyotrs.lib
import
SessionError
from
pyotrs
import
Client
,
Ticket
# noqa
from
pyotrs
import
Article
,
Client
,
Ticket
# noqa
from
pyotrs.lib
import
NoBaseURL
,
NoWebServiceName
,
NoCredentials
# noqa
from
pyotrs.lib
import
SessionCreateError
,
SessionIDFileError
,
OTRSAPIError
,
OTRSHTTPError
# noqa
from
pyotrs.lib
import
TicketError
# noqa
class
ClientTests
(
unittest
.
TestCase
):
...
...
@@ -305,6 +306,7 @@ class ClientTests(unittest.TestCase):
"""
Tests _write_session_id_to_file not implemented
"""
# create object
Client
(
baseurl
=
"
http://fqdn
"
,
webservicename
=
"
GenericTicketConnectorREST
"
)
# TODO
def
test__remove_session_id_file
(
self
):
"""
Tests_remove_session_id_file not implemented
"""
...
...
@@ -320,6 +322,44 @@ class ClientTests(unittest.TestCase):
'
http_method, url and payload are required.
'
,
Client
.
_send_request
)
def
test_ticket_create_no_ticket
(
self
):
"""
Test ticket_create - no ticket specified
"""
obj
=
Client
(
baseurl
=
"
http://fqdn
"
,
webservicename
=
"
GenericTicketConnectorREST
"
)
obj
.
session_id
=
"
some_session_id
"
self
.
assertRaisesRegex
(
TicketError
,
'
provide Ticket!
'
,
obj
.
ticket_create
)
def
test_ticket_create_no_article
(
self
):
"""
Test ticket_create - no article specified
"""
obj
=
Client
(
baseurl
=
"
http://fqdn
"
,
webservicename
=
"
GenericTicketConnectorREST
"
)
obj
.
session_id
=
"
some_session_id
"
tic
=
Ticket
(
dct
=
{
'
Title
'
:
'
foo
'
})
self
.
assertRaisesRegex
(
TicketError
,
'
provide Article!
'
,
obj
.
ticket_create
,
ticket
=
tic
)
@mock.patch
(
'
pyotrs.lib.Client._ticket_create_json
'
,
autospec
=
True
)
def
test_ticket_create_no_ticket_mock
(
self
,
mock_t_create_json
):
"""
Test ticket_create - no ticket specified
"""
obj
=
Client
(
baseurl
=
"
http://fqdn
"
,
webservicename
=
"
GenericTicketConnectorREST
"
)
obj
.
session_id
=
"
some_session_id
"
tic
=
Ticket
(
dct
=
{
'
Title
'
:
'
foo
'
})
art
=
Article
({
'
Subject
'
:
'
mySubject
'
,
'
Body
'
:
'
myBody
'
,
'
TimeUnit
'
:
0
,
'
MimeType
'
:
'
text/plain
'
,
'
Charset
'
:
'
UTF8
'
})
mock_t_create_json
.
return_value
=
False
result
=
obj
.
ticket_create
(
ticket
=
tic
,
article
=
art
)
self
.
assertEqual
(
result
,
None
)
def
test__ticket_request_invalid_method
(
self
):
"""
Test Method Client._ticket_request
"""
self
.
assertRaisesRegex
(
NotImplementedError
,
...
...
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