forked from softlayer/softlayer-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathticket_tests.py
More file actions
104 lines (83 loc) · 3.81 KB
/
ticket_tests.py
File metadata and controls
104 lines (83 loc) · 3.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
"""
SoftLayer.tests.managers.ticket_tests
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:license: MIT, see LICENSE for more details.
"""
import SoftLayer
from SoftLayer import fixtures
from SoftLayer import testing
class TicketTests(testing.TestCase):
def set_up(self):
self.ticket = SoftLayer.TicketManager(self.client)
def test_list_tickets(self):
results = self.ticket.list_tickets()
for result in results:
self.assertIn(result['id'], [100, 101, 102])
self.assert_called_with('SoftLayer_Account', 'getTickets')
def test_list_tickets_all(self):
results = self.ticket.list_tickets(open_status=True,
closed_status=True)
for result in results:
self.assertIn(result['id'], [100, 101, 102])
self.assert_called_with('SoftLayer_Account', 'getTickets')
def test_list_tickets_open(self):
results = self.ticket.list_tickets(open_status=True,
closed_status=False)
for result in results:
self.assertIn(result['id'], [102])
self.assert_called_with('SoftLayer_Account', 'getOpenTickets')
def test_list_tickets_closed(self):
results = self.ticket.list_tickets(open_status=False,
closed_status=True)
for result in results:
self.assertIn(result['id'], [100, 101])
self.assert_called_with('SoftLayer_Account', 'getClosedTickets')
def test_list_subjects(self):
list_expected_ids = [1001, 1002, 1003, 1004, 1005]
results = self.ticket.list_subjects()
for result in results:
self.assertIn(result['id'], list_expected_ids)
def test_get_instance(self):
result = self.ticket.get_ticket(100)
self.assertEqual(result, fixtures.SoftLayer_Ticket.getObject)
self.assert_called_with('SoftLayer_Ticket', 'getObject',
identifier=100)
def test_create_ticket(self):
self.ticket.create_ticket(
title="Cloud Instance Cancellation - 08/01/13",
body="body",
subject=1004)
args = ({"assignedUserId": 12345,
"contents": "body",
"subjectId": 1004,
"title": "Cloud Instance Cancellation - 08/01/13"},
"body")
self.assert_called_with('SoftLayer_Ticket', 'createStandardTicket',
args=args)
def test_update_ticket(self):
# test a full update
self.ticket.update_ticket(100, body='Update1')
self.assert_called_with('SoftLayer_Ticket', 'addUpdate',
args=({'entry': 'Update1'},),
identifier=100)
def test_attach_hardware(self):
self.ticket.attach_hardware(100, 123)
self.assert_called_with('SoftLayer_Ticket', 'addAttachedHardware',
args=(123,),
identifier=100)
def test_attach_virtual_server(self):
self.ticket.attach_virtual_server(100, 123)
self.assert_called_with('SoftLayer_Ticket', 'addAttachedVirtualGuest',
args=(123,),
identifier=100)
def test_detach_hardware(self):
self.ticket.detach_hardware(100, 123)
self.assert_called_with('SoftLayer_Ticket', 'removeAttachedHardware',
args=(123,),
identifier=100)
def test_detach_virtual_server(self):
self.ticket.detach_virtual_server(100, 123)
self.assert_called_with('SoftLayer_Ticket',
'removeAttachedVirtualGuest',
args=(123,),
identifier=100)