Exemple #1
0
    def test_gating_required_true(self, sleep):
        """Assert that test_gating_status is updated when test_gating is enabled."""
        update = models.Build.query.filter_by(
            nvr='bodhi-2.0-1.fc17').one().update
        update.test_gating_status = None

        h = updates.UpdatesHandler()
        h.db_factory = base.TransactionalSessionMaker(self.Session)
        # Throw a bogus bug id in there to ensure it doesn't raise AssertionError.
        message = UpdateEditV1(
            body={
                'update': {
                    'alias': update.alias,
                    'builds': [{
                        'nvr': 'bodhi-2.0-1.fc17'
                    }],
                    'user': {
                        'name': 'brodhi'
                    },
                    'status': str(update.status),
                    'request': str(update.request)
                },
                'new_bugs': []
            })
        with mock.patch('bodhi.server.models.util.greenwave_api_post'
                        ) as mock_greenwave:
            greenwave_response = {
                'policies_satisfied':
                False,
                'summary':
                'what have you done‽',
                'applicable_policies': ['taskotron_release_critical_tasks'],
                'unsatisfied_requirements': [{
                    'testcase': 'dist.rpmdeplint',
                    'item': {
                        'item': 'bodhi-2.0-1.fc17',
                        'type': 'koji_build'
                    },
                    'type': 'test-result-missing',
                    'scenario': None
                }, {
                    'testcase': 'dist.rpmdeplint',
                    'item': {
                        'item': update.alias,
                        'type': 'bodhi_update'
                    },
                    'type': 'test-result-missing',
                    'scenario': None
                }]
            }
            mock_greenwave.return_value = greenwave_response

            h(message)

        update = models.Build.query.filter_by(
            nvr='bodhi-2.0-1.fc17').one().update
        self.assertEqual(update.test_gating_status,
                         models.TestGatingStatus.failed)
        sleep.assert_called_once_with(1)
Exemple #2
0
    def test_edited_update_bug_not_in_update(self, work_on_bugs,
                                             fetch_test_cases, sleep):
        """
        Test with a message that indicates that the update is being edited, and the list of bugs
        contains one that UpdatesHandler does not find in the update.
        """
        bug = models.Bug(bug_id=123456)
        self.db.add(bug)
        self.db.commit()

        h = updates.UpdatesHandler()
        h.db_factory = base.TransactionalSessionMaker(self.Session)
        update = models.Build.query.filter_by(
            nvr='bodhi-2.0-1.fc17').one().update
        message = UpdateEditV1(
            body={
                'update': {
                    'alias': update.alias,
                    'builds': [{
                        'nvr': 'bodhi-2.0-1.fc17'
                    }],
                    'user': {
                        'name': 'brodhi'
                    },
                    'status': str(update.status),
                    'request': str(update.request)
                },
                'new_bugs': [12345, 123456]
            })

        h(message)

        self.assertEqual(work_on_bugs.call_count, 1)
        self.assertTrue(
            isinstance(work_on_bugs.mock_calls[0][1][0],
                       sqlalchemy.orm.session.Session))
        self.assertEqual(work_on_bugs.mock_calls[0][1][1].title,
                         'bodhi-2.0-1.fc17')
        self.assertEqual([b.bug_id for b in work_on_bugs.mock_calls[0][1][2]],
                         [12345, 123456])
        self.assertEqual(fetch_test_cases.call_count, 1)
        self.assertTrue(
            isinstance(fetch_test_cases.mock_calls[0][1][0],
                       sqlalchemy.orm.session.Session))
        sleep.assert_called_once_with(1)

        # Bug with id '123456' should be attached to update
        bug = models.Bug.query.filter_by(bug_id=123456).one()
        update = models.Build.query.filter_by(
            nvr='bodhi-2.0-1.fc17').one().update
        self.assertIn(bug, update.bugs)
Exemple #3
0
    def test_edited_update_bugs_in_update(self, work_on_bugs, fetch_test_cases,
                                          sleep):
        """
        Test with a message that indicates that the update is being edited, and the list of bugs
        matches what UpdatesHandler finds in the database.
        """
        h = updates.UpdatesHandler()
        h.db_factory = base.TransactionalSessionMaker(self.Session)
        update = models.Build.query.filter_by(
            nvr='bodhi-2.0-1.fc17').one().update
        message = UpdateEditV1(
            body={
                'update': {
                    'alias': update.alias,
                    'builds': [{
                        'nvr': 'bodhi-2.0-1.fc17'
                    }],
                    'user': {
                        'name': 'brodhi'
                    },
                    'status': str(update.status),
                    'request': str(update.request)
                },
                'new_bugs': [12345]
            })

        h(message)

        self.assertEqual(work_on_bugs.call_count, 1)
        self.assertTrue(
            isinstance(work_on_bugs.mock_calls[0][1][1],
                       sqlalchemy.orm.session.Session))
        self.assertEqual(work_on_bugs.mock_calls[0][1][2].title,
                         'bodhi-2.0-1.fc17')
        self.assertEqual([b.bug_id for b in work_on_bugs.mock_calls[0][1][3]],
                         [12345])
        self.assertEqual(fetch_test_cases.call_count, 1)
        self.assertTrue(
            isinstance(fetch_test_cases.mock_calls[0][1][1],
                       sqlalchemy.orm.session.Session))
        sleep.assert_called_once_with(1)
Exemple #4
0
    def test_request_testing(self, work_on_bugs, fetch_test_cases, sleep):
        """
        Assert correct behavior when the message tells us that the update is requested for testing.
        """
        h = updates.UpdatesHandler()
        h.db_factory = base.TransactionalSessionMaker(self.Session)
        update = models.Build.query.filter_by(
            nvr='bodhi-2.0-1.fc17').one().update
        message = UpdateEditV1(
            body={
                'update': {
                    'alias': update.alias,
                    'builds': [{
                        'nvr': 'bodhi-2.0-1.fc17'
                    }],
                    'user': {
                        'name': 'brodhi'
                    },
                    'status': str(update.status),
                    'request': str(update.request)
                },
                'new_bugs': [12345]
            })

        h(message)

        self.assertEqual(work_on_bugs.call_count, 1)
        self.assertTrue(
            isinstance(work_on_bugs.mock_calls[0][1][1],
                       sqlalchemy.orm.session.Session))
        self.assertEqual(work_on_bugs.mock_calls[0][1][2].title,
                         'bodhi-2.0-1.fc17')
        # The update's bug list should have been used.
        self.assertEqual([b.bug_id for b in work_on_bugs.mock_calls[0][1][3]],
                         [12345])
        self.assertEqual(fetch_test_cases.call_count, 1)
        self.assertTrue(
            isinstance(fetch_test_cases.mock_calls[0][1][1],
                       sqlalchemy.orm.session.Session))
        sleep.assert_called_once_with(1)
Exemple #5
0
 def test_edit_v1(self):
     expected = {
         "topic":
         "bodhi.update.edit",
         "summary":
         "ralph edited FEDORA-2019-7dbbb74a13",
         "app_icon":
         "https://apps.fedoraproject.org/img/icons/bodhi.png",
         "url":
         "https://bodhi.fedoraproject.org/updates/FEDORA-2019-7dbbb74a13",
         "agent_avatar":
         ("https://seccdn.libravatar.org/avatar/"
          "9c9f7784935381befc302fe3c814f9136e7a33953d0318761669b8643f4df55c"
          "?s=64&d=retro"),
         "new_bugs": [1708925, 1706626],
         "usernames": ["ralph"],
         "packages": ["tzdata"],
         'update':
         UpdateV1('FEDORA-2019-7dbbb74a13',
                  [BuildV1('tzdata-2014i-1.fc19')], UserV1('ralph'),
                  'pending', 'testing', ReleaseV1('F19'))
     }
     msg = UpdateEditV1(
         body={
             "new_bugs": [1708925, 1706626],
             "update": {
                 "close_bugs":
                 True,
                 "pushed":
                 False,
                 "require_testcases":
                 True,
                 "critpath":
                 False,
                 "stable_karma":
                 3,
                 "date_pushed":
                 None,
                 "requirements":
                 "rpmlint",
                 "severity":
                 "unspecified",
                 "title":
                 "tzdata-2014i-1.fc19",
                 "suggest":
                 "unspecified",
                 "require_bugs":
                 True,
                 "comments": [{
                     "bug_feedback": [],
                     "user_id": 1681,
                     "timestamp": "2015-01-28 03:02:44",
                     "testcase_feedback": [],
                     "karma_critpath": 0,
                     "update": 54046,
                     "update_id": 54046,
                     "karma": 0,
                     "anonymous": False,
                     "text": "ralph edited this update. ",
                     "id": 484236,
                     "user": {
                         "buildroot_overrides": [],
                         "name": "bodhi",
                         "avatar": None
                     }
                 }],
                 "date_approved":
                 None,
                 "type":
                 "enhancement",
                 "status":
                 "pending",
                 "date_submitted":
                 "2014-10-29 20:02:57",
                 "unstable_karma":
                 -3,
                 "user": {
                     "buildroot_overrides": [],
                     "name": "ralph",
                     "avatar": None
                 },
                 "locked":
                 False,
                 "builds": [{
                     "override": None,
                     "nvr": "tzdata-2014i-1.fc19"
                 }],
                 "date_modified":
                 "2015-01-28 03:02:55",
                 "notes":
                 "the update notes go here...",
                 "request":
                 "testing",
                 "bugs": [],
                 "alias":
                 'FEDORA-2019-7dbbb74a13',
                 "karma":
                 0,
                 "release": {
                     "dist_tag": "f19",
                     "name": "F19",
                     "testing_tag": "f19-updates-testing",
                     "pending_stable_tag": "f19-updates-pending",
                     "long_name": "Fedora 19",
                     "state": "disabled",
                     "version": None,
                     "override_tag": "f19-override",
                     "branch": None,
                     "id_prefix": "FEDORA",
                     "pending_testing_tag": "f19-updates-testing-pending",
                     "stable_tag": "f19-updates",
                     "candidate_tag": "f19-updates-candidate"
                 }
             },
             "agent": "ralph"
         })
     check_message(msg, expected)