forked from openSUSE/openSUSE-release-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_bugowner_tests.py
109 lines (74 loc) · 3.91 KB
/
check_bugowner_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
import logging
from . import OBSLocal
from check_bugowner import CheckerBugowner
import pytest
PROJECT = "SLE:Next-SP"
@pytest.fixture
def default_config(request):
wf = OBSLocal.FactoryWorkflow(PROJECT)
project = wf.projects[PROJECT]
request.cls.bot_user = 'factory-auto'
wf.create_user(request.cls.bot_user)
# When creating a review, set the by_user to bot_user
project.add_reviewers(users=[request.cls.bot_user])
request.cls.wf = wf
request.cls.review_bot = CheckerBugowner(request.cls.wf.apiurl, user=request.cls.bot_user, logger=logging.getLogger())
yield "workflow"
del request.cls.wf
class TestCheckBugowner(OBSLocal.TestCase):
@pytest.mark.usefixtures("default_config")
def test_no_bugowner(self):
"""Declines the request for a new package"""
req_id = self.wf.create_submit_request('devel:wine', 'merlot').reqid
self.assertReview(req_id, by_user=(self.bot_user, 'new'))
self.review_bot.set_request_ids([req_id])
self.review_bot.check_requests()
review = self.assertReview(req_id, by_user=(self.bot_user, 'declined'))
self.assertIn('merlot appears to be a new package', review.comment)
@pytest.mark.usefixtures("default_config")
def test_existing_package(self):
"""Accepts requests for existing packages"""
self.wf.create_package(PROJECT, 'merlot')
req_id = self.wf.create_submit_request('devel:wine', 'merlot').reqid
self.assertReview(req_id, by_user=(self.bot_user, 'new'))
self.review_bot.set_request_ids([req_id])
self.review_bot.check_requests()
review = self.assertReview(req_id, by_user=(self.bot_user, 'accepted'))
self.assertEqual('ok', review.comment)
@pytest.mark.usefixtures("default_config")
def test_invalid_bugowner(self):
"""Declines the request for a new package because of wrong maintainer"""
req_id = self.wf.create_submit_request('devel:wine', 'merlot', description="bugowner: thatguythere").reqid
self.assertReview(req_id, by_user=(self.bot_user, 'new'))
self.review_bot.set_request_ids([req_id])
self.review_bot.check_requests()
review = self.assertReview(req_id, by_user=(self.bot_user, 'declined'))
self.assertIn('thatguythere could not be found on this instance.', review.comment)
@pytest.mark.usefixtures("default_config")
def test_valid_bugowner(self):
"""Accept request with valid maintainer"""
self.wf.create_user('thegirl')
req_id = self.wf.create_submit_request('devel:wine', 'merlot', description="bugowner: thegirl").reqid
self.assertReview(req_id, by_user=(self.bot_user, 'new'))
self.review_bot.set_request_ids([req_id])
self.review_bot.check_requests()
self.assertReview(req_id, by_user=(self.bot_user, 'accepted'))
@pytest.mark.usefixtures("default_config")
def test_valid_bugowner_with_space(self):
"""Accept request with valid maintainer with space"""
self.wf.create_user('thegirl')
req_id = self.wf.create_submit_request('devel:wine', 'merlot', description="bugowner: thegirl ").reqid
self.assertReview(req_id, by_user=(self.bot_user, 'new'))
self.review_bot.set_request_ids([req_id])
self.review_bot.check_requests()
self.assertReview(req_id, by_user=(self.bot_user, 'accepted'))
@pytest.mark.usefixtures("default_config")
def test_valid_bugowner_group(self):
"""Accept request with valid group maintainer"""
self.wf.create_group('coldpool')
req_id = self.wf.create_submit_request(
'devel:wine', 'merlot', description="This is a cool new package\nbugowner: group:coldpool").reqid
self.assertReview(req_id, by_user=(self.bot_user, 'new'))
self.review_bot.set_request_ids_search_review()
self.review_bot.check_requests()
self.assertReview(req_id, by_user=(self.bot_user, 'accepted'))