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
9cd691dc
Commit
9cd691dc
authored
8 years ago
by
Robert Habermann
Browse files
Options
Downloads
Patches
Plain Diff
rename result.content to _content and response_type to _content
parent
1109b2d8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pyotrs/lib.py
+10
-10
10 additions, 10 deletions
pyotrs/lib.py
tests/test_client.py
+7
-7
7 additions, 7 deletions
tests/test_client.py
tests/test_pyotrs_responses.py
+3
-3
3 additions, 3 deletions
tests/test_pyotrs_responses.py
with
20 additions
and
20 deletions
pyotrs/lib.py
+
10
−
10
View file @
9cd691dc
...
...
@@ -682,7 +682,7 @@ class Client(object):
self
.
result_list_ticket_search
=
[]
self
.
result_json
=
None
self
.
result_content
=
None
self
.
_
result_content
=
None
self
.
result_status_code
=
None
"""
...
...
@@ -1272,21 +1272,21 @@ class Client(object):
# get and set new data
self
.
result_json
=
response
.
json
()
self
.
result_status_code
=
response
.
status_code
# TODO 2016-04-24 (RH) can this deep copy go?
self
.
_result_json_original
=
copy
.
deepcopy
(
self
.
result_json
)
self
.
result_status_code
=
response
.
status_code
self
.
result_content
=
response
.
content
self
.
_result_content
=
response
.
content
if
self
.
operation
==
"
SessionCreate
"
:
self
.
res
ponse
_type
=
"
SessionID
"
self
.
_
res
ult
_type
=
"
SessionID
"
elif
self
.
operation
==
"
TicketGet
"
:
self
.
res
ponse
_type
=
"
Ticket
"
self
.
_
res
ult
_type
=
"
Ticket
"
elif
self
.
operation
==
"
TicketCreate
"
:
self
.
res
ponse
_type
=
"
TicketID
"
self
.
_
res
ult
_type
=
"
TicketID
"
elif
self
.
operation
==
"
TicketSearch
"
:
self
.
res
ponse
_type
=
"
TicketID
"
self
.
_
res
ult
_type
=
"
TicketID
"
elif
self
.
operation
==
"
TicketUpdate
"
:
self
.
res
ponse
_type
=
"
TicketID
"
self
.
_
res
ult
_type
=
"
TicketID
"
else
:
raise
NotImplementedError
(
"
Unknown Operation!
"
)
...
...
@@ -1294,12 +1294,12 @@ class Client(object):
if
self
.
operation
==
"
TicketSearch
"
:
if
not
self
.
result_json
:
return
True
if
self
.
result_json
.
get
(
self
.
res
ponse
_type
,
None
):
if
self
.
result_json
.
get
(
self
.
_
res
ult
_type
,
None
):
self
.
result_list_ticket_search
=
self
.
result_json
[
'
TicketID
'
]
return
True
# now handle other operations
if
self
.
result_json
.
get
(
self
.
res
ponse
_type
,
None
):
if
self
.
result_json
.
get
(
self
.
_
res
ult
_type
,
None
):
self
.
result_error
=
False
elif
self
.
result_json
.
get
(
"
Error
"
,
None
):
self
.
result_error
=
True
...
...
This diff is collapsed.
Click to expand it.
tests/test_client.py
+
7
−
7
View file @
9cd691dc
...
...
@@ -743,7 +743,7 @@ class ClientTests(unittest.TestCase):
client
.
_parse_and_validate_response
(
mocked_response
)
self
.
assertEqual
(
client
.
res
ponse
_type
,
'
SessionID
'
)
self
.
assertEqual
(
client
.
_
res
ult
_type
,
'
SessionID
'
)
def
test__validate_response_operation_ticket_get
(
self
):
"""
Test _validate_response with TicketGet
"""
...
...
@@ -765,7 +765,7 @@ class ClientTests(unittest.TestCase):
client
.
_parse_and_validate_response
(
mocked_response
)
self
.
assertEqual
(
client
.
res
ponse
_type
,
'
Ticket
'
)
self
.
assertEqual
(
client
.
_
res
ult
_type
,
'
Ticket
'
)
self
.
assertDictEqual
(
client
.
result_json
,
tkt
)
def
test__validate_response_operation_ticket_create
(
self
):
...
...
@@ -781,7 +781,7 @@ class ClientTests(unittest.TestCase):
client
.
_parse_and_validate_response
(
mocked_response
)
self
.
assertEqual
(
client
.
res
ponse
_type
,
'
TicketID
'
)
self
.
assertEqual
(
client
.
_
res
ult
_type
,
'
TicketID
'
)
self
.
assertDictEqual
(
client
.
result_json
,
{
u
'
ArticleID
'
:
u
'
26
'
,
u
'
TicketID
'
:
u
'
9
'
,
u
'
TicketNumber
'
:
u
'
000008
'
})
...
...
@@ -796,7 +796,7 @@ class ClientTests(unittest.TestCase):
mocked_response
.
json
.
return_value
=
{
u
'
TicketID
'
:
u
'
9
'
,
u
'
TicketNumber
'
:
u
'
000008
'
}
client
.
_parse_and_validate_response
(
mocked_response
)
self
.
assertEqual
(
client
.
res
ponse
_type
,
'
TicketID
'
)
self
.
assertEqual
(
client
.
_
res
ult
_type
,
'
TicketID
'
)
self
.
assertDictEqual
(
client
.
result_json
,
{
u
'
TicketID
'
:
u
'
9
'
,
u
'
TicketNumber
'
:
u
'
000008
'
})
...
...
@@ -810,7 +810,7 @@ class ClientTests(unittest.TestCase):
mocked_response
.
json
.
return_value
=
{
u
'
TicketID
'
:
[
u
'
9
'
]}
client
.
_parse_and_validate_response
(
mocked_response
)
self
.
assertEqual
(
client
.
res
ponse
_type
,
'
TicketID
'
)
self
.
assertEqual
(
client
.
_
res
ult
_type
,
'
TicketID
'
)
self
.
assertDictEqual
(
client
.
result_json
,
{
u
'
TicketID
'
:
[
u
'
9
'
]})
def
test__validate_response_operation_ticket_search_empty
(
self
):
...
...
@@ -823,7 +823,7 @@ class ClientTests(unittest.TestCase):
mocked_response
.
json
.
return_value
=
{}
client
.
_parse_and_validate_response
(
mocked_response
)
self
.
assertEqual
(
client
.
res
ponse
_type
,
'
TicketID
'
)
self
.
assertEqual
(
client
.
_
res
ult
_type
,
'
TicketID
'
)
self
.
assertDictEqual
(
client
.
result_json
,
{})
def
test__validate_response_operation_ticket_search_nonsense
(
self
):
...
...
@@ -838,7 +838,7 @@ class ClientTests(unittest.TestCase):
self
.
assertRaises
(
ResponseJSONParseError
,
client
.
_parse_and_validate_response
,
mocked_response
)
self
.
assertEqual
(
client
.
res
ponse
_type
,
'
TicketID
'
)
self
.
assertEqual
(
client
.
_
res
ult
_type
,
'
TicketID
'
)
self
.
assertTrue
(
client
.
result_error
)
self
.
assertDictEqual
(
client
.
result_json
,
{
u
'
FooBar
'
:
[
u
'
1
'
,
u
'
3
'
]})
...
...
This diff is collapsed.
Click to expand it.
tests/test_pyotrs_responses.py
+
3
−
3
View file @
9cd691dc
...
...
@@ -25,7 +25,7 @@ class PyOTRSResponsesTests(unittest.TestCase):
self
.
assertIsNone
(
obj
.
result_json
)
self
.
assertIsNone
(
obj
.
result_status_code
)
self
.
assertIsNone
(
obj
.
result_content
)
self
.
assertIsNone
(
obj
.
_
result_content
)
self
.
assertIsNone
(
obj
.
session_id_store
.
value
)
with
responses
.
RequestsMock
(
assert_all_requests_are_fired
=
True
)
as
rsps
:
...
...
@@ -53,7 +53,7 @@ class PyOTRSResponsesTests(unittest.TestCase):
self
.
assertIsNone
(
obj
.
result_json
)
self
.
assertIsNone
(
obj
.
result_status_code
)
self
.
assertIsNone
(
obj
.
result_content
)
self
.
assertIsNone
(
obj
.
_
result_content
)
self
.
assertIsNone
(
obj
.
session_id_store
.
value
)
with
responses
.
RequestsMock
(
assert_all_requests_are_fired
=
True
)
as
rsps
:
...
...
@@ -85,7 +85,7 @@ class PyOTRSResponsesTests(unittest.TestCase):
self
.
assertIsNone
(
obj
.
result_json
)
self
.
assertIsNone
(
obj
.
result_status_code
)
self
.
assertIsNone
(
obj
.
result_content
)
self
.
assertIsNone
(
obj
.
_
result_content
)
self
.
assertIsNone
(
obj
.
session_id_store
.
value
)
mock_validate_resp
.
return_value
=
False
...
...
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