Code Duplication    Length = 91-91 lines in 2 locations

tests/protocols/gmpv9/test_modify_ticket.py 1 location

@@ 27-117 (lines=91) @@
24
from . import Gmpv9TestCase
25
26
27
class GmpModifyTicketTestCase(Gmpv9TestCase):
28
    def test_modify_ticket(self):
29
        self.gmp.modify_ticket('t1')
30
31
        self.connection.send.has_been_called_with(
32
            '<modify_ticket ticket_id="t1"/>'
33
        )
34
35
        self.gmp.modify_ticket(ticket_id='t1')
36
37
        self.connection.send.has_been_called_with(
38
            '<modify_ticket ticket_id="t1"/>'
39
        )
40
41
    def test_missing_ticket_id(self):
42
        with self.assertRaises(RequiredArgument):
43
            self.gmp.modify_ticket('')
44
45
        with self.assertRaises(RequiredArgument):
46
            self.gmp.modify_ticket(None)
47
48
        with self.assertRaises(RequiredArgument):
49
            self.gmp.modify_ticket(ticket_id=None)
50
51
    def test_modify_ticket_with_comment(self):
52
        self.gmp.modify_ticket(ticket_id='t1', comment='bar')
53
54
        self.connection.send.has_been_called_with(
55
            '<modify_ticket ticket_id="t1">'
56
            '<comment>bar</comment>'
57
            '</modify_ticket>'
58
        )
59
60
    def test_modify_ticket_with_assigned_to_user_id(self):
61
        self.gmp.modify_ticket(ticket_id='t1', assigned_to_user_id='u1')
62
63
        self.connection.send.has_been_called_with(
64
            '<modify_ticket ticket_id="t1">'
65
            '<assigned_to>'
66
            '<user id="u1"/>'
67
            '</assigned_to>'
68
            '</modify_ticket>'
69
        )
70
71
    def test_modify_ticket_invalid_status(self):
72
        with self.assertRaises(InvalidArgumentType):
73
            self.gmp.modify_ticket(ticket_id='t1', status='foobar', note='bar')
74
75
    def test_modify_ticket_open(self):
76
        self.gmp.modify_ticket(
77
            ticket_id='t1', status=TicketStatus.OPEN, note='lorem ipsum'
78
        )
79
80
        self.connection.send.has_been_called_with(
81
            '<modify_ticket ticket_id="t1">'
82
            '<status>Open</status>'
83
            '<open_note>lorem ipsum</open_note>'
84
            '</modify_ticket>'
85
        )
86
87
    def test_modify_ticket_fixed(self):
88
        self.gmp.modify_ticket(
89
            ticket_id='t1', status=TicketStatus.FIXED, note='lorem ipsum'
90
        )
91
92
        self.connection.send.has_been_called_with(
93
            '<modify_ticket ticket_id="t1">'
94
            '<status>Fixed</status>'
95
            '<fixed_note>lorem ipsum</fixed_note>'
96
            '</modify_ticket>'
97
        )
98
99
    def test_modify_ticket_closed(self):
100
        self.gmp.modify_ticket(
101
            ticket_id='t1', status=TicketStatus.CLOSED, note='lorem ipsum'
102
        )
103
104
        self.connection.send.has_been_called_with(
105
            '<modify_ticket ticket_id="t1">'
106
            '<status>Closed</status>'
107
            '<closed_note>lorem ipsum</closed_note>'
108
            '</modify_ticket>'
109
        )
110
111
    def test_modify_ticket_status_without_note(self):
112
        with self.assertRaises(RequiredArgument):
113
            self.gmp.modify_ticket(ticket_id='t1', status=TicketStatus.CLOSED)
114
115
    def test_modify_ticket_note_without_status(self):
116
        with self.assertRaises(RequiredArgument):
117
            self.gmp.modify_ticket(ticket_id='t1', note='foo')
118
119
120
if __name__ == '__main__':

tests/protocols/gmpv8/test_modify_ticket.py 1 location

@@ 27-117 (lines=91) @@
24
from . import Gmpv8TestCase
25
26
27
class GmpModifyTicketTestCase(Gmpv8TestCase):
28
    def test_modify_ticket(self):
29
        self.gmp.modify_ticket('t1')
30
31
        self.connection.send.has_been_called_with(
32
            '<modify_ticket ticket_id="t1"/>'
33
        )
34
35
        self.gmp.modify_ticket(ticket_id='t1')
36
37
        self.connection.send.has_been_called_with(
38
            '<modify_ticket ticket_id="t1"/>'
39
        )
40
41
    def test_missing_ticket_id(self):
42
        with self.assertRaises(RequiredArgument):
43
            self.gmp.modify_ticket('')
44
45
        with self.assertRaises(RequiredArgument):
46
            self.gmp.modify_ticket(None)
47
48
        with self.assertRaises(RequiredArgument):
49
            self.gmp.modify_ticket(ticket_id=None)
50
51
    def test_modify_ticket_with_comment(self):
52
        self.gmp.modify_ticket(ticket_id='t1', comment='bar')
53
54
        self.connection.send.has_been_called_with(
55
            '<modify_ticket ticket_id="t1">'
56
            '<comment>bar</comment>'
57
            '</modify_ticket>'
58
        )
59
60
    def test_modify_ticket_with_assigned_to_user_id(self):
61
        self.gmp.modify_ticket(ticket_id='t1', assigned_to_user_id='u1')
62
63
        self.connection.send.has_been_called_with(
64
            '<modify_ticket ticket_id="t1">'
65
            '<assigned_to>'
66
            '<user id="u1"/>'
67
            '</assigned_to>'
68
            '</modify_ticket>'
69
        )
70
71
    def test_modify_ticket_invalid_status(self):
72
        with self.assertRaises(InvalidArgumentType):
73
            self.gmp.modify_ticket(ticket_id='t1', status='foobar', note='bar')
74
75
    def test_modify_ticket_open(self):
76
        self.gmp.modify_ticket(
77
            ticket_id='t1', status=TicketStatus.OPEN, note='lorem ipsum'
78
        )
79
80
        self.connection.send.has_been_called_with(
81
            '<modify_ticket ticket_id="t1">'
82
            '<status>Open</status>'
83
            '<open_note>lorem ipsum</open_note>'
84
            '</modify_ticket>'
85
        )
86
87
    def test_modify_ticket_fixed(self):
88
        self.gmp.modify_ticket(
89
            ticket_id='t1', status=TicketStatus.FIXED, note='lorem ipsum'
90
        )
91
92
        self.connection.send.has_been_called_with(
93
            '<modify_ticket ticket_id="t1">'
94
            '<status>Fixed</status>'
95
            '<fixed_note>lorem ipsum</fixed_note>'
96
            '</modify_ticket>'
97
        )
98
99
    def test_modify_ticket_closed(self):
100
        self.gmp.modify_ticket(
101
            ticket_id='t1', status=TicketStatus.CLOSED, note='lorem ipsum'
102
        )
103
104
        self.connection.send.has_been_called_with(
105
            '<modify_ticket ticket_id="t1">'
106
            '<status>Closed</status>'
107
            '<closed_note>lorem ipsum</closed_note>'
108
            '</modify_ticket>'
109
        )
110
111
    def test_modify_ticket_status_without_note(self):
112
        with self.assertRaises(RequiredArgument):
113
            self.gmp.modify_ticket(ticket_id='t1', status=TicketStatus.CLOSED)
114
115
    def test_modify_ticket_note_without_status(self):
116
        with self.assertRaises(RequiredArgument):
117
            self.gmp.modify_ticket(ticket_id='t1', note='foo')
118
119
120
if __name__ == '__main__':