From 65bb0a7a27170e1a17765b81345c3c0fd128664c Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Thu, 23 Nov 2023 17:17:53 -0800 Subject: [PATCH] Publish UpdateReadyForTesting whenever an update is created See https://pagure.io/fedora-ci/general/issue/436 . This is the behaviour test systems want, based on real-world experience. We do not want test systems to wait for updates to reach the updates-testing repo before they test; we want them to test as soon as the update is created. All the test systems that exist pull the builds to be tested from Koji, they do not rely on them being present in updates-testing. Waiting for the update to reach updates-testing before tests run can mean a wait of up to 24 hours, which is obviously not ideal when people want test results fast. It also means we can't gate push to updates-testing on tests that trigger on this message. openQA currently listens out for other messages to use as a proxy for 'update was created' in order to mitigate this problem, but Fedora CI does not do so, and consequently its tests often trigger late. This change, along with the earlier change to publish this message when an update's builds are changed, will allow us to simplify openQA's logic considerably (it can just trigger any time it sees this message) and improve CI's scheduling considerably without any need to make changes to the trigger logic on the CI side. Signed-off-by: Adam Williamson (cherry picked from commit d3765ed0908e21f8ee69d584edf662b4ffc58645) --- .../bodhi/messages/schemas/update.py | 9 + bodhi-server/bodhi/server/buildsys.py | 4 +- bodhi-server/bodhi/server/models.py | 41 +- bodhi-server/tests/base.py | 17 +- .../tests/consumers/test_automatic_updates.py | 1 + bodhi-server/tests/consumers/test_signed.py | 6 +- bodhi-server/tests/services/test_updates.py | 356 ++++++++++++------ bodhi-server/tests/tasks/test_composer.py | 41 +- bodhi-server/tests/test_models.py | 48 +-- bodhi-server/tests/test_push.py | 49 +-- 10 files changed, 337 insertions(+), 235 deletions(-) diff --git a/bodhi-messages/bodhi/messages/schemas/update.py b/bodhi-messages/bodhi/messages/schemas/update.py index d53d1938ce..942b29ce3d 100644 --- a/bodhi-messages/bodhi/messages/schemas/update.py +++ b/bodhi-messages/bodhi/messages/schemas/update.py @@ -1034,6 +1034,15 @@ 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. 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 5698387419..1c503242b2 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): @@ -4215,10 +4216,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 @@ -4250,23 +4251,19 @@ def _build_group_test_message(self, agent="bodhi", retrigger=False): } @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,14 +4286,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/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 a616eed20d..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.UpdateReadyForTestingV3): - 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 13b4108c61..af28dbe98e 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,7 +3303,8 @@ 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'] @@ -3327,7 +3370,8 @@ 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' @@ -3383,7 +3427,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 @@ -3442,7 +3487,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 @@ -3501,7 +3547,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 @@ -3561,7 +3608,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 +3645,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 @@ -3658,7 +3707,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 @@ -3715,7 +3765,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 +3790,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 +3812,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 +3854,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 +3886,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 +3916,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 +3942,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 +3972,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 +3983,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 +3998,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 +4025,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 +4037,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 +4079,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 +4092,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 +4118,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 +4133,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 +4189,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 +4216,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 +4247,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 +4275,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 +4304,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 +4333,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 +4366,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 +4416,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 +4464,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 +4495,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 +4524,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 +4555,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 +4587,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 +4619,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 +4654,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 +4669,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 +4688,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 +4746,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 +4780,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. @@ -4756,7 +4843,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 +4888,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 +4933,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 @@ -4884,7 +4974,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 @@ -4947,7 +5038,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 +5067,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 +5102,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 +5134,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 +5165,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 +5188,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 +5234,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 +5275,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 +5319,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 +5378,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 +5428,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 +5488,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 +5519,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 +5545,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 +5575,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 +5605,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 +5636,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 +5668,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 +5698,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 +5729,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 +5760,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 +5790,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 +5859,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 +5898,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 +5953,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 +6003,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 @@ -5942,7 +6059,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 +6094,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 +6110,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 +6154,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 +6171,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 @@ -6105,7 +6226,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']) @@ -6160,7 +6282,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,8 +7330,7 @@ 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.UpdateReadyForTestingV3): - self.db.commit() + self.db.commit() post_data = dict( csrf_token=self.get_csrf_token() diff --git a/bodhi-server/tests/tasks/test_composer.py b/bodhi-server/tests/tasks/test_composer.py index 4329c5bde0..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.UpdateReadyForTestingV3, 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.UpdateReadyForTestingV3, - update_schemas.UpdateReadyForTestingV3, 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.UpdateReadyForTestingV3, 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.UpdateReadyForTestingV3, 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.UpdateReadyForTestingV3, 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 c337e29802..2213707fcf 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.UpdateReadyForTestingV3): + with mock_sends(update_schemas.UpdateEditV2): with mock.patch('bodhi.server.models.util.greenwave_api_post') as mock_greenwave: greenwave_response = { 'policies_satisfied': False, @@ -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,36 +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.UpdateReadyForTestingV3): - self.obj.status = UpdateStatus.testing - msg = self.db.info['messages'][0] - self.db.commit() - assert msg.body["artifact"]["builds"][0]["nvr"] == "TurboGears-1.0.8-3.fc11" - assert msg.body["artifact"]["builds"][0]["task_id"] == 127621 - assert msg.body["artifact"]["builds"][0]["id"] == 16058 - 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.UpdateReadyForTestingV3): - 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]["nvr"] == "TurboGears-1.0.8-4.fc11" - assert msg.body["artifact"]["builds"][0]["task_id"] == 127621 - assert msg.body["artifact"]["builds"][0]["id"] == 16058 - 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