~psivaa/uci-engine/rabbitmq-restish-with-proxy

« back to all changes in this revision

Viewing changes to cli/tests/test_ticket.py

  • Committer: Joe Talbott
  • Date: 2014-01-27 14:54:08 UTC
  • mfrom: (126.3.8 webui)
  • mto: This revision was merged to the branch mainline in revision 161.
  • Revision ID: joe.talbott@canonical.com-20140127145408-zpubebx02y6oumxq
merge doanac's cleanup branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
        self.changes = os.path.join(os.path.dirname(__file__),
31
31
                                    'data/foobar_0.1-1_source.changes')
32
32
 
 
33
    @mock.patch('ci_libs.ticket.post',
 
34
                return_value='http://www.example.com/api/v1/sourcepackage/4/')
 
35
    def test_create_sourcepackage(self, mock_post):
 
36
        new_subticket = SubTicket(owner='foobar@example.com', ticket_id=4)
 
37
        new_subticket._parse_changes(self.changes)
 
38
        sourcepackage_uri = new_subticket._create_sourcepackage()
 
39
        mock_post.assert_called_once()
 
40
        self.assertEqual(sourcepackage_uri, '/api/v1/sourcepackage/4/')
 
41
 
33
42
    @mock.patch('ci_libs.ticket.get_sourcepackage_uri',
34
43
                return_value='/api/v1/sourcepackage/5/')
35
44
    @mock.patch('ci_libs.ticket.post',
39
48
        new_subticket._parse_changes(self.changes)
40
49
        new_subticket._create_spu()
41
50
 
42
 
    @mock.patch('ci_libs.ticket.post',
43
 
                return_value='http://www.example.com/api/v1/artifact/38/')
 
51
    @mock.patch('ci_libs.ticket.get_sourcepackage_uri', return_value='')
 
52
    @mock.patch('ci_libs.ticket.post',
 
53
                return_value='http://www.example.com/api/v1/sourcepackage/5/')
 
54
    @mock.patch('ci_libs.ticket.post',
 
55
                return_value='http://www.example.com/api/v1/spu/39/')
 
56
    def test_create_spu_sourcepackage_not_found(self, mock_spu_post, mock_post,
 
57
                                                mock_sp_uri):
 
58
        new_subticket = SubTicket(owner='foobar@example.com', ticket_id=3)
 
59
        new_subticket._parse_changes(self.changes)
 
60
        new_subticket._create_spu()
 
61
 
 
62
    @mock.patch(
 
63
        'ci_libs.ticket.post',
 
64
        return_value='http://www.example.com/api/v1/subticketartifact/38/',
 
65
    )
44
66
    def test_create_artifact(self, mock_post):
45
67
        new_subticket = SubTicket(owner='foobar@example.com', ticket_id=2)
46
68
        file = 'foobar_source.changes'
76
98
        args = self.cli.parse_arguments(args)
77
99
        new_ticket._create_ticket(args)
78
100
 
79
 
 
80
101
    @mock.patch('ci_libs.ticket.SubTicket._process')
81
102
    @mock.patch('ci_libs.ticket.post',
82
103
                return_value='http://www.example.com/api/v1/ticket/38/')
97
118
        self.assertEqual(len(new_ticket.subtickets), 1)
98
119
        self.assertTrue("foobar" in new_ticket.subtickets)
99
120
 
100
 
 
101
121
    @mock.patch('ci_libs.ticket.SubTicket._process')
102
122
    @mock.patch('ci_libs.ticket.post',
103
123
                return_value='http://www.example.com/api/v1/ticket/39/')
105
125
    def test_add_new_ticket_multiple_subtickets(self, mock_patch, mock_post,
106
126
                                                mock_process):
107
127
        changes_1 = os.path.join(os.path.dirname(__file__),
108
 
                               'data/foobar_0.1-1_source.changes')
 
128
                                 'data/foobar_0.1-1_source.changes')
109
129
        changes_2 = os.path.join(os.path.dirname(__file__),
110
 
                               'data/barfoo_0.1-1_source.changes')
 
130
                                 'data/barfoo_0.1-1_source.changes')
111
131
 
112
132
        args = ['create_ticket', '-t', 'New feature', '-b', '4321', '-o',
113
133
                'someone@example.com', '-d', 'This is a cool new feature',