KayakoClient 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/kayako_client.rb +31 -0
- data/lib/kayako_client/base.rb +23 -0
- data/lib/kayako_client/custom_field.rb +14 -0
- data/lib/kayako_client/department.rb +18 -3
- data/lib/kayako_client/http/http.rb +14 -0
- data/lib/kayako_client/http/http_backend.rb +14 -0
- data/lib/kayako_client/http/http_client.rb +14 -0
- data/lib/kayako_client/http/http_response.rb +14 -0
- data/lib/kayako_client/http/net_http.rb +14 -0
- data/lib/kayako_client/knowledgebase_article.rb +131 -0
- data/lib/kayako_client/knowledgebase_attachment.rb +59 -0
- data/lib/kayako_client/knowledgebase_category.rb +71 -0
- data/lib/kayako_client/knowledgebase_comment.rb +32 -0
- data/lib/kayako_client/mixins/api.rb +14 -0
- data/lib/kayako_client/mixins/article_client.rb +76 -0
- data/lib/kayako_client/mixins/attachment.rb +16 -1
- data/lib/kayako_client/mixins/authentication.rb +14 -0
- data/lib/kayako_client/mixins/client.rb +300 -0
- data/lib/kayako_client/mixins/comment_object.rb +102 -0
- data/lib/kayako_client/mixins/convert_api.rb +39 -0
- data/lib/kayako_client/mixins/creator_api.rb +44 -0
- data/lib/kayako_client/mixins/knowledgebase_article_api.rb +69 -0
- data/lib/kayako_client/mixins/knowledgebase_category_client.rb +51 -0
- data/lib/kayako_client/mixins/logger.rb +14 -0
- data/lib/kayako_client/mixins/news_category_client.rb +51 -0
- data/lib/kayako_client/mixins/news_client.rb +51 -0
- data/lib/kayako_client/mixins/object.rb +24 -7
- data/lib/kayako_client/mixins/post_client.rb +14 -0
- data/lib/kayako_client/mixins/staff_visibility_api.rb +14 -0
- data/lib/kayako_client/mixins/ticket_api.rb +14 -0
- data/lib/kayako_client/mixins/ticket_client.rb +14 -0
- data/lib/kayako_client/mixins/troubleshooter_step_api.rb +69 -0
- data/lib/kayako_client/mixins/troubleshooter_step_client.rb +76 -0
- data/lib/kayako_client/mixins/user_visibility_api.rb +14 -0
- data/lib/kayako_client/news_category.rb +29 -0
- data/lib/kayako_client/news_comment.rb +32 -0
- data/lib/kayako_client/news_item.rb +81 -0
- data/lib/kayako_client/news_subscriber.rb +33 -0
- data/lib/kayako_client/staff.rb +14 -0
- data/lib/kayako_client/staff_group.rb +14 -0
- data/lib/kayako_client/ticket.rb +24 -1
- data/lib/kayako_client/ticket_attachment.rb +18 -0
- data/lib/kayako_client/ticket_count.rb +14 -0
- data/lib/kayako_client/ticket_custom_field.rb +14 -0
- data/lib/kayako_client/ticket_note.rb +14 -1
- data/lib/kayako_client/ticket_post.rb +15 -0
- data/lib/kayako_client/ticket_priority.rb +14 -0
- data/lib/kayako_client/ticket_status.rb +14 -0
- data/lib/kayako_client/ticket_time_track.rb +14 -0
- data/lib/kayako_client/ticket_type.rb +14 -0
- data/lib/kayako_client/troubleshooter_attachment.rb +68 -0
- data/lib/kayako_client/troubleshooter_category.rb +51 -0
- data/lib/kayako_client/troubleshooter_comment.rb +32 -0
- data/lib/kayako_client/troubleshooter_step.rb +100 -0
- data/lib/kayako_client/user.rb +42 -0
- data/lib/kayako_client/user_group.rb +14 -0
- data/lib/kayako_client/user_organization.rb +14 -0
- data/lib/kayako_client/xml/lib_xml.rb +14 -0
- data/lib/kayako_client/xml/rexml_document.rb +14 -0
- data/lib/kayako_client/xml/xml.rb +14 -0
- data/lib/kayako_client/xml/xml_backend.rb +14 -0
- data/test/test_attachment.rb +77 -0
- data/test/test_client.rb +191 -0
- data/test/test_configuration.rb +110 -0
- data/test/test_count.rb +162 -0
- data/test/test_custom_field.rb +86 -0
- data/test/test_department.rb +136 -0
- data/test/test_http.rb +34 -0
- data/test/test_knowledgebase.rb +155 -0
- data/test/test_news.rb +117 -0
- data/test/test_note.rb +64 -0
- data/test/test_post.rb +64 -0
- data/test/test_priority.rb +46 -0
- data/test/test_properties.rb +114 -0
- data/test/test_staff.rb +77 -0
- data/test/test_status.rb +52 -0
- data/test/test_ticket.rb +152 -0
- data/test/test_ticket_custom_field.rb +193 -0
- data/test/test_time_track.rb +68 -0
- data/test/test_troubleshooter.rb +106 -0
- data/test/test_type.rb +65 -0
- data/test/test_user.rb +95 -0
- data/test/test_xml.rb +183 -0
- metadata +89 -42
@@ -0,0 +1,106 @@
|
|
1
|
+
#######################################################################
|
2
|
+
#
|
3
|
+
# Kayako Ruby REST API library
|
4
|
+
# _____________________________________________________________________
|
5
|
+
#
|
6
|
+
# @author Andriy Lesyuk
|
7
|
+
#
|
8
|
+
# @package KayakoClient
|
9
|
+
# @copyright Copyright (c) 2011-2013, Kayako
|
10
|
+
# @license FreeBSD
|
11
|
+
# @link http://forge.kayako.com/projects/kayako-ruby-api-library
|
12
|
+
#
|
13
|
+
#######################################################################
|
14
|
+
|
15
|
+
require 'test/unit'
|
16
|
+
require 'kayako_client'
|
17
|
+
|
18
|
+
class TestTroubleshooter < Test::Unit::TestCase
|
19
|
+
|
20
|
+
def test_path
|
21
|
+
assert_equal KayakoClient::TroubleshooterAttachment.path, '/Troubleshooter/Attachment'
|
22
|
+
assert_equal KayakoClient::TroubleshooterCategory.path, '/Troubleshooter/Category'
|
23
|
+
assert_equal KayakoClient::TroubleshooterComment.path, '/Troubleshooter/Comment'
|
24
|
+
assert_equal KayakoClient::TroubleshooterStep.path, '/Troubleshooter/Step'
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_step_api
|
28
|
+
assert_raise ArgumentError do
|
29
|
+
KayakoClient::TroubleshooterAttachment.all
|
30
|
+
end
|
31
|
+
|
32
|
+
assert_raise ArgumentError do
|
33
|
+
KayakoClient::TroubleshooterAttachment.get(1)
|
34
|
+
end
|
35
|
+
|
36
|
+
assert_raise ArgumentError do
|
37
|
+
KayakoClient::TroubleshooterAttachment.delete(1)
|
38
|
+
end
|
39
|
+
|
40
|
+
test = KayakoClient::TroubleshooterAttachment.new(
|
41
|
+
:id => 1
|
42
|
+
)
|
43
|
+
test.loaded!
|
44
|
+
|
45
|
+
assert_raise RuntimeError do
|
46
|
+
test.delete
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_step
|
51
|
+
test = KayakoClient::TroubleshooterStep.new(
|
52
|
+
:parent_step_ids => [ 1 ],
|
53
|
+
:child_step_ids => [ 2 ]
|
54
|
+
)
|
55
|
+
|
56
|
+
assert test.respond_to?(:get_attachment)
|
57
|
+
assert test.respond_to?(:get_comment)
|
58
|
+
|
59
|
+
assert test.has_parent_steps?
|
60
|
+
assert test.in_step?(1)
|
61
|
+
assert !test.in_step?(2)
|
62
|
+
|
63
|
+
assert test.has_child_steps?
|
64
|
+
assert test.has_step?(2)
|
65
|
+
assert !test.has_step?(1)
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_attachment
|
69
|
+
test = KayakoClient::TroubleshooterAttachment.new
|
70
|
+
|
71
|
+
assert test.respond_to?(:file=)
|
72
|
+
assert test.respond_to?(:file)
|
73
|
+
|
74
|
+
assert test.respond_to?(:troubleshooter_step_id)
|
75
|
+
assert test.respond_to?(:troubleshooter_step)
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_category
|
79
|
+
assert KayakoClient::TroubleshooterCategory.included_modules.include?(KayakoClient::ConvertAPI)
|
80
|
+
|
81
|
+
test = KayakoClient::TroubleshooterCategory.new
|
82
|
+
|
83
|
+
test.respond_to?(:visible_to_user_group?)
|
84
|
+
test.respond_to?(:visible_to_staff_group?)
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_comment
|
88
|
+
test = KayakoClient::TroubleshooterComment.new
|
89
|
+
|
90
|
+
assert test.respond_to?(:creator=)
|
91
|
+
|
92
|
+
assert test.respond_to?(:troubleshooter_step_id)
|
93
|
+
assert test.respond_to?(:troubleshooter_step)
|
94
|
+
|
95
|
+
assert_raise NotImplementedError do
|
96
|
+
test.put
|
97
|
+
end
|
98
|
+
|
99
|
+
assert test.respond_to?(:creator_type=)
|
100
|
+
assert test.respond_to?(:creator_id=)
|
101
|
+
|
102
|
+
assert test.respond_to?(:user_agent)
|
103
|
+
assert test.respond_to?(:referrer)
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
data/test/test_type.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
#######################################################################
|
2
|
+
#
|
3
|
+
# Kayako Ruby REST API library
|
4
|
+
# _____________________________________________________________________
|
5
|
+
#
|
6
|
+
# @author Andriy Lesyuk
|
7
|
+
#
|
8
|
+
# @package KayakoClient
|
9
|
+
# @copyright Copyright (c) 2011-2013, Kayako
|
10
|
+
# @license FreeBSD
|
11
|
+
# @link http://forge.kayako.com/projects/kayako-ruby-api-library
|
12
|
+
#
|
13
|
+
#######################################################################
|
14
|
+
|
15
|
+
require 'test/unit'
|
16
|
+
require 'kayako_client'
|
17
|
+
|
18
|
+
class TestType < Test::Unit::TestCase
|
19
|
+
|
20
|
+
def test_type_mixin
|
21
|
+
assert KayakoClient::TicketType.included_modules.include?(KayakoClient::UserVisibilityAPI)
|
22
|
+
|
23
|
+
test = KayakoClient::TicketType.new
|
24
|
+
assert test.respond_to?(:visible_to_user_group?)
|
25
|
+
assert test.respond_to?(:user_visibility_custom)
|
26
|
+
assert test.respond_to?(:user_group_ids)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_type_methods
|
30
|
+
test = KayakoClient::TicketType.new
|
31
|
+
|
32
|
+
assert_raise NotImplementedError do
|
33
|
+
test.put
|
34
|
+
end
|
35
|
+
|
36
|
+
assert_raise NotImplementedError do
|
37
|
+
test.post
|
38
|
+
end
|
39
|
+
|
40
|
+
assert_raise NotImplementedError do
|
41
|
+
test.delete
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_type_constants
|
46
|
+
assert KayakoClient::TicketType::TYPE_TYPES.include?(:public)
|
47
|
+
assert KayakoClient::TicketType::TYPE_TYPES.include?(:private)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_type_visibility
|
51
|
+
test = KayakoClient::TicketType.new(
|
52
|
+
:uservisibilitycustom => true,
|
53
|
+
:usergroupid => [ 1, 2 ]
|
54
|
+
)
|
55
|
+
|
56
|
+
assert test.visible_to_user_group?(1)
|
57
|
+
assert !test.visible_to_user_group?(3)
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_type_associates
|
61
|
+
test = KayakoClient::TicketType.new
|
62
|
+
test.respond_to?(:department)
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
data/test/test_user.rb
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
#######################################################################
|
2
|
+
#
|
3
|
+
# Kayako Ruby REST API library
|
4
|
+
# _____________________________________________________________________
|
5
|
+
#
|
6
|
+
# @author Andriy Lesyuk
|
7
|
+
#
|
8
|
+
# @package KayakoClient
|
9
|
+
# @copyright Copyright (c) 2011-2013, Kayako
|
10
|
+
# @license FreeBSD
|
11
|
+
# @link http://forge.kayako.com/projects/kayako-ruby-api-library
|
12
|
+
#
|
13
|
+
#######################################################################
|
14
|
+
|
15
|
+
require 'test/unit'
|
16
|
+
require 'kayako_client'
|
17
|
+
|
18
|
+
class TestUser < Test::Unit::TestCase
|
19
|
+
|
20
|
+
def test_user_customs
|
21
|
+
assert_raise ArgumentError do
|
22
|
+
KayakoClient::User.all(0)
|
23
|
+
end
|
24
|
+
|
25
|
+
assert_raise ArgumentError do
|
26
|
+
KayakoClient::User.all(1, 0)
|
27
|
+
end
|
28
|
+
|
29
|
+
assert_raise ArgumentError do
|
30
|
+
KayakoClient::User.all(nil, 1)
|
31
|
+
end
|
32
|
+
|
33
|
+
assert_raise ArgumentError do
|
34
|
+
KayakoClient::User.all(0, 1)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_user_validate
|
39
|
+
test = KayakoClient::User.new(
|
40
|
+
:user_group_id => 1,
|
41
|
+
:user_role => :tester,
|
42
|
+
:salutation => 'Sir',
|
43
|
+
:full_name => 'Test',
|
44
|
+
:emails => 'test@test.com',
|
45
|
+
:password => 'test'
|
46
|
+
)
|
47
|
+
|
48
|
+
assert !test.save
|
49
|
+
assert test.errors.has_key?(:user_role)
|
50
|
+
assert test.errors.has_key?(:salutation)
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_user_required
|
54
|
+
test = KayakoClient::User.new(
|
55
|
+
:full_name => 'Test',
|
56
|
+
:emails => 'test@test.com',
|
57
|
+
:password => 'test'
|
58
|
+
)
|
59
|
+
assert_raise ArgumentError do
|
60
|
+
test.save
|
61
|
+
end
|
62
|
+
|
63
|
+
test = KayakoClient::User.new(
|
64
|
+
:user_group_id => 1,
|
65
|
+
:emails => 'test@test.com',
|
66
|
+
:password => 'test'
|
67
|
+
)
|
68
|
+
assert_raise ArgumentError do
|
69
|
+
test.save
|
70
|
+
end
|
71
|
+
|
72
|
+
test = KayakoClient::User.new(
|
73
|
+
:user_group_id => 1,
|
74
|
+
:full_name => 'Test',
|
75
|
+
:password => 'test'
|
76
|
+
)
|
77
|
+
assert_raise ArgumentError do
|
78
|
+
test.save
|
79
|
+
end
|
80
|
+
|
81
|
+
test = KayakoClient::User.new(
|
82
|
+
:user_group_id => 1,
|
83
|
+
:full_name => 'Test',
|
84
|
+
:emails => 'test@test.com'
|
85
|
+
)
|
86
|
+
assert_raise ArgumentError do
|
87
|
+
test.save
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_user_search
|
92
|
+
assert KayakoClient::User.respond_to?(:search)
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
data/test/test_xml.rb
ADDED
@@ -0,0 +1,183 @@
|
|
1
|
+
#######################################################################
|
2
|
+
#
|
3
|
+
# Kayako Ruby REST API library
|
4
|
+
# _____________________________________________________________________
|
5
|
+
#
|
6
|
+
# @author Andriy Lesyuk
|
7
|
+
#
|
8
|
+
# @package KayakoClient
|
9
|
+
# @copyright Copyright (c) 2011-2013, Kayako
|
10
|
+
# @license FreeBSD
|
11
|
+
# @link http://forge.kayako.com/projects/kayako-ruby-api-library
|
12
|
+
#
|
13
|
+
#######################################################################
|
14
|
+
|
15
|
+
require 'test/unit'
|
16
|
+
require 'kayako_client'
|
17
|
+
|
18
|
+
class TestXML < Test::Unit::TestCase
|
19
|
+
|
20
|
+
PHP_ERROR = '<div style="BACKGROUND: #f8ebeb; FONT: 13px Trebuchet MS, Verdana, Helvetica, Arial; BORDER: 1px SOLID #751616; PADDING: 10px; MARGIN: 5px;">' +
|
21
|
+
'<font color="red">' +
|
22
|
+
'[Warning]: Missing argument 2 for Controller_TicketAttachment::Get() (api/class.Controller_TicketAttachment.php:172)' +
|
23
|
+
'</font>' +
|
24
|
+
'</div>'
|
25
|
+
|
26
|
+
def test_xml_php_error
|
27
|
+
xml = KayakoClient::REXMLDocument.new(PHP_ERROR)
|
28
|
+
|
29
|
+
assert xml.error?
|
30
|
+
assert_equal xml.error, '[Warning]: Missing argument 2 for Controller_TicketAttachment::Get() (api/class.Controller_TicketAttachment.php:172)'
|
31
|
+
assert_equal xml.count, 0
|
32
|
+
assert_nil xml.to_hash
|
33
|
+
|
34
|
+
xml = KayakoClient::LibXML.new(PHP_ERROR)
|
35
|
+
|
36
|
+
assert xml.error?
|
37
|
+
assert_equal xml.error, '[Warning]: Missing argument 2 for Controller_TicketAttachment::Get() (api/class.Controller_TicketAttachment.php:172)'
|
38
|
+
assert_equal xml.count, 0
|
39
|
+
assert_nil xml.to_hash
|
40
|
+
end
|
41
|
+
|
42
|
+
STAFF_GROUPS = '<?xml version="1.0" encoding="UTF-8"?>' +
|
43
|
+
'<staffgroups>' +
|
44
|
+
'<staffgroup>' +
|
45
|
+
'<id><![CDATA[1]]></id>' +
|
46
|
+
'<title><![CDATA[Administrators]]></title>' +
|
47
|
+
'<isadmin><![CDATA[1]]></isadmin>' +
|
48
|
+
'</staffgroup>' +
|
49
|
+
'<staffgroup>' +
|
50
|
+
'<id><![CDATA[2]]></id>' +
|
51
|
+
'<title><![CDATA[Employees]]></title>' +
|
52
|
+
'<isadmin><![CDATA[0]]></isadmin>' +
|
53
|
+
'</staffgroup>' +
|
54
|
+
'<staffgroup>' +
|
55
|
+
'<id><![CDATA[3]]></id>' +
|
56
|
+
'<title><![CDATA[Users]]></title>' +
|
57
|
+
'<isadmin><![CDATA[0]]></isadmin>' +
|
58
|
+
'</staffgroup>' +
|
59
|
+
'<staffgroup>' +
|
60
|
+
'<id><![CDATA[5]]></id>' +
|
61
|
+
'<title><![CDATA[Testers]]></title>' +
|
62
|
+
'<isadmin><![CDATA[0]]></isadmin>' +
|
63
|
+
'</staffgroup>' +
|
64
|
+
'</staffgroups>'
|
65
|
+
|
66
|
+
def test_xml_staff_groups
|
67
|
+
xml = KayakoClient::REXMLDocument.new(STAFF_GROUPS)
|
68
|
+
test = xml.to_hash
|
69
|
+
|
70
|
+
assert_equal xml.count, 4
|
71
|
+
assert_instance_of Array, test[:staffgroup]
|
72
|
+
assert_equal test[:staffgroup].size, 4
|
73
|
+
assert_instance_of Hash, test[:staffgroup].first
|
74
|
+
assert_equal test[:staffgroup].first[:id], 1.to_s
|
75
|
+
assert_equal test[:staffgroup].first[:title], 'Administrators'
|
76
|
+
|
77
|
+
xml = KayakoClient::LibXML.new(STAFF_GROUPS)
|
78
|
+
test = xml.to_hash
|
79
|
+
|
80
|
+
assert_equal xml.count, 4
|
81
|
+
assert_instance_of Array, test[:staffgroup]
|
82
|
+
assert_equal test[:staffgroup].size, 4
|
83
|
+
assert_instance_of Hash, test[:staffgroup].first
|
84
|
+
assert_equal test[:staffgroup].first[:id], 1.to_s
|
85
|
+
assert_equal test[:staffgroup].first[:title], 'Administrators'
|
86
|
+
end
|
87
|
+
|
88
|
+
TICKET_COUNT = '<?xml version="1.0" encoding="UTF-8"?>' +
|
89
|
+
'<ticketcount>' +
|
90
|
+
'<departments>' +
|
91
|
+
'<department id="3">' +
|
92
|
+
'<totalitems><![CDATA[5]]></totalitems>' +
|
93
|
+
'<lastactivity><![CDATA[1311888965]]></lastactivity>' +
|
94
|
+
'<totalunresolveditems><![CDATA[5]]></totalunresolveditems>' +
|
95
|
+
'<ticketstatus id="1" lastactivity="1311888965" totalitems="5" />' +
|
96
|
+
'<tickettype id="0" lastactivity="1311888965" totalitems="5" totalunresolveditems="5" />' +
|
97
|
+
'<ownerstaff id="0" lastactivity="1311888396" totalitems="1" totalunresolveditems="1" />' +
|
98
|
+
'<ownerstaff id="1" lastactivity="1311887337" totalitems="2" totalunresolveditems="2" />' +
|
99
|
+
'<ownerstaff id="3" lastactivity="1311888965" totalitems="2" totalunresolveditems="2" />' +
|
100
|
+
'</department>' +
|
101
|
+
'<department id="5">' +
|
102
|
+
'<totalitems><![CDATA[1]]></totalitems>' +
|
103
|
+
'<lastactivity><![CDATA[1313153933]]></lastactivity>' +
|
104
|
+
'<totalunresolveditems><![CDATA[1]]></totalunresolveditems>' +
|
105
|
+
'<ticketstatus id="1" lastactivity="1313153933" totalitems="1" />' +
|
106
|
+
'<tickettype id="0" lastactivity="1313153933" totalitems="1" totalunresolveditems="1" />' +
|
107
|
+
'<ownerstaff id="3" lastactivity="1313153933" totalitems="1" totalunresolveditems="1" />' +
|
108
|
+
'</department>' +
|
109
|
+
'</departments>' +
|
110
|
+
'<!-- Ticket Count grouped by Status -->' +
|
111
|
+
'<statuses>' +
|
112
|
+
'<ticketstatus id="1" lastactivity="1313153933" totalitems="6" />' +
|
113
|
+
'</statuses>' +
|
114
|
+
'<!-- Ticket Count grouped by Owner Staff -->' +
|
115
|
+
'<owners>' +
|
116
|
+
'<ownerstaff id="0" lastactivity="1311888396" totalitems="1" totalunresolveditems="1" />' +
|
117
|
+
'<ownerstaff id="1" lastactivity="1311887337" totalitems="2" totalunresolveditems="2" />' +
|
118
|
+
'<ownerstaff id="3" lastactivity="1311888965" totalitems="2" totalunresolveditems="2" />' +
|
119
|
+
'</owners>' +
|
120
|
+
'<!-- Unassigned Ticket Count grouped by Department -->' +
|
121
|
+
'<unassigned>' +
|
122
|
+
'<department id="1" lastactivity="1311888396" totalitems="1" totalunresolveditems="1" />' +
|
123
|
+
'<department id="2" lastactivity="1311888396" totalitems="1" totalunresolveditems="1" />' +
|
124
|
+
'<department id="4" lastactivity="1311888396" totalitems="1" totalunresolveditems="1" />' +
|
125
|
+
'<department id="3" lastactivity="1311888396" totalitems="1" totalunresolveditems="1" />' +
|
126
|
+
'</unassigned>' +
|
127
|
+
'</ticketcount>'
|
128
|
+
|
129
|
+
def test_xml_ticket_count
|
130
|
+
xml = KayakoClient::REXMLDocument.new(TICKET_COUNT)
|
131
|
+
test = xml.to_hash
|
132
|
+
|
133
|
+
assert test.has_key?(:departments)
|
134
|
+
assert test.has_key?(:statuses)
|
135
|
+
assert test.has_key?(:owners)
|
136
|
+
assert test.has_key?(:unassigned)
|
137
|
+
|
138
|
+
assert_equal test[:departments].size, 1
|
139
|
+
assert_equal test[:statuses].size, 1
|
140
|
+
assert_equal test[:owners].size, 1
|
141
|
+
assert_equal test[:unassigned].size, 1
|
142
|
+
|
143
|
+
assert_instance_of Array, test[:departments][:department]
|
144
|
+
assert_instance_of Hash, test[:statuses][:ticketstatus]
|
145
|
+
assert_instance_of Array, test[:owners][:ownerstaff]
|
146
|
+
assert_instance_of Array, test[:unassigned][:department]
|
147
|
+
|
148
|
+
assert_equal test[:departments][:department].size, 2
|
149
|
+
assert_equal test[:owners][:ownerstaff].size, 3
|
150
|
+
assert_equal test[:unassigned][:department].size, 4
|
151
|
+
|
152
|
+
assert_equal test[:departments][:department][0][:id], 3.to_s
|
153
|
+
assert_equal test[:owners][:ownerstaff][1][:id], 1.to_s
|
154
|
+
assert_equal test[:unassigned][:department][2][:id], 4.to_s
|
155
|
+
|
156
|
+
xml = KayakoClient::LibXML.new(TICKET_COUNT)
|
157
|
+
test = xml.to_hash
|
158
|
+
|
159
|
+
assert test.has_key?(:departments)
|
160
|
+
assert test.has_key?(:statuses)
|
161
|
+
assert test.has_key?(:owners)
|
162
|
+
assert test.has_key?(:unassigned)
|
163
|
+
|
164
|
+
assert_equal test[:departments].size, 1
|
165
|
+
assert_equal test[:statuses].size, 1
|
166
|
+
assert_equal test[:owners].size, 1
|
167
|
+
assert_equal test[:unassigned].size, 1
|
168
|
+
|
169
|
+
assert_instance_of Array, test[:departments][:department]
|
170
|
+
assert_instance_of Hash, test[:statuses][:ticketstatus]
|
171
|
+
assert_instance_of Array, test[:owners][:ownerstaff]
|
172
|
+
assert_instance_of Array, test[:unassigned][:department]
|
173
|
+
|
174
|
+
assert_equal test[:departments][:department].size, 2
|
175
|
+
assert_equal test[:owners][:ownerstaff].size, 3
|
176
|
+
assert_equal test[:unassigned][:department].size, 4
|
177
|
+
|
178
|
+
assert_equal test[:departments][:department][0][:id], 3.to_s
|
179
|
+
assert_equal test[:owners][:ownerstaff][1][:id], 1.to_s
|
180
|
+
assert_equal test[:unassigned][:department][2][:id], 4.to_s
|
181
|
+
end
|
182
|
+
|
183
|
+
end
|