forked from openSUSE/openSUSE-release-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaintenance_tests.py
286 lines (254 loc) · 14.2 KB
/
maintenance_tests.py
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
import os
import unittest
import logging
import httpretty
from . import OBSLocal
from urllib.parse import urlparse, parse_qs
from check_maintenance_incidents import MaintenanceChecker
APIURL = 'http://0.0.0.0:3000'
FIXTURES = os.path.join(os.getcwd(), 'tests/fixtures')
class TestMaintenance(OBSLocal.TestCase):
def setUp(self):
"""
Initialize the configuration
"""
super().setUp()
httpretty.reset()
httpretty.enable()
logging.basicConfig()
self.logger = logging.getLogger(__file__)
self.logger.setLevel(logging.DEBUG)
self.checker = MaintenanceChecker(apiurl=APIURL,
user='maintbot',
logger=self.logger)
self.checker.override_allow = False # Test setup cannot handle.
def test_non_maintainer_submit(self):
"""same as above but already has devel project as reviewer
"""
httpretty.register_uri(httpretty.GET,
APIURL + '/search/request',
body="""
<collection matches="1">
<request id="261355" creator="brassh">
<action type="maintenance_incident">
<source project="home:brassh" package="mysql-workbench" rev="857c77d2ba1d347b6dc50a1e5bcb74e1"/>
<target project="openSUSE:Maintenance" releaseproject="openSUSE:13.2:Update"/>
</action>
<state name="review" who="lnussel_factory" when="2014-11-13T10:46:52">
<comment></comment>
</state>
<review state="new" by_user="maintbot">
<comment></comment>
</review>
<history who="brassh" when="2014-11-13T09:18:19">
<description>Request created</description>
<comment>...</comment>
</history>
<history who="lnussel_factory" when="2014-11-13T10:46:52">
<description>Request got a new review request</description>
</history>
<description>...</description>
</request>
</collection>
""")
httpretty.register_uri(httpretty.GET,
APIURL + "/request/261355",
match_querystring=True,
body="""
<request id="261355" creator="brassh">
<action type="maintenance_incident">
<source project="home:brassh" package="mysql-workbench" rev="857c77d2ba1d347b6dc50a1e5bcb74e1"/>
<target project="openSUSE:Maintenance" releaseproject="openSUSE:13.2:Update"/>
</action>
<state name="review" who="lnussel_factory" when="2014-11-13T10:46:52">
<comment></comment>
</state>
<review state="new" by_user="maintbot">
<comment></comment>
</review>
<history who="brassh" when="2014-11-13T09:18:19">
<description>Request created</description>
<comment>...</comment>
</history>
<history who="lnussel_factory" when="2014-11-13T10:46:52">
<description>Request got a new review request</description>
</history>
<description>...</description>
</request>
""")
httpretty.register_uri(httpretty.GET,
APIURL + "/source/home:brassh/mysql-workbench",
match_querystring=True,
body="""
<directory name="mysql-workbench" rev="6" vrev="6" srcmd5="858204decf53f923d5574dbe6ae63b15">
<linkinfo project="openSUSE:13.2" package="mysql-workbench" srcmd5="ed9c3b12388cbd14868eb3faabe34685"
baserev="ed9c3b12388cbd14868eb3faabe34685" xsrcmd5="08bfb4f40cb1e2de8f9cd4633bf02eb1"
lsrcmd5="858204decf53f923d5574dbe6ae63b15" />
<serviceinfo code="succeeded" xsrcmd5="6ec4305a8e5363e26a7f4895a0ae12d2" />
<entry name="_link" md5="85ef5fb38ca1ec7c300311fda9f4b3d1" size="121" mtime="1414567341" />
<entry name="mysql-workbench-community-6.1.7-src.tar.gz" md5="ac059e239869fb77bf5d7a1f5845a8af"
size="24750696" mtime="1404405925" />
<entry name="mysql-workbench-ctemplate.patch" md5="06ccba1f8275cd9408f515828ecede19" size="1322" mtime="1404658323" />
<entry name="mysql-workbench-glib.patch" md5="67fd7d8e3503ce0909381bde747c8a1e" size="1785" mtime="1415732509" />
<entry name="mysql-workbench-mysql_options4.patch" md5="9c07dfe1b94af95daf3e16bd6a161684"
size="910" mtime="1404658324" />
<entry name="mysql-workbench-no-check-for-updates.patch" md5="1f0c9514ff8218d361ea46d3031b2b64"
size="1139" mtime="1404658324" />
<entry name="mysql-workbench.changes" md5="26bc54777e6a261816b72f64c69630e4" size="13354" mtime="1415747835" />
<entry name="mysql-workbench.spec" md5="88b562a93f01b842a5798f809e3c8188" size="7489" mtime="1415745943" />
<entry name="openSUSE_(Vendor_Package).xml" md5="ab041af98d7748c216e7e5787ec36f65"
size="743" mtime="1315923090" />
<entry name="patch-desktop-categories.patch" md5="c24b3283573c34a5e072be122388f8e1"
size="391" mtime="1376991147" />
</directory>
""")
result = {'devel_review_added': None}
def change_request(result, method, uri, headers):
query = parse_qs(urlparse(uri).query)
if query == {'by_user': ['maintbot'], 'cmd': ['changereviewstate'], 'newstate': ['accepted']}:
result['devel_review_added'] = True
return (200, headers, '<status code="ok"/>')
httpretty.register_uri(httpretty.POST,
APIURL + "/request/261355",
body=lambda method, uri, headers: change_request(result, method, uri, headers))
httpretty.register_uri(httpretty.GET,
APIURL + "/search/owner?project=openSUSE:13.2:Update&binary=mysql-workbench",
match_querystring=True,
body="""
<collection/>
""")
httpretty.register_uri(httpretty.GET,
APIURL + "/search/owner?binary=mysql-workbench",
match_querystring=True,
body="""
<collection>
<owner rootproject="openSUSE" project="server:database" package="mysql-workbench">
<person name="Gankov" role="maintainer"/>
<person name="bruno_friedmann" role="maintainer"/>
</owner>
</collection>
""")
self.checker.requests = []
self.checker.set_request_ids_search_review()
self.checker.check_requests()
self.assertTrue(result['devel_review_added'])
def test_non_maintainer_double_review(self):
httpretty.register_uri(httpretty.GET,
APIURL + '/search/request',
body="""
<collection matches="1">
<request id="261355" creator="brassh">
<action type="maintenance_incident">
<source project="home:brassh" package="mysql-workbench" rev="857c77d2ba1d347b6dc50a1e5bcb74e1"/>
<target project="openSUSE:Maintenance" releaseproject="openSUSE:13.2:Update"/>
</action>
<state name="review" who="lnussel_factory" when="2014-11-13T10:46:52">
<comment></comment>
</state>
<review state="new" by_user="maintbot">
<comment></comment>
</review>
<review state="new" by_package="mysql-workbench" by_project="server:database">
<comment>review by devel project</comment>
</review>
<history who="brassh" when="2014-11-13T09:18:19">
<description>Request created</description>
<comment>...</comment>
</history>
<history who="lnussel_factory" when="2014-11-13T10:46:52">
<description>Request got a new review request</description>
</history>
<description>...</description>
</request>
</collection>
""")
httpretty.register_uri(httpretty.GET,
APIURL + "/request/261355",
match_querystring=True,
body="""
<request id="261355" creator="brassh">
<action type="maintenance_incident">
<source project="home:brassh" package="mysql-workbench" rev="857c77d2ba1d347b6dc50a1e5bcb74e1"/>
<target project="openSUSE:Maintenance" releaseproject="openSUSE:13.2:Update"/>
</action>
<state name="review" who="lnussel_factory" when="2014-11-13T10:46:52">
<comment></comment>
</state>
<review state="new" by_user="maintbot">
<comment></comment>
</review>
<review state="new" by_package="mysql-workbench" by_project="server:database">
<comment>review by devel project</comment>
</review>
<history who="brassh" when="2014-11-13T09:18:19">
<description>Request created</description>
<comment>...</comment>
</history>
<history who="lnussel_factory" when="2014-11-13T10:46:52">
<description>Request got a new review request</description>
</history>
<description>...</description>
</request>
""")
httpretty.register_uri(httpretty.GET,
APIURL + "/source/home:brassh/mysql-workbench",
match_querystring=True,
body="""
<directory name="mysql-workbench" rev="6" vrev="6" srcmd5="858204decf53f923d5574dbe6ae63b15">
<linkinfo project="openSUSE:13.2" package="mysql-workbench"
srcmd5="ed9c3b12388cbd14868eb3faabe34685" baserev="ed9c3b12388cbd14868eb3faabe34685"
xsrcmd5="08bfb4f40cb1e2de8f9cd4633bf02eb1" lsrcmd5="858204decf53f923d5574dbe6ae63b15" />
<serviceinfo code="succeeded" xsrcmd5="6ec4305a8e5363e26a7f4895a0ae12d2" />
<entry name="_link" md5="85ef5fb38ca1ec7c300311fda9f4b3d1" size="121" mtime="1414567341" />
<entry name="mysql-workbench-community-6.1.7-src.tar.gz" md5="ac059e239869fb77bf5d7a1f5845a8af"
size="24750696" mtime="1404405925" />
<entry name="mysql-workbench-ctemplate.patch" md5="06ccba1f8275cd9408f515828ecede19"
size="1322" mtime="1404658323" />
<entry name="mysql-workbench-glib.patch" md5="67fd7d8e3503ce0909381bde747c8a1e"
size="1785" mtime="1415732509" />
<entry name="mysql-workbench-mysql_options4.patch" md5="9c07dfe1b94af95daf3e16bd6a161684"
size="910" mtime="1404658324" />
<entry name="mysql-workbench-no-check-for-updates.patch" md5="1f0c9514ff8218d361ea46d3031b2b64"
size="1139" mtime="1404658324" />
<entry name="mysql-workbench.changes" md5="26bc54777e6a261816b72f64c69630e4"
size="13354" mtime="1415747835" />
<entry name="mysql-workbench.spec" md5="88b562a93f01b842a5798f809e3c8188"
size="7489" mtime="1415745943" />
<entry name="openSUSE_(Vendor_Package).xml" md5="ab041af98d7748c216e7e5787ec36f65"
size="743" mtime="1315923090" />
<entry name="patch-desktop-categories.patch" md5="c24b3283573c34a5e072be122388f8e1"
size="391" mtime="1376991147" />
</directory>
""")
result = {'devel_review_added': None}
def change_request(result, method, uri, headers):
u = urlparse(uri)
if u.query == 'by_package=mysql-workbench&cmd=addreview&by_project=server%3Adatabase':
result['devel_review_added'] = True
return (200, headers, '<status code="ok"/>')
httpretty.register_uri(httpretty.POST,
APIURL + "/request/261355",
body=lambda method, uri, headers: change_request(result, method, uri, headers))
httpretty.register_uri(httpretty.GET,
APIURL + "/search/owner?project=openSUSE:13.2:Update&binary=mysql-workbench",
match_querystring=True,
body="""
<collection/>
""")
httpretty.register_uri(httpretty.GET,
APIURL + "/search/owner?binary=mysql-workbench",
match_querystring=True,
body="""
<collection>
<owner rootproject="openSUSE" project="server:database" package="mysql-workbench">
<person name="Gankov" role="maintainer"/>
<person name="bruno_friedmann" role="maintainer"/>
</owner>
</collection>
""")
self.checker.requests = []
self.checker.set_request_ids_search_review()
self.checker.check_requests()
self.assertFalse(result['devel_review_added'])
if __name__ == '__main__':
unittest.main()