diff --git a/bodhi-messages/bodhi/messages/schemas/update.py b/bodhi-messages/bodhi/messages/schemas/update.py index 9c3231869a..942b29ce3d 100644 --- a/bodhi-messages/bodhi/messages/schemas/update.py +++ b/bodhi-messages/bodhi/messages/schemas/update.py @@ -1028,3 +1028,118 @@ def __str__(self) -> str: f"{self.body['update']['user']['name']}'s Bodhi update is ready for testing\n" f"Builds:\n" f"{new_line.join([b['nvr'] for b in self.body['artifact']['builds']])} ") + + +class UpdateReadyForTestingV3(UpdateMessage): + """ + Sent when an update is ready to be tested. Simplified version. + + Specifically, this message is sent: + + * When an update is created + * When an update is edited and its builds change + * When a "re-trigger tests" request is made via the web UI or API + + These are the points where we expect that automated systems will + test the update. + + Inherits from UpdateMessage and only contains as much extra + information (in the 'artifact' dict) as the Fedora CI schedulers + actually need. + """ + + body_schema = { + 'id': f'{SCHEMA_URL}/v1/bodhi.update.status.testing#', + '$schema': 'http://json-schema.org/draft-04/schema#', + 'description': 'Schema for message sent when an update is ready for testing', + 'type': 'object', + 'properties': { + 'agent': { + 'type': 'string', + 'description': 'Re-trigger request: name of requester, trigger on push: "bodhi".', + }, + 'artifact': { + 'description': 'Details about the builds to test.', + 'type': 'object', + 'properties': { + 'type': { + 'description': 'Artifact type, in this case "koji-build-group".', + 'type': 'string', + }, + 'builds': { + 'type': 'array', + 'description': 'A list of builds included in this group', + 'items': {'$ref': '#/definitions/artifactbuild'} + }, + }, + 'required': ['type', 'builds'], + }, + 're-trigger': { + 'type': 'boolean', + 'description': 'This flag is True if the message is sent to re-trigger tests' + }, + 'update': UpdateV1.schema(), + }, + 'required': ['agent', 'artifact', 'update'], + 'definitions': { + 'artifactbuild': { + 'description': 'Details about a build that are not in the update builds dict', + 'type': 'object', + 'properties': { + 'type': { + 'description': 'Artifact type, in this case "koji-build"', + 'type': 'string', + }, + 'id': { + 'description': 'Build ID of the koji build.', + 'type': 'integer', + }, + 'task_id': { + 'description': 'Task ID of the koji build.', + 'type': ['null', 'integer'], + }, + 'nvr': { + 'description': 'Name-version-release of the artifact.', + 'type': 'string', + } + }, + 'required': ['type', 'id', 'task_id', 'nvr'], + }, + 'build': BuildV1.schema(), + } + } + + topic = "bodhi.update.status.testing.koji-build-group.build.complete" + severity = DEBUG + + @property + def summary(self) -> str: + """ + Return a short, human-readable representation of this message. + + This should provide a short summary of the message, much like the subject line + of an email. + + Returns: + A summary for this message. + """ + return ( + f"{self.update.user.name}'s {self._builds_summary} " + f"bodhi update is ready for testing") + + def __str__(self) -> str: + """ + Return a human-readable representation of this message. + + This should provide a detailed representation of the message, much like the body + of an email. + + Returns: + A human readable representation of this message. + """ + new_line = "\n" + return ( + f"{self.update.user.name}'s Bodhi update {self.update.alias} " + f"is ready for testing\n" + f"Builds:\n" + f"{new_line.join([b.nvr for b in self.update.builds])} ") diff --git a/bodhi-messages/pyproject.toml b/bodhi-messages/pyproject.toml index 10790b53f2..6df29e70c6 100644 --- a/bodhi-messages/pyproject.toml +++ b/bodhi-messages/pyproject.toml @@ -60,6 +60,7 @@ diff-cover = ">=4.2.1" "bodhi.update.complete.testing.v1" = "bodhi.messages.schemas.update:UpdateCompleteTestingV1" "bodhi.update.status.testing.v1" = "bodhi.messages.schemas.update:UpdateReadyForTestingV1" "bodhi.update.status.testing.v2" = "bodhi.messages.schemas.update:UpdateReadyForTestingV2" +"bodhi.update.status.testing.v3" = "bodhi.messages.schemas.update:UpdateReadyForTestingV3" "bodhi.update.edit.v1" = "bodhi.messages.schemas.update:UpdateEditV1" "bodhi.update.edit.v2" = "bodhi.messages.schemas.update:UpdateEditV2" "bodhi.update.eject.v1" = "bodhi.messages.schemas.update:UpdateEjectV1" diff --git a/bodhi-messages/tests/test_update.py b/bodhi-messages/tests/test_update.py index 7b3757646a..edf4b1fa7c 100644 --- a/bodhi-messages/tests/test_update.py +++ b/bodhi-messages/tests/test_update.py @@ -27,6 +27,7 @@ UpdateKarmaThresholdV1, UpdateReadyForTestingV1, UpdateReadyForTestingV2, + UpdateReadyForTestingV3, UpdateRequestObsoleteV1, UpdateRequestRevokeV1, UpdateRequestStableV1, @@ -317,6 +318,60 @@ def test_ready_for_testing_v2(self): ) check_message(msg, expected) + def test_ready_for_testing_v3(self): + expected = { + "topic": "bodhi.update.status.testing.koji-build-group.build.complete", + "summary": ( + "plautrba's libselinux-2.8-6.fc29.x86_64 libsepol-2.… bodhi update " + "is ready for testing" + ), + "__str__": ( + "plautrba's Bodhi update FEDORA-2019-d64d0caab3 is ready for testing\nBuilds:" + "\nlibselinux-2.8-6.fc29.x86_64\nlibsepol-2.8-3.fc29.x86_64 " + ), + "app_icon": "https://apps.fedoraproject.org/img/icons/bodhi.png", + "app_name": "bodhi", + "url": "https://bodhi.fedoraproject.org/updates/FEDORA-2019-d64d0caab3", + "agent_avatar": ( + "https://seccdn.libravatar.org/avatar/" + "20652954adacfd9f6e26536bbcf3b5fbc850dc61f8a2e67c5bfbc6e345032976" + "?s=64&d=retro" + ), + "usernames": ["mohanboddu", "plautrba"], + "packages": ["libselinux", "libsepol"], + } + msg = UpdateReadyForTestingV3( + body={ + "artifact": { + "type": "koji-build-group", + "builds": + [{ + "type": "koji-build", + "id": 14546275, + "task_id": 14546276, + "nvr": "libselinux-2.8-6.fc29.x86_64", + }, { + "type": "koji-build", + "id": 14546278, + "task_id": None, + "nvr": "libsepol-2.8-3.fc29.x86_64", + }], + }, + "update": { + "alias": "FEDORA-2019-d64d0caab3", + "builds": [{"nvr": "libselinux-2.8-6.fc29.x86_64"}, + {"nvr": "libsepol-2.8-3.fc29.x86_64"}], + "title": "flibselinux-2.8-6.fc29", + 'release': {"name": "F29"}, + 'request': None, + "status": "testing", + "user": {"name": "plautrba"} + }, + "agent": "mohanboddu", + } + ) + check_message(msg, expected) + def test_request_testing_v1_multiple(self): expected = { "topic": "bodhi.update.request.testing", diff --git a/bodhi-server/bodhi/server/buildsys.py b/bodhi-server/bodhi/server/buildsys.py index 2bd42eb830..8e38200952 100644 --- a/bodhi-server/bodhi/server/buildsys.py +++ b/bodhi-server/bodhi/server/buildsys.py @@ -208,7 +208,9 @@ def getBuild(self, build='TurboGears-1.0.2.2-2.fc17', other=False, testing=False 'package_name': 'gnome-backgrounds', 'release': '1.fc17', 'tag_name': 'f17-build-side-7777', - 'version': '3.0'} + 'version': '3.0', + 'id': 16061, + 'task_id': 15051} theid = 16058 if other and not testing: diff --git a/bodhi-server/bodhi/server/models.py b/bodhi-server/bodhi/server/models.py index 8da3fad230..83360c8328 100644 --- a/bodhi-server/bodhi/server/models.py +++ b/bodhi-server/bodhi/server/models.py @@ -2009,13 +2009,14 @@ def __init__(self, *args, **kwargs): alias = '%s-%s-%s' % (prefix, year, id) self.alias = alias self.release_id = kwargs['release'].id + # we need this to be set for message publishing to work + self.status = kwargs.get('status', UpdateStatus.pending) super(Update, self).__init__(*args, **kwargs) log.debug('Set alias for %s to %s' % (self.get_title(), alias)) - if self.status == UpdateStatus.testing: - self._ready_for_testing(self, self.status, None, None) + self._ready_for_testing(self, None) @property def version_hash(self): @@ -2716,6 +2717,11 @@ def edit(cls, request, data): 'removed_builds': removed_builds } )) + if (new_builds or removed_builds) and up.content_type == ContentType.rpm: + message = update_schemas.UpdateReadyForTestingV3.from_dict( + message=up._build_group_test_message(agent=request.identity.name) + ) + notifications.publish(message) # If editing a Pending update, all of whose builds are signed, for a release # which isn't composed by Bodhi (i.e. Rawhide), move it directly to Testing. @@ -4215,10 +4221,10 @@ def _build_group_test_message(self, agent="bodhi", retrigger=False): """ Build the dictionary sent when an update is ready to be tested. - This is used in bodhi.server.models.Update._ready_for_testing and in - bodhi.server.services.updates.trigger_tests which are the two places - where we send notifications about an update being ready to be tested - by any CI system. + This is used when we send notifications about an update being + ready to be tested by any CI system - on update creation, any + time the update is edited and its builds change, and if someone + sends a Re-Trigger Tests request via the web UI or API. Args: agent (str): For the case where the message is sent as a test @@ -4229,59 +4235,40 @@ def _build_group_test_message(self, agent="bodhi", retrigger=False): Returns: dict: A dictionary corresponding to the message sent """ - contact = { - "name": "Bodhi", - "email": "admin@fp.o", - "team": "Fedora CI", - "docs": "https://docs.fedoraproject.org/en-US/ci/", - } builds = [] for build in self.builds: builds.append({ "type": "koji-build", "id": build.get_build_id(), "task_id": build.get_task_id(), - "issuer": build.get_owner_name(), - "component": build.nvr_name, "nvr": build.nvr, - "scratch": False, }) artifact = { "type": "koji-build-group", - "id": f"{self.alias}-{self.version_hash}", - "repository": self.abs_url(), "builds": builds, - "release": self.release.dist_tag, } return { - "contact": contact, "artifact": artifact, "update": self, - "generated_at": datetime.utcnow().isoformat() + 'Z', - "version": "0.2.2", 'agent': agent, 're-trigger': retrigger, } @staticmethod - def _ready_for_testing(target, value, old, initiator): + def _ready_for_testing(target, old): """ - Signal that the update has been moved to testing. + Signal that the update is ready for testing. - This happens in the following cases: - - for stable releases: the update lands in the testing repository - - for rawhide: all packages in an update have been built by koji + This happens when the update is created. The same message is + also published when the update is edited and its builds change + and when a "re-trigger tests" request is sent, but not by this + method. Args: - target (Update): The update that has had a change to its status attribute. - value (EnumSymbol): The new value of Update.status. - old (EnumSymbol): The old value of the Update.status - initiator (sqlalchemy.orm.attributes.Event): The event object that is initiating this - transition. + target (Update): The update that has been created. + old (EnumSymbol): The old value of the Update.status. """ - if value != UpdateStatus.testing or value == old: - return if old == NEVER_SET: # This is the object initialization phase. This instance is not ready, don't create # the message now. This method will be called again at the end of __init__ @@ -4289,7 +4276,7 @@ def _ready_for_testing(target, value, old, initiator): if target.content_type != ContentType.rpm: return - message = update_schemas.UpdateReadyForTestingV2.from_dict( + message = update_schemas.UpdateReadyForTestingV3.from_dict( message=target._build_group_test_message() ) notifications.publish(message) @@ -4304,14 +4291,6 @@ def _ready_for_testing(target, value, old, initiator): ) -event.listen( - Update.status, - 'set', - Update._ready_for_testing, - active_history=True, -) - - class Compose(Base): """ Express the status of an in-progress compose job. diff --git a/bodhi-server/bodhi/server/services/updates.py b/bodhi-server/bodhi/server/services/updates.py index 225d7fa6b9..297b21dd28 100644 --- a/bodhi-server/bodhi/server/services/updates.py +++ b/bodhi-server/bodhi/server/services/updates.py @@ -757,7 +757,7 @@ def trigger_tests(request): request.errors.add('body', 'request', 'Update is not in testing status') else: if update.content_type == ContentType.rpm: - message = update_schemas.UpdateReadyForTestingV2.from_dict( + message = update_schemas.UpdateReadyForTestingV3.from_dict( message=update._build_group_test_message(agent=request.identity.name, retrigger=True) ) diff --git a/bodhi-server/tests/base.py b/bodhi-server/tests/base.py index 4d2d92145f..15d24f52f7 100644 --- a/bodhi-server/tests/base.py +++ b/bodhi-server/tests/base.py @@ -141,11 +141,12 @@ def create_update(session, build_nvrs, release_name='F17'): expiration_date=expiration_date) session.add(override) - update = models.Update( - builds=builds, user=user, request=models.UpdateRequest.testing, - notes='Useful details!', type=models.UpdateType.bugfix, - date_submitted=datetime(1984, 11, 2), - requirements='rpmlint', stable_karma=3, unstable_karma=-3, release=release) + with mock.patch('bodhi.server.models.notifications'): + update = models.Update( + builds=builds, user=user, request=models.UpdateRequest.testing, + notes='Useful details!', type=models.UpdateType.bugfix, + date_submitted=datetime(1984, 11, 2), + requirements='rpmlint', stable_karma=3, unstable_karma=-3, release=release) session.add(update) return update @@ -185,7 +186,8 @@ def populate(db): db.flush() # This mock will help us generate a consistent update alias. with mock.patch(target='uuid.uuid4', return_value='wat'): - update = create_update(db, ['bodhi-2.0-1.fc17']) + with mock.patch('bodhi.server.models.notifications'): + update = create_update(db, ['bodhi-2.0-1.fc17']) update.type = models.UpdateType.bugfix update.severity = models.UpdateSeverity.medium bug = models.Bug(bug_id=12345) @@ -247,11 +249,12 @@ def _setup_method(self): self.db = Session() self.db.begin_nested() + buildsys.setup_buildsystem({'buildsystem': 'dev'}) + if self._populate_db: populate(self.db) bugs.set_bugtracker() - buildsys.setup_buildsystem({'buildsystem': 'dev'}) self._request_sesh = mock.patch('bodhi.server.webapp._complete_database_session', webapp._rollback_or_commit) diff --git a/bodhi-server/tests/consumers/test_automatic_updates.py b/bodhi-server/tests/consumers/test_automatic_updates.py index 85e6766d62..4af21921c3 100644 --- a/bodhi-server/tests/consumers/test_automatic_updates.py +++ b/bodhi-server/tests/consumers/test_automatic_updates.py @@ -42,6 +42,7 @@ @mock.patch('bodhi.server.consumers.automatic_updates.work_on_bugs_task', mock.Mock()) +@mock.patch('bodhi.server.models.notifications', mock.Mock()) class TestAutomaticUpdateHandler(base.BasePyTestCase): """Test the automatic update handler.""" diff --git a/bodhi-server/tests/consumers/test_signed.py b/bodhi-server/tests/consumers/test_signed.py index 449e104ac1..19866d935d 100644 --- a/bodhi-server/tests/consumers/test_signed.py +++ b/bodhi-server/tests/consumers/test_signed.py @@ -232,8 +232,7 @@ def test_consume_from_tag_not_signed(self, mock_build_model): def test_consume_from_tag(self): """ Assert that update created from tag is handled correctly when message - is received. - Update status is changed to testing and corresponding message is sent. + is received: update status is changed to testing. """ self.handler.db_factory = base.TransactionalSessionMaker(self.Session) update = self.db.query(Update).join(Build).filter(Build.nvr == 'bodhi-2.0-1.fc17').one() @@ -265,8 +264,7 @@ def test_consume_from_tag(self): 'unsatisfied_requirements': [] } mock_greenwave.return_value = greenwave_response - with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV2): - self.handler(self.sample_side_tag_message) + self.handler(self.sample_side_tag_message) assert update.builds[0].signed is True assert update.builds[0].update.request is None diff --git a/bodhi-server/tests/services/test_updates.py b/bodhi-server/tests/services/test_updates.py index ad7ba69577..3b4df53889 100644 --- a/bodhi-server/tests/services/test_updates.py +++ b/bodhi-server/tests/services/test_updates.py @@ -153,7 +153,8 @@ def test_unicode_description(self, *args): update = self.get_update('bodhi-2.0.0-2.fc17') update['notes'] = 'This is wünderfül' - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): r = self.app.post_json('/updates/', update) up = r.json_body @@ -196,7 +197,8 @@ def test_unpushed_update(self, *args): unpushed_update.status = UpdateStatus.unpushed self.db.commit() - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): res = self.app.post_json('/updates/', self.get_update('whoopsie-1.0.0-1.fc17')) assert res.json['alias'] != unpushed_update.alias @@ -244,7 +246,8 @@ def test_provenpackager_privs(self, *args): update = self.get_update('bodhi-2.1-1.fc17') update['csrf_token'] = app.get('/csrf').json_body['csrf_token'] - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): res = app.post_json('/updates/', update) assert 'bodhi does not have commit access to bodhi' not in res @@ -265,7 +268,8 @@ def test_put_json_update(self): @mock.patch.dict('bodhi.server.validators.config', {'acl_system': 'dummy'}) @mock.patch(**mock_valid_requirements) def test_post_json_update(self, *args): - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): self.app.post_json('/updates/', self.get_update('bodhi-2.0.0-1.fc17')) @mock.patch.dict('bodhi.server.validators.config', {'acl_system': 'dummy'}) @@ -281,7 +285,8 @@ def test_update_notes_exceed_maximum(self, *args): @mock.patch(**mock_uuid4_version1) @mock.patch(**mock_valid_requirements) def test_new_rpm_update(self, *args): - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): r = self.app.post_json('/updates/', self.get_update('bodhi-2.0.0-2.fc17')) up = r.json_body @@ -378,7 +383,10 @@ def test_new_rpm_update_from_tag(self, handle_side_and_related_tags_task, rawhid update['stable_days'] = 7 with mock.patch('bodhi.server.buildsys.DevBuildsys.getTag', self.mock_getTag): with mock.patch('bodhi.server.models.Release.mandatory_days_in_testing', 0): - r = self.app.post_json('/updates/', update) + # we don't use mock_sends here as we want to do some custom checking + with mock.patch('bodhi.server.models.notifications.publish') as mockpub: + r = self.app.post_json('/updates/', update) + msg = mockpub.call_args.args[0] up = r.json_body assert up['title'] == 'gnome-backgrounds-3.0-1.fc17' @@ -409,6 +417,12 @@ def test_new_rpm_update_from_tag(self, handle_side_and_related_tags_task, rawhid assert up['autotime'] is False assert up['stable_days'] == 7 + assert msg.body['artifact']['builds'][0]['nvr'] == 'gnome-backgrounds-3.0-1.fc17' + assert msg.body['artifact']['builds'][0]['task_id'] == 15051 + assert msg.body['artifact']['builds'][0]['id'] == 16061 + assert msg.body['artifact']['type'] == 'koji-build-group' + assert msg.packages == ['gnome-backgrounds'] + resp = self.app.get(f"/updates/{up['alias']}", headers={'Accept': 'text/html'}) handle_side_and_related_tags_task.delay.assert_called_once() @@ -485,7 +499,8 @@ def test_koji_config_url(self, *args): self.registry.settings['koji_web_url'] = \ 'https://koji.fedoraproject.org/koji/' nvr = 'bodhi-2.0.0-2.fc17' - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', self.get_update(nvr)) resp = self.app.get(f"/updates/{resp.json['alias']}", headers={'Accept': 'text/html'}) @@ -501,7 +516,8 @@ def test_koji_config_url_without_trailing_slash(self, *args): self.registry.settings['koji_web_url'] = \ 'https://koji.fedoraproject.org/koji' nvr = 'bodhi-2.0.0-2.fc17' - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', self.get_update(nvr)) resp = self.app.get(f"/updates/{resp.json['alias']}", headers={'Accept': 'text/html'}) @@ -517,7 +533,8 @@ def test_koji_config_mock_url_without_trailing_slash(self, *args): """ self.registry.settings['koji_web_url'] = 'https://host.org' nvr = 'bodhi-2.0.0-2.fc17' - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', self.get_update(nvr)) resp = self.app.get(f"/updates/{resp.json['alias']}", headers={'Accept': 'text/html'}) @@ -710,7 +727,8 @@ def test_new_update_with_multiple_bugs(self, *args): update = self.get_update('bodhi-2.0.0-2.fc17') update['bugs'] = ['1234', '5678'] - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): r = self.app.post_json('/updates/', update) up = r.json_body @@ -768,7 +786,8 @@ def test_new_update_with_multiple_bugs_as_str(self, *args): update = self.get_update('bodhi-2.0.0-2.fc17') update['bugs'] = '1234, 5678' - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): r = self.app.post_json('/updates/', update) up = r.json_body @@ -799,7 +818,8 @@ def test_new_update_with_existing_build(self, *args): self.db.commit() args = self.get_update('bodhi-2.0.0-3.fc17') - with fml_testing.mock_sends(api.Message): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', args) assert resp.json['title'] == 'bodhi-2.0.0-3.fc17' @@ -813,7 +833,8 @@ def test_new_update_with_existing_package(self, *args): self.db.commit() args = self.get_update('existing-package-2.4.1-5.fc17') - with fml_testing.mock_sends(api.Message): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', args) assert resp.json['title'] == 'existing-package-2.4.1-5.fc17' @@ -826,7 +847,8 @@ def test_new_update_with_missing_package(self, *args): """Test submitting a new update with a package that is not already in the database.""" args = self.get_update('missing-package-2.4.1-5.fc17') - with fml_testing.mock_sends(api.Message): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', args) assert resp.json['title'] == 'missing-package-2.4.1-5.fc17' @@ -844,7 +866,8 @@ def test_cascade_package_requirements_to_update(self, *args): # Don't specify any requirements so that they cascade from the package del args['requirements'] - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): r = self.app.post_json('/updates/', args) up = r.json_body @@ -861,7 +884,8 @@ def test_push_untested_critpath_to_release(self, *args): args = self.get_update('kernel-3.11.5-300.fc17') args['request'] = 'stable' - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): up = self.app.post_json('/updates/', args).json_body assert up['critpath'] @@ -878,7 +902,8 @@ def test_new_edit_update_critpath_groups(self, fakejson, *args): fakejson.return_value = {'rpm': {'core': ['kernel']}} args = self.get_update('kernel-3.11.5-300.fc17') - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): up = self.app.post_json('/updates/', args).json_body assert up['critpath'] @@ -900,7 +925,8 @@ def test_obsoletion(self, *args): nvr = 'bodhi-2.0.0-2.fc17' args = self.get_update(nvr) with mock.patch(**mock_uuid4_version1): - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): self.app.post_json('/updates/', args) up = self.db.query(Build).filter_by(nvr=nvr).one().update @@ -911,7 +937,8 @@ def test_obsoletion(self, *args): args = self.get_update('bodhi-2.0.0-3.fc17') with mock.patch(**mock_uuid4_version2): - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): r = self.app.post_json('/updates/', args).json_body assert r['request'] == 'testing' @@ -947,7 +974,8 @@ def test_create_new_nonsecurity_update_when_previous_security_one_exists(self, * args["type"] = "security" args["severity"] = "high" with mock.patch(**mock_uuid4_version1): - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): self.app.post_json('/updates/', args) up = self.db.query(Build).filter_by(nvr=nvr).one().update @@ -958,7 +986,8 @@ def test_create_new_nonsecurity_update_when_previous_security_one_exists(self, * args = self.get_update('bodhi-2.0.0-3.fc17') with mock.patch(**mock_uuid4_version2): - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): r = self.app.post_json('/updates/', args).json_body # Since we're trying to obsolete security update with non security update. @@ -1000,7 +1029,8 @@ def test_obsoletion_security_update(self, *args): args["type"] = "security" args["severity"] = "high" with mock.patch(**mock_uuid4_version1): - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): self.app.post_json('/updates/', args) up = self.db.query(Build).filter_by(nvr=nvr).one().update @@ -1013,7 +1043,8 @@ def test_obsoletion_security_update(self, *args): args["type"] = "security" args["severity"] = "high" with mock.patch(**mock_uuid4_version2): - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): r = self.app.post_json('/updates/', args).json_body assert r['request'] == 'testing' @@ -1063,7 +1094,8 @@ def test_obsoletion_with_exception(self, *args): nvr = 'bodhi-2.0.0-2.fc17' args = self.get_update(nvr) with mock.patch(**mock_uuid4_version1): - with fml_testing.mock_sends(api.Message): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): self.app.post_json('/updates/', args) up = self.db.query(Build).filter_by(nvr=nvr).one().update up.status = UpdateStatus.testing @@ -1073,7 +1105,8 @@ def test_obsoletion_with_exception(self, *args): args = self.get_update('bodhi-2.0.0-3.fc17') with mock.patch(**mock_uuid4_version2): - with fml_testing.mock_sends(api.Message): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): r = self.app.post_json('/updates/', args).json_body assert r['request'] == 'testing' @@ -1621,7 +1654,8 @@ def test_provenpackager_edit_anything(self, *args): up_data = self.get_update(nvr) up_data['csrf_token'] = app.get('/csrf').json_body['csrf_token'] - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): res = app.post_json('/updates/', up_data) assert 'does not have commit access to bodhi' not in res @@ -1661,7 +1695,8 @@ def test_provenpackager_request_privs(self, *args): up_data = self.get_update(nvr) up_data['csrf_token'] = app.get('/csrf').json_body['csrf_token'] - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): res = app.post_json('/updates/', up_data) assert 'does not have commit access to bodhi' not in res @@ -1792,7 +1827,8 @@ def test_provenpackager_request_update_queued_in_test_gating(self, *args): up_data = self.get_update(nvr) up_data['csrf_token'] = self.app.get('/csrf').json_body['csrf_token'] - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): res = self.app.post_json('/updates/', up_data) build = self.db.query(RpmBuild).filter_by(nvr=nvr).one() @@ -1827,7 +1863,8 @@ def test_provenpackager_request_update_running_in_test_gating(self, *args): up_data = self.get_update(nvr) up_data['csrf_token'] = self.app.get('/csrf').json_body['csrf_token'] - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): res = self.app.post_json('/updates/', up_data) build = self.db.query(RpmBuild).filter_by(nvr=nvr).one() @@ -1862,7 +1899,8 @@ def test_provenpackager_request_update_failed_test_gating(self, *args): up_data = self.get_update(nvr) up_data['csrf_token'] = self.app.get('/csrf').json_body['csrf_token'] - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): res = self.app.post_json('/updates/', up_data) build = self.db.query(RpmBuild).filter_by(nvr=nvr).one() @@ -1897,7 +1935,8 @@ def test_provenpackager_request_update_ignored_by_test_gating(self, *args): up_data = self.get_update(nvr) up_data['csrf_token'] = self.app.get('/csrf').json_body['csrf_token'] - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): res = self.app.post_json('/updates/', up_data) assert 'does not have commit access to bodhi' not in res @@ -1931,7 +1970,8 @@ def test_provenpackager_request_update_waiting_on_test_gating(self, *args): up_data = self.get_update(nvr) up_data['csrf_token'] = self.app.get('/csrf').json_body['csrf_token'] - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): res = self.app.post_json('/updates/', up_data) build = self.db.query(RpmBuild).filter_by(nvr=nvr).one() @@ -1966,7 +2006,8 @@ def test_provenpackager_request_update_with_none_test_gating(self, *args): up_data = self.get_update(nvr) up_data['csrf_token'] = self.app.get('/csrf').json_body['csrf_token'] - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): res = self.app.post_json('/updates/', up_data) build = self.db.query(RpmBuild).filter_by(nvr=nvr).one() @@ -2211,7 +2252,8 @@ def test_updates_search(self): def test_list_updates_pagination(self, *args): # First, stuff a second update in there - with fml_testing.mock_sends(api.Message): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): self.app.post_json('/updates/', self.get_update('bodhi-2.0.0-2.fc17')) # Then, test pagination @@ -3261,14 +3303,16 @@ def test_list_updates_by_nonexistent_username(self): def test_edit_update(self, *args): args = self.get_update('bodhi-2.0.0-2.fc17') - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): r = self.app.post_json('/updates/', args) args['edited'] = r.json['alias'] args['builds'] = 'bodhi-2.0.0-3.fc17' args['requirements'] = 'upgradepath' - with fml_testing.mock_sends(update_schemas.UpdateEditV2): + with fml_testing.mock_sends(update_schemas.UpdateEditV2, + update_schemas.UpdateReadyForTestingV3): r = self.app.post_json('/updates/', args) up = r.json_body @@ -3327,14 +3371,16 @@ def test_edit_rpm_update_from_tag(self, *args): update = self.get_update(from_tag='f17-build-side-7777') with mock.patch('bodhi.server.buildsys.DevBuildsys.getTag', self.mock_getTag): - r = self.app.post_json('/updates/', update) + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3): + r = self.app.post_json('/updates/', update) update['edited'] = r.json['alias'] update['builds'] = 'bodhi-2.0.0-3.fc17' update['requirements'] = 'upgradepath' with mock.patch('bodhi.server.buildsys.DevBuildsys.getTag', self.mock_getTag): - with fml_testing.mock_sends(update_schemas.UpdateEditV2): + with fml_testing.mock_sends(update_schemas.UpdateEditV2, + update_schemas.UpdateReadyForTestingV3): r = self.app.post_json('/updates/', update) up = r.json_body @@ -3383,7 +3429,8 @@ def test_edit_pending_update_with_new_builds(self, info, get_tags, tag_task, *ar nvr = 'bodhi-2.0.0-2.fc17' args = self.get_update(nvr) - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): r = self.app.post_json('/updates/', args) # Mark it as pending @@ -3400,7 +3447,8 @@ def test_edit_pending_update_with_new_builds(self, info, get_tags, tag_task, *ar args['edited'] = upd.alias args['builds'] = 'bodhi-2.0.0-3.fc17' - with fml_testing.mock_sends(update_schemas.UpdateEditV2): + with fml_testing.mock_sends(update_schemas.UpdateEditV2, + update_schemas.UpdateReadyForTestingV3): r = self.app.post_json('/updates/', args) info.assert_any_call('Unpushing bodhi-2.0.0-2.fc17') @@ -3442,7 +3490,8 @@ def test_edit_testing_update_with_new_builds(self, info, get_tags, tag_task, *ar nvr = 'bodhi-2.0.0-2.fc17' args = self.get_update(nvr) - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): r = self.app.post_json('/updates/', args) # Mark it as testing @@ -3459,7 +3508,8 @@ def test_edit_testing_update_with_new_builds(self, info, get_tags, tag_task, *ar args['builds'] = 'bodhi-2.0.0-3.fc17' with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1, - update_schemas.UpdateEditV2): + update_schemas.UpdateEditV2, + update_schemas.UpdateReadyForTestingV3): r = self.app.post_json('/updates/', args) info.assert_any_call('Unpushing bodhi-2.0.0-2.fc17') @@ -3501,7 +3551,8 @@ def test_edit_testing_update_with_new_builds_with_stable_request(self, info, get nvr = 'bodhi-2.0.0-2.fc17' args = self.get_update(nvr) - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): r = self.app.post_json('/updates/', args) # Mark it as testing @@ -3519,7 +3570,8 @@ def test_edit_testing_update_with_new_builds_with_stable_request(self, info, get args['builds'] = 'bodhi-2.0.0-3.fc17' with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1, - update_schemas.UpdateEditV2): + update_schemas.UpdateEditV2, + update_schemas.UpdateReadyForTestingV3): r = self.app.post_json('/updates/', args) info.assert_any_call('Unpushing bodhi-2.0.0-2.fc17') @@ -3561,7 +3613,8 @@ def test_edit_testing_update_with_stable_request_no_edit_build(self, *args): nvr = 'bodhi-2.0.0-2.fc17' args = self.get_update(nvr) - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): r = self.app.post_json('/updates/', args) # Mark it as testing @@ -3597,7 +3650,8 @@ def test_edit_pending_sidetag_update_with_new_builds(self, info, get_tags, tag_t nvr = 'bodhi-2.0.0-2.fc17' args = self.get_update(nvr) - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): r = self.app.post_json('/updates/', args) # Mark it as pending @@ -3616,7 +3670,8 @@ def test_edit_pending_sidetag_update_with_new_builds(self, info, get_tags, tag_t args['edited'] = upd.alias args['builds'] = 'bodhi-2.0.0-3.fc17' - with fml_testing.mock_sends(update_schemas.UpdateEditV2): + with fml_testing.mock_sends(update_schemas.UpdateEditV2, + update_schemas.UpdateReadyForTestingV3): r = self.app.post_json('/updates/', args) info.assert_any_call('Unpushing bodhi-2.0.0-2.fc17') @@ -3658,7 +3713,8 @@ def test_edit_testing_sidetag_update_with_new_builds(self, info, get_tags, tag_t nvr = 'bodhi-2.0.0-2.fc17' args = self.get_update(nvr) - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): r = self.app.post_json('/updates/', args) # Mark it as testing @@ -3677,7 +3733,8 @@ def test_edit_testing_sidetag_update_with_new_builds(self, info, get_tags, tag_t args['builds'] = 'bodhi-2.0.0-3.fc17' with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1, - update_schemas.UpdateEditV2): + update_schemas.UpdateEditV2, + update_schemas.UpdateReadyForTestingV3): r = self.app.post_json('/updates/', args) info.assert_any_call('Unpushing bodhi-2.0.0-2.fc17') @@ -3715,7 +3772,8 @@ def test_edit_update_with_different_release(self, *args): """Test editing an update for one release with builds from another.""" args = self.get_update('bodhi-2.0.0-2.fc17') - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): r = self.app.post_json('/updates/', args) # Add another release and package @@ -3739,7 +3797,8 @@ def test_edit_stable_update(self, *args): nvr = 'bodhi-2.0.0-2.fc17' args = self.get_update(nvr) - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): r = self.app.post_json('/updates/', args, status=200) # Then, switch it to stable behind the scenes @@ -3760,7 +3819,8 @@ def test_edit_locked_update(self, *args): nvr = 'bodhi-2.0.0-2.fc17' args = self.get_update(nvr) - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): r = self.app.post_json('/updates/', args, status=200) up = self.db.query(Build).filter_by(nvr=nvr).one().update @@ -3801,7 +3861,8 @@ def test_pending_update_on_stable_karma_reached_autopush_enabled(self, *args): args['autokarma'] = True args['stable_karma'] = 2 args['unstable_karma'] = -2 - with fml_testing.mock_sends(api.Message): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): self.app.post_json('/updates/', args) up = self.db.query(Build).filter_by(nvr=nvr).one().update @@ -3832,7 +3893,8 @@ def test_pending_urgent_update_on_stable_karma_reached_autopush_enabled(self, *a args['unstable_karma'] = -2 args['severity'] = 'urgent' - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): self.app.post_json('/updates/', args) up = self.db.query(Build).filter_by(nvr=nvr).one().update @@ -3861,7 +3923,8 @@ def test_pending_update_on_stable_karma_not_reached(self, *args): args['stable_karma'] = 2 args['unstable_karma'] = -2 - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): self.app.post_json('/updates/', args) up = self.db.query(Build).filter_by(nvr=nvr).one().update @@ -3886,7 +3949,8 @@ def test_pending_update_on_stable_karma_reached_autopush_disabled(self, *args): args['stable_karma'] = 2 args['unstable_karma'] = -2 - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): self.app.post_json('/updates/', args) up = self.db.query(Build).filter_by(nvr=nvr).one().update @@ -3915,7 +3979,8 @@ def test_obsoletion_locked_with_open_request(self, *args): nvr = 'bodhi-2.0.0-2.fc17' args = self.get_update(nvr) - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): self.app.post_json('/updates/', args) up = self.db.query(Build).filter_by(nvr=nvr).one().update @@ -3925,7 +3990,8 @@ def test_obsoletion_locked_with_open_request(self, *args): args = self.get_update('bodhi-2.0.0-3.fc17') - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): r = self.app.post_json('/updates/', args).json_body assert r['request'] == 'testing' @@ -3939,12 +4005,14 @@ def test_obsoletion_unlocked_with_open_request(self, *args): nvr = 'bodhi-2.0.0-2.fc17' args = self.get_update(nvr) - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): self.app.post_json('/updates/', args) args = self.get_update('bodhi-2.0.0-3.fc17') - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): r = self.app.post_json('/updates/', args).json_body assert r['request'] == 'testing' @@ -3964,7 +4032,8 @@ def test_obsoletion_unlocked_with_open_stable_request(self, *args): nvr = 'bodhi-2.0.0-2.fc17' args = self.get_update(nvr) - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): self.app.post_json('/updates/', args) up = self.db.query(Build).filter_by(nvr=nvr).one().update @@ -3975,7 +4044,8 @@ def test_obsoletion_unlocked_with_open_stable_request(self, *args): nvr_new = 'bodhi-2.0.0-3.fc17' args = self.get_update(nvr_new) - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): r = self.app.post_json('/updates/', args).json_body assert r['request'] == 'testing' @@ -4016,7 +4086,8 @@ def test_push_to_stable_for_obsolete_update(self, *args): nvr = 'bodhi-2.0.0-2.fc17' args = self.get_update(nvr) with mock.patch(**mock_uuid4_version1): - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): self.app.post_json('/updates/', args) up = self.db.query(Build).filter_by(nvr=nvr).one().update @@ -4028,7 +4099,8 @@ def test_push_to_stable_for_obsolete_update(self, *args): new_nvr = 'bodhi-2.0.0-3.fc17' args = self.get_update(new_nvr) with mock.patch(**mock_uuid4_version2): - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): r = self.app.post_json('/updates/', args).json_body assert r['request'] == 'testing' @@ -4053,7 +4125,8 @@ def test_enabled_button_for_autopush(self, *args): nvr = 'bodhi-2.0.0-2.fc17' args = self.get_update(nvr) args['autokarma'] = True - with fml_testing.mock_sends(api.Message): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', args) resp = self.app.get(f"/updates/{resp.json['alias']}", headers={'Accept': 'text/html'}) @@ -4067,7 +4140,8 @@ def test_disabled_button_for_autopush(self, *args): nvr = 'bodhi-2.0.0-2.fc17' args = self.get_update(nvr) args['autokarma'] = False - with fml_testing.mock_sends(api.Message): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', args) resp = self.app.get(f"/updates/{resp.json['alias']}", headers={'Accept': 'text/html'}) @@ -4122,7 +4196,8 @@ def test_revoke_action_for_stable_request(self, *args): """ args = self.get_update('bodhi-2.0.0-3.fc17') - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', args) up = self.db.query(Update).filter_by(alias=resp.json['alias']).one() @@ -4148,7 +4223,8 @@ def test_revoke_action_for_testing_request(self, *args): """ args = self.get_update('bodhi-2.0.0-3.fc17') - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', args) up = self.db.query(Update).filter_by(alias=resp.json['alias']).one() @@ -4178,7 +4254,8 @@ def test_obsolete_if_unstable_with_autopush_enabled_when_pending(self, *args): args['stable_karma'] = 1 args['unstable_karma'] = -1 - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): response = self.app.post_json('/updates/', args) up = Update.get(response.json['alias']) @@ -4205,7 +4282,8 @@ def test_obsolete_if_unstable_with_autopush_disabled_when_pending(self, *args): args['stable_karma'] = 1 args['unstable_karma'] = -1 - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): response = self.app.post_json('/updates/', args) up = Update.get(response.json['alias']) @@ -4233,7 +4311,8 @@ def test_obsolete_if_unstable_karma_not_reached_with_autopush_enabled_when_pendi args['stable_karma'] = 2 args['unstable_karma'] = -2 - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): response = self.app.post_json('/updates/', args) up = Update.get(response.json['alias']) @@ -4261,7 +4340,8 @@ def test_obsolete_if_unstable_with_autopush_enabled_when_testing(self, *args): args['stable_karma'] = 2 args['unstable_karma'] = -2 - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): response = self.app.post_json('/updates/', args) up = Update.get(response.json['alias']) @@ -4293,7 +4373,8 @@ def test_request_after_unpush(self, *args): """Test request of this update after unpushing""" args = self.get_update('bodhi-2.0.0-3.fc17') - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', args) up = self.db.query(Update).filter_by(alias=resp.json['alias']).one() @@ -4342,7 +4423,8 @@ def test_request_to_stable_based_on_stable_karma(self, *args): args = self.get_update(nvr) args['autokarma'] = False args['stable_karma'] = 1 - with fml_testing.mock_sends(api.Message): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): response = self.app.post_json('/updates/', args) up = Update.get(response.json['alias']) @@ -4389,7 +4471,8 @@ def test_stable_request_after_testing(self, *args): """ args = self.get_update('bodhi-2.0.0-3.fc17') - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', args) up = self.db.query(Update).filter_by(alias=resp.json['alias']).one() @@ -4419,7 +4502,8 @@ def test_request_to_archived_release(self, *args): """ args = self.get_update('bodhi-2.0.0-3.fc17') - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', args) up = self.db.query(Update).filter_by(alias=resp.json['alias']).one() @@ -4447,7 +4531,8 @@ def test_stable_request_failed_taskotron_results(self, *args): """Test submitting a stable request, but with bad taskotron results""" args = self.get_update('bodhi-2.0.0-3.fc17') - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', args) up = self.db.query(Update).filter_by(alias=resp.json['alias']).one() @@ -4477,7 +4562,8 @@ def test_stable_request_absent_taskotron_results(self, *args): """Test submitting a stable request, but with absent task results""" args = self.get_update('bodhi-2.0.0-3.fc17') - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', args) up = self.db.query(Update).filter_by(alias=resp.json['alias']).one() @@ -4508,7 +4594,8 @@ def test_stable_request_when_stable(self, *args): pushed to stable""" args = self.get_update('bodhi-2.0.0-3.fc17') - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', args) up = self.db.query(Update).filter_by(alias=resp.json['alias']).one() @@ -4539,7 +4626,8 @@ def test_testing_request_when_testing(self, *args): pushed to testing""" args = self.get_update('bodhi-2.0.0-3.fc17') - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', args) up = self.db.query(Update).filter_by(alias=resp.json['alias']).one() @@ -4573,7 +4661,8 @@ def test_update_with_older_build_in_testing_from_diff_user(self, r): """ title = 'bodhi-2.0-2.fc17 python-3.0-1.fc17' args = self.get_update(title) - with fml_testing.mock_sends(api.Message): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', args) newuser = User(name='bob') self.db.add(newuser) @@ -4587,7 +4676,8 @@ def test_update_with_older_build_in_testing_from_diff_user(self, r): newtitle = 'bodhi-2.0-3.fc17' args = self.get_update(newtitle) - with fml_testing.mock_sends(api.Message): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', args) # Note that this does **not** obsolete the other update @@ -4605,7 +4695,8 @@ def test_update_with_older_build_in_testing_from_diff_user(self, r): @mock.patch(**mock_valid_requirements) def test_updateid_alias(self, *args): - with fml_testing.mock_sends(api.Message): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): res = self.app.post_json('/updates/', self.get_update('bodhi-2.0.0-3.fc17')) json = res.json_body assert json['alias'] == json['updateid'] @@ -4662,7 +4753,9 @@ def test_submitting_multi_release_updates(self, *args): # A multi-release submission!!! This should create *two* updates args = self.get_update('bodhi-2.0.0-2.fc17,bodhi-2.0.0-2.fc18') - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1, + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1, + update_schemas.UpdateReadyForTestingV3, update_schemas.UpdateRequestTestingV1): r = self.app.post_json('/updates/', args) @@ -4694,7 +4787,8 @@ def test_edit_update_bugs(self, *args): args = self.get_update('bodhi-2.0.0-2.fc17') args['bugs'] = '56789' - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): r = self.app.post_json('/updates/', args) # This has two bugs because it obsoleted another update and inherited its bugs. @@ -4714,7 +4808,8 @@ def test_edit_update_bugs(self, *args): args['bugs'] = '56789,98765' with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1, - update_schemas.UpdateEditV2): + update_schemas.UpdateEditV2, + update_schemas.UpdateReadyForTestingV3): r = self.app.post_json('/updates/', args) up = r.json_body @@ -4756,7 +4851,8 @@ def test_edit_update_and_disable_features(self, *args): build = 'bodhi-2.0.0-2.fc17' args = self.get_update('bodhi-2.0.0-2.fc17') - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): r = self.app.post_json('/updates/', args) up = r.json_body @@ -4800,7 +4896,8 @@ def test_edit_update_change_type(self, *args): args = self.get_update('bodhi-2.0.0-2.fc17') args['type'] = 'newpackage' - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): r = self.app.post_json('/updates/', args) up = r.json_body @@ -4844,7 +4941,8 @@ def test_edit_testing_update_reset_karma(self, *args): nvr = 'bodhi-2.0.0-2.fc17' args = self.get_update(nvr) - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): r = self.app.post_json('/updates/', args) # Mark it as testing, tested and give it 2 karma @@ -4861,7 +4959,7 @@ def test_edit_testing_update_reset_karma(self, *args): args['edited'] = upd.alias args['builds'] = 'bodhi-2.0.0-3.fc17' - with fml_testing.mock_sends(*[base_schemas.BodhiMessage] * 2): + with fml_testing.mock_sends(*[base_schemas.BodhiMessage] * 3): r = self.app.post_json('/updates/', args) up = r.json_body @@ -4884,7 +4982,8 @@ def test_edit_testing_update_reset_karma_with_same_tester(self, *args): nvr = 'bodhi-2.0.0-2.fc17' args = self.get_update(nvr) - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): r = self.app.post_json('/updates/', args) # Mark it as testing and as tested @@ -4904,7 +5003,7 @@ def test_edit_testing_update_reset_karma_with_same_tester(self, *args): new_nvr = 'bodhi-2.0.0-3.fc17' args['edited'] = upd.alias args['builds'] = new_nvr - with fml_testing.mock_sends(*[base_schemas.BodhiMessage] * 3): + with fml_testing.mock_sends(*[base_schemas.BodhiMessage] * 4): r = self.app.post_json('/updates/', args) up = r.json_body assert up['title'] == new_nvr @@ -4922,7 +5021,7 @@ def test_edit_testing_update_reset_karma_with_same_tester(self, *args): newer_nvr = 'bodhi-2.0.0-4.fc17' args['edited'] = upd.alias args['builds'] = newer_nvr - with fml_testing.mock_sends(*[base_schemas.BodhiMessage] * 2): + with fml_testing.mock_sends(*[base_schemas.BodhiMessage] * 3): r = self.app.post_json('/updates/', args) up = r.json_body assert up['title'] == newer_nvr @@ -4947,7 +5046,8 @@ def test__composite_karma_with_one_negative(self, *args): nvr = 'bodhi-2.1-1.fc17' args = self.get_update(nvr) - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): self.app.post_json('/updates/', args).json_body up = self.db.query(Build).filter_by(nvr=nvr).one().update @@ -4975,7 +5075,8 @@ def test__composite_karma_with_changed_karma(self, *args): nvr = 'bodhi-2.1-1.fc17' args = self.get_update(nvr) - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): self.app.post_json('/updates/', args).json_body up = self.db.query(Build).filter_by(nvr=nvr).one().update @@ -5009,7 +5110,8 @@ def test__composite_karma_with_positive_karma_first(self, *args): nvr = 'bodhi-2.1-1.fc17' args = self.get_update(nvr) - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): self.app.post_json('/updates/', args).json_body up = self.db.query(Build).filter_by(nvr=nvr).one().update @@ -5040,7 +5142,8 @@ def test__composite_karma_with_no_negative_karma(self, *args): nvr = 'bodhi-2.1-1.fc17' args = self.get_update(nvr) - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): self.app.post_json('/updates/', args).json_body up = self.db.query(Build).filter_by(nvr=nvr).one().update @@ -5070,7 +5173,8 @@ def test__composite_karma_with_no_feedback(self, *args): nvr = 'bodhi-2.1-1.fc17' args = self.get_update(nvr) - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): self.app.post_json('/updates/', args).json_body up = self.db.query(Build).filter_by(nvr=nvr).one().update @@ -5092,7 +5196,8 @@ def test_karma_threshold_with_disabled_autopush(self, *args): args['stable_karma'] = 3 args['unstable_karma'] = -3 - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): r = self.app.post_json('/updates/', args) up = r.json_body @@ -5137,7 +5242,8 @@ def test_disable_autopush_for_critical_updates(self, *args): args = self.get_update(nvr) args['autokarma'] = True - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', args) assert resp.json['critpath'] @@ -5177,7 +5283,8 @@ def test_autopush_critical_update_with_no_negative_karma(self, *args): args['stable_karma'] = 2 args['unstable_karma'] = -2 - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', args) assert resp.json['critpath'] @@ -5220,7 +5327,8 @@ def test_manually_push_critical_update_with_negative_karma(self, *args): args['stable_karma'] = 3 args['unstable_karma'] = -3 - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', args) assert resp.json['critpath'] @@ -5278,7 +5386,8 @@ def test_manually_push_critical_update_with_autopush_turned_off(self, *args): args['stable_karma'] = 3 args['unstable_karma'] = -3 - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', args) assert resp.json['critpath'] @@ -5327,7 +5436,8 @@ def test_disable_autopush_non_critical_update_with_negative_karma(self, rawhide_ args['stable_karma'] = 3 args['unstable_karma'] = -3 - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', args) assert resp.json['request'] == 'testing' @@ -5386,7 +5496,8 @@ def test_autopush_non_critical_update_with_no_negative_karma(self, *args): args['stable_karma'] = 2 args['unstable_karma'] = -2 - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', args) assert resp.json['request'] == 'testing' @@ -5416,7 +5527,8 @@ def test_edit_button_not_present_when_stable(self, *args): """ nvr = 'bodhi-2.0.0-2.fc17' args = self.get_update(nvr) - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', args) update = Update.get(resp.json['alias']) update.date_stable = datetime.utcnow() @@ -5441,7 +5553,8 @@ def test_push_to_stable_button_not_present_when_test_gating_status_failed(self, args['requirements'] = '' update_tg.return_value = TestGatingStatus.failed - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', args, headers={'Accept': 'application/json'}) update = Update.get(resp.json['alias']) @@ -5470,7 +5583,8 @@ def test_push_to_stable_button_present_when_test_gating_status_passed(self, upda args['requirements'] = '' update_tg.return_value = TestGatingStatus.passed - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', args, headers={'Accept': 'application/json'}) update = Update.get(resp.json['alias']) @@ -5499,7 +5613,8 @@ def test_push_to_stable_button_present_when_karma_reached(self, *args): nvr = 'bodhi-2.0.0-2.fc17' args = self.get_update(nvr) - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', args) update = Update.get(resp.json['alias']) @@ -5529,7 +5644,8 @@ def test_push_to_stable_button_present_when_karma_reached_urgent(self, *args): nvr = 'bodhi-2.0.0-2.fc17' args = self.get_update(nvr) - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', args) update = Update.get(resp.json['alias']) @@ -5560,7 +5676,8 @@ def test_push_to_stable_button_present_when_time_reached(self, *args): nvr = 'bodhi-2.0.0-2.fc17' args = self.get_update(nvr) - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', args) update = Update.get(resp.json['alias']) @@ -5589,7 +5706,8 @@ def test_push_to_stable_button_present_when_time_reached_and_urgent(self, *args) nvr = 'bodhi-2.0.0-2.fc17' args = self.get_update(nvr) - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', args) update = Update.get(resp.json['alias']) @@ -5619,7 +5737,8 @@ def test_push_to_stable_button_present_when_time_reached_critpath(self, *args): nvr = 'bodhi-2.0.0-2.fc17' args = self.get_update(nvr) - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', args) update = Update.get(resp.json['alias']) @@ -5649,7 +5768,8 @@ def test_push_to_stable_button_not_present_when_karma_reached_and_frozen_release nvr = 'bodhi-2.0.0-2.fc17' args = self.get_update(nvr) - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', args) update = Update.get(resp.json['alias']) @@ -5678,7 +5798,8 @@ def assert_severity_html(self, severity, text=()): nvr = 'bodhi-2.0.0-2.fc17' args = self.get_update(nvr) - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', args) update = Update.get(resp.json['alias']) @@ -5746,7 +5867,8 @@ def test_update_severity_label_absent_when_severity_is_None(self, *args): nvr = 'bodhi-2.0.0-2.fc17' args = self.get_update(nvr) - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', args) update = Update.get(resp.json['alias']) @@ -5784,7 +5906,8 @@ def test_manually_push_to_stable_based_on_karma_request_none(self, *args): args['autokarma'] = False args['stable_karma'] = 1 - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', args) # Marks it as no request @@ -5838,7 +5961,8 @@ def test_manually_push_to_stable_based_on_karma_request_testing(self, *args): args['autokarma'] = False args['stable_karma'] = 1 - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', args) # Marks it as testing @@ -5887,7 +6011,8 @@ def test_edit_update_with_expired_override(self, *args): nvr = 'bodhi-2.0.0-2.fc17' args = self.get_update(nvr) - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): r = self.app.post_json('/updates/', args) # Create a new expired override @@ -5903,7 +6028,8 @@ def test_edit_update_with_expired_override(self, *args): args['edited'] = upd.alias args['builds'] = new_nvr - with fml_testing.mock_sends(update_schemas.UpdateEditV2): + with fml_testing.mock_sends(update_schemas.UpdateEditV2, + update_schemas.UpdateReadyForTestingV3): r = self.app.post_json('/updates/', args) up = r.json_body @@ -5913,7 +6039,8 @@ def test_edit_update_with_expired_override(self, *args): args['edited'] = upd.alias args['builds'] = nvr - with fml_testing.mock_sends(update_schemas.UpdateEditV2): + with fml_testing.mock_sends(update_schemas.UpdateEditV2, + update_schemas.UpdateReadyForTestingV3): r = self.app.post_json('/updates/', args) up = r.json_body @@ -5942,7 +6069,7 @@ def test_submit_older_build_to_stable(self, *args): stable_karma=3, unstable_karma=-3) update.comment(self.db, "foo1", 1, 'foo1') update.comment(self.db, "foo2", 1, 'foo2') - with fml_testing.mock_sends(api.Message, api.Message, api.Message): + with fml_testing.mock_sends(api.Message, api.Message, api.Message, api.Message): update.comment(self.db, "foo3", 1, 'foo3') self.db.add(update) # Let's clear any messages that might get sent @@ -5977,7 +6104,8 @@ def test_edit_testing_update_with_build_from_different_update(self, *args): nvr1 = 'bodhi-2.0.0-2.fc17' args = self.get_update(nvr1) - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): r = self.app.post_json('/updates/', args) # Mark it as testing @@ -5992,7 +6120,8 @@ def test_edit_testing_update_with_build_from_different_update(self, *args): nvr2 = 'koji-2.0.0-1.fc17' args = self.get_update(nvr2) - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): r = self.app.post_json('/updates/', args) # Mark it as testing @@ -6035,7 +6164,8 @@ def test_edit_testing_update_with_build_from_unpushed_update(self, *args): nvr1 = 'bodhi-2.0.0-2.fc17' args = self.get_update(nvr1) - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): r = self.app.post_json('/updates/', args) # Mark it as unpushed @@ -6051,7 +6181,8 @@ def test_edit_testing_update_with_build_from_unpushed_update(self, *args): nvr2 = 'koji-2.0.0-1.fc17' args = self.get_update(nvr2) - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): r = self.app.post_json('/updates/', args) # Mark it as testing @@ -6066,7 +6197,8 @@ def test_edit_testing_update_with_build_from_unpushed_update(self, *args): args['edited'] = upd.alias args['builds'] = '%s,%s' % (nvr1, nvr2) with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1, - update_schemas.UpdateEditV2): + update_schemas.UpdateEditV2, + update_schemas.UpdateReadyForTestingV3): r = self.app.post_json('/updates/', args) up = r.json_body assert len(up['builds']) == 2 @@ -6105,7 +6237,8 @@ def test_meets_testing_requirements_since_karma_reset_critpath(self, *args): nvr = 'bodhi-2.0.0-2.fc17' args = self.get_update(nvr) - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): r = self.app.post_json('/updates/', args) update = Update.get(r.json['alias']) @@ -6126,7 +6259,8 @@ def test_meets_testing_requirements_since_karma_reset_critpath(self, *args): args['builds'] = 'bodhi-2.0.0-3.fc17' with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1, - update_schemas.UpdateEditV2): + update_schemas.UpdateEditV2, + update_schemas.UpdateReadyForTestingV3): r = self.app.post_json('/updates/', args) up = r.json_body @@ -6160,7 +6294,8 @@ def test_frozen_release_html(self, update_status, release_state): nvr = 'bodhi-2.0.0-2.fc17' args = self.get_update(nvr) - with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3, + update_schemas.UpdateRequestTestingV1): resp = self.app.post_json('/updates/', args) update = Update.get(resp.json['alias']) @@ -7207,13 +7342,12 @@ def test_update_status_testing(self, *args): up = self.db.query(Build).filter_by(nvr=nvr).one().update up.status = UpdateStatus.testing - with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV2): - self.db.commit() + self.db.commit() post_data = dict( csrf_token=self.get_csrf_token() ) - with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV2): + with fml_testing.mock_sends(update_schemas.UpdateReadyForTestingV3): res = self.app.post_json(f'/updates/{up.alias}/trigger-tests', post_data, status=200) assert res.status_code == 200 diff --git a/bodhi-server/tests/tasks/test_composer.py b/bodhi-server/tests/tasks/test_composer.py index 307a033a20..15ba3d38b6 100644 --- a/bodhi-server/tests/tasks/test_composer.py +++ b/bodhi-server/tests/tasks/test_composer.py @@ -472,7 +472,6 @@ def test_tags(self, *args): 'ctype': 'rpm', 'updates': ['bodhi-2.0-1.fc17'], 'agent': 'bowlofeggs'}), - update_schemas.UpdateReadyForTestingV2, update_schemas.UpdateCompleteTestingV1, compose_schemas.ComposeCompleteV1.from_dict(dict( success=True, repo='f17-updates-testing', ctype='rpm', agent='bowlofeggs'))) @@ -571,24 +570,23 @@ def test_tag_ordering(self, *args): 'ctype': 'rpm', 'updates': ['bodhi-2.0-1.fc17', 'bodhi-2.0-2.fc17'], 'agent': 'bowlofeggs'}), - update_schemas.UpdateReadyForTestingV2, - update_schemas.UpdateReadyForTestingV2, update_schemas.UpdateCompleteTestingV1, update_schemas.UpdateCompleteTestingV1, compose_schemas.ComposeCompleteV1.from_dict(dict( success=True, repo='f17-updates-testing', ctype='rpm', agent='bowlofeggs'))) with self.db_factory() as session: - firstupdate = session.query(Update).one() - build = RpmBuild(nvr=otherbuild, package=firstupdate.builds[0].package, - release=firstupdate.release, signed=True) - session.add(build) - update = Update( - builds=[build], type=UpdateType.bugfix, - request=UpdateRequest.testing, notes='second update', user=firstupdate.user, - stable_karma=3, unstable_karma=-3, release=firstupdate.release) - session.add(update) - session.flush() + with mock.patch('bodhi.server.models.notifications'): + firstupdate = session.query(Update).one() + build = RpmBuild(nvr=otherbuild, package=firstupdate.builds[0].package, + release=firstupdate.release, signed=True) + session.add(build) + update = Update( + builds=[build], type=UpdateType.bugfix, + request=UpdateRequest.testing, notes='second update', user=firstupdate.user, + stable_karma=3, unstable_karma=-3, release=firstupdate.release) + session.add(update) + session.flush() with mock_sends(*expected_messages): # Start the push @@ -621,7 +619,7 @@ def test_testing_digest(self, mail, *args): t = RPMComposerThread(self.semmock, task['composes'][0], 'ralph', self.db_factory, self.tempdir) - with mock_sends(*[base_schemas.BodhiMessage] * 4): + with mock_sends(*[base_schemas.BodhiMessage] * 3): t.run() assert t.testing_digest['Fedora 17']['bodhi-2.0-1.fc17'] == f"""\ @@ -970,7 +968,6 @@ def test_security_update_priority(self, *args): 'ctype': 'rpm', 'updates': [u'bodhi-2.0-1.fc17'], 'agent': 'bowlofeggs'}), - update_schemas.UpdateReadyForTestingV2, update_schemas.UpdateCompleteTestingV1, compose_schemas.ComposeCompleteV1.from_dict( {'success': True, @@ -1043,7 +1040,6 @@ def test_security_update_priority_testing(self, *args): 'ctype': 'rpm', 'updates': [u'bodhi-2.0-1.fc17'], 'agent': 'bowlofeggs'}), - update_schemas.UpdateReadyForTestingV2, update_schemas.UpdateCompleteTestingV1, compose_schemas.ComposeCompleteV1.from_dict( {'success': True, @@ -1843,7 +1839,7 @@ def test_absent_gating(self, *args): def test_modify_testing_bugs(self, on_qa, modified, *args): self.expected_sems = 1 - with mock_sends(*[base_schemas.BodhiMessage] * 5): + with mock_sends(*[base_schemas.BodhiMessage] * 4): task = self._make_task() api_version = task.pop("api_version") self.handler.run(api_version, task) @@ -1903,7 +1899,7 @@ def test_status_comment_testing(self, *args): up = session.query(Update).one() assert len(up.comments) == 2 - with mock_sends(*[base_schemas.BodhiMessage] * 5): + with mock_sends(*[base_schemas.BodhiMessage] * 4): task = self._make_task() api_version = task.pop("api_version") self.handler.run(api_version, task) @@ -2024,7 +2020,7 @@ def test_resume_push(self, *args): task = self._make_task() api_version = task.pop("api_version") task['resume'] = True - with mock_sends(*[base_schemas.BodhiMessage] * 5): + with mock_sends(*[base_schemas.BodhiMessage] * 4): self.handler.run(api_version, task) with self.db_factory() as session: @@ -2079,7 +2075,7 @@ def test_retry_done_compose(self, mock_cmd, sleep, task = self._make_task() api_version = task.pop("api_version") task['resume'] = True - with mock_sends(*[base_schemas.BodhiMessage] * 5): + with mock_sends(*[base_schemas.BodhiMessage] * 4): self.handler.run(api_version, task) # Assert we did not actually recompose @@ -2144,7 +2140,7 @@ def test_stable_requirements_met_during_push(self, *args): task = self._make_task() api_version = task.pop("api_version") task['resume'] = True - with mock_sends(*[base_schemas.BodhiMessage] * 7): + with mock_sends(*[base_schemas.BodhiMessage] * 6): self.handler.run(api_version, task) with mock_sends(*[base_schemas.BodhiMessage] * 2): @@ -2169,7 +2165,6 @@ def test_push_timestamps(self, *args): expected_messages = ( compose_schemas.ComposeStartV1, compose_schemas.ComposeComposingV1, - update_schemas.UpdateReadyForTestingV2, update_schemas.UpdateCompleteTestingV1, compose_schemas.ComposeCompleteV1.from_dict(dict( success=True, repo='f17-updates-testing', ctype='rpm', agent='bowlofeggs'))) @@ -2250,7 +2245,7 @@ def test_obsolete_older_updates(self, *args): # Clear pending messages self.db.info['messages'] = [] - with mock_sends(*[base_schemas.BodhiMessage] * 5): + with mock_sends(*[base_schemas.BodhiMessage] * 4): task = self._make_task() api_version = task.pop("api_version") self.handler.run(api_version, task) diff --git a/bodhi-server/tests/test_models.py b/bodhi-server/tests/test_models.py index db4908b3e4..9fd4ca82e3 100644 --- a/bodhi-server/tests/test_models.py +++ b/bodhi-server/tests/test_models.py @@ -75,7 +75,11 @@ def setup_method(self): new_attrs = {} new_attrs.update(self.attrs) new_attrs.update(self.do_get_dependencies()) - self.obj = self.klass(**new_attrs) + # suppress message publication on update creation, the + # message somehow 'leaks' into mock_sends if we let it + # get published here + with mock.patch('bodhi.server.models.notifications'): + self.obj = self.klass(**new_attrs) self.db.add(self.obj) self.db.flush() return self.obj @@ -1938,6 +1942,8 @@ def test_add_bugs_bodhi_not_configured(self, warning): build = model.RpmBuild(nvr='bodhi-6.0.0-1.fc36', release=release, package=package, signed=False) self.db.add(build) + user = model.User(name='tester') + self.db.add(user) data = {'release': release, 'builds': [build], 'from_tag': 'f36-build-side-1234', 'bugs': [], 'requirements': '', 'edited': '', 'autotime': True, 'stable_days': 3, 'stable_karma': 3, 'unstable_karma': -1, @@ -1947,7 +1953,8 @@ def test_add_bugs_bodhi_not_configured(self, warning): request.identity.name = 'tester' self.db.flush() - model.Update.new(request, data) + with mock_sends(update_schemas.UpdateReadyForTestingV3): + model.Update.new(request, data) warning.assert_called_with('Not configured to handle bugs') @@ -2090,7 +2097,7 @@ def test_rawhide_update_edit_move_to_testing(self): request.db = self.db request.identity.name = 'tester' - with mock_sends(update_schemas.UpdateEditV2, update_schemas.UpdateReadyForTestingV2): + with mock_sends(update_schemas.UpdateEditV2): with mock.patch('bodhi.server.models.util.greenwave_api_post') as mock_greenwave: greenwave_response = { 'policies_satisfied': False, @@ -2218,7 +2225,7 @@ def test_version_hash(self): request.db = self.db request.identity.name = 'tester' self.db.flush() - with mock_sends(Message): + with mock_sends(Message, Message): model.Update.edit(request, data) # now, with two builds, check the hash has changed @@ -2640,7 +2647,7 @@ def test_autokarma_update_reaching_stable_karma(self): update.status = UpdateStatus.testing update.stable_karma = 1 # Now let's add some karma to get it to the required threshold - with mock_sends(Message, Message): + with mock_sends(Message): update.comment(self.db, 'testing', author='hunter2', karma=1) # meets_testing_requirement() should return True since the karma threshold has been reached @@ -2889,9 +2896,10 @@ def get_update(self, name='TurboGears-1.0.8-3.fc11', override_args=None): attrs = self.attrs.copy() pkg = self.db.query(model.RpmPackage).filter_by(name='TurboGears').one() rel = self.db.query(model.Release).filter_by(name='F11').one() + user = self.db.query(model.User).first() attrs.update(dict( builds=[model.RpmBuild(nvr=name, package=pkg, release=rel)], - release=rel)) + release=rel, user=user)) attrs.update(override_args or {}) return self.klass(**attrs) @@ -4918,34 +4926,6 @@ def test_comment_on_test_gating_status_change_email(self, mail): # We should have two comments, one for each test_gating_status change assert len(self.obj.comments) == 2 - def test_set_status_testing(self): - """Test that setting an update's status to testing sends a message.""" - self.db.info['messages'] = [] - with mock_sends(update_schemas.UpdateReadyForTestingV2): - self.obj.status = UpdateStatus.testing - msg = self.db.info['messages'][0] - self.db.commit() - assert msg.body["artifact"]["builds"][0]["component"] == "TurboGears" - assert msg.body["artifact"]["id"].startswith("FEDORA-") - assert msg.body["artifact"]["type"] == "koji-build-group" - assert msg.packages == ['TurboGears'] - - def test_create_with_status_testing(self): - """Test that creating an update with the status set to testing sends a message.""" - self.db.info['messages'] = [] - with mock_sends(update_schemas.UpdateReadyForTestingV2): - self.get_update(name="TurboGears-1.0.8-4.fc11", override_args={ - "status": UpdateStatus.testing, - "user": self.db.query(model.User).filter_by(name='lmacken').one() - }) - assert len(self.db.info['messages']) == 1 - msg = self.db.info['messages'][0] - self.db.commit() - assert msg.body["artifact"]["builds"][0]["component"] == "TurboGears" - assert msg.body["artifact"]["id"].startswith("FEDORA-") - assert msg.body["artifact"]["type"] == "koji-build-group" - assert msg.packages == ['TurboGears'] - @mock.patch('bodhi.server.models.Update.obsolete') @mock.patch('bodhi.server.models.Update.comment') def test_obsolete_older_updates(self, comment, obsolete): diff --git a/bodhi-server/tests/test_push.py b/bodhi-server/tests/test_push.py index dc2c9d2d41..ff8170ea97 100644 --- a/bodhi-server/tests/test_push.py +++ b/bodhi-server/tests/test_push.py @@ -59,11 +59,12 @@ def setup_method(self, method): self.db.add(build) # And an Update with the RpmBuild. - self.archived_release_update = models.Update( - builds=[build], user=self.user, - request=models.UpdateRequest.stable, notes='Useful details!', release=archived_release, - date_submitted=datetime(2016, 10, 28), requirements='', stable_karma=3, - unstable_karma=-3, type=models.UpdateType.bugfix) + with mock.patch('bodhi.server.models.notifications'): + self.archived_release_update = models.Update( + builds=[build], user=self.user, request=models.UpdateRequest.stable, + notes='Useful details!', release=archived_release, + date_submitted=datetime(2016, 10, 28), requirements='', stable_karma=3, + unstable_karma=-3, type=models.UpdateType.bugfix) self.db.add(self.archived_release_update) self.db.commit() @@ -119,16 +120,18 @@ def test_defaults_to_filtering_correct_releases(self): self.db.add(disabled_build) self.db.add(pending_build) # Now let's create updates for both packages. - disabled_release_update = models.Update( - builds=[disabled_build], user=self.user, - request=models.UpdateRequest.stable, notes='Useful details!', release=disabled_release, - date_submitted=datetime(2016, 10, 28), requirements='', stable_karma=3, - unstable_karma=-3, type=models.UpdateType.bugfix) - pending_release_update = models.Update( - builds=[pending_build], user=self.user, - request=models.UpdateRequest.stable, notes='Useful details!', release=pending_release, - date_submitted=datetime(2016, 10, 28), requirements='', stable_karma=3, - unstable_karma=-3, type=models.UpdateType.bugfix) + with mock.patch('bodhi.server.models.notifications'): + disabled_release_update = models.Update( + builds=[disabled_build], user=self.user, request=models.UpdateRequest.stable, + notes='Useful details!', release=disabled_release, + date_submitted=datetime(2016, 10, 28), requirements='', stable_karma=3, + unstable_karma=-3, type=models.UpdateType.bugfix) + with mock.patch('bodhi.server.models.notifications'): + pending_release_update = models.Update( + builds=[pending_build], user=self.user, request=models.UpdateRequest.stable, + notes='Useful details!', release=pending_release, + date_submitted=datetime(2016, 10, 28), requirements='', stable_karma=3, + unstable_karma=-3, type=models.UpdateType.bugfix) self.db.add(disabled_release_update) self.db.add(pending_release_update) self.db.commit() @@ -162,11 +165,12 @@ def test_two_releases(self): current_build = models.RpmBuild(nvr='bodhi-2.3.2-1.fc18', release=current_release, package=pkg) self.db.add(current_build) - current_release_update = models.Update( - builds=[current_build], user=self.user, - request=models.UpdateRequest.stable, notes='Useful details!', release=current_release, - date_submitted=datetime(2016, 10, 28), requirements='', stable_karma=3, - unstable_karma=-3, type=models.UpdateType.bugfix) + with mock.patch('bodhi.server.models.notifications'): + current_release_update = models.Update( + builds=[current_build], user=self.user, request=models.UpdateRequest.stable, + notes='Useful details!', release=current_release, + date_submitted=datetime(2016, 10, 28), requirements='', stable_karma=3, + unstable_karma=-3, type=models.UpdateType.bugfix) self.db.add(current_release_update) self.db.commit() @@ -432,8 +436,9 @@ def setup_method(self, method): Make some updates that can be pushed. """ super().setup_method(method) - python_nose = self.create_update(['python-nose-1.3.7-11.fc17']) - python_paste_deploy = self.create_update(['python-paste-deploy-1.5.2-8.fc17']) + with mock.patch('bodhi.server.models.notifications'): + python_nose = self.create_update(['python-nose-1.3.7-11.fc17']) + python_paste_deploy = self.create_update(['python-paste-deploy-1.5.2-8.fc17']) # Make it so we have two builds to push out python_nose.builds[0].signed = True python_paste_deploy.builds[0].signed = True diff --git a/news/5538.feature b/news/5538.feature new file mode 100644 index 0000000000..4b22969c9b --- /dev/null +++ b/news/5538.feature @@ -0,0 +1 @@ +The UpdateReadyForTesting message format is simplified, and the message is now published on update creation and edit with changed builds instead of push to testing