Пример #1
0
    def test_list_comments_with_multiple_ignore_user(self):
        nvr = u'just-testing-1.0-2.fc17'
        another_user = User(name=u'aUser')
        self.db.add(another_user)
        update = Update(
            title=nvr,
            user=another_user,
            request=UpdateRequest.testing,
            type=UpdateType.enhancement,
            notes=u'Just another update.',
            date_submitted=datetime(1981, 10, 11),
            requirements=u'rpmlint',
            stable_karma=3,
            unstable_karma=-3,
        )
        update.release = Release.query.one()
        self.db.add(update)

        comment = Comment(karma=1, text=u'Cool! 😃')
        comment.user = another_user
        self.db.add(comment)
        update.comments.append(comment)
        self.db.flush()

        res = self.app.get('/comments/', {"ignore_user": "******"})
        body = res.json_body
        self.assertEqual(len(body['comments']), 1)
        self.assertNotIn('errors', body)
        self.assertEqual(body['comments'][0]['text'], u'Cool! 😃')
Пример #2
0
def create_update(session, build_nvrs, release_name=u'F17'):
    """
    Use the given session to create and return an Update with the given iterable of build_nvrs. Each
    build_nvr should be a string describing the name, version, and release for the build separated
    by dashes. For example, build_nvrs might look like this:

    (u'bodhi-2.3.3-1.fc24', u'python-fedora-atomic-composer-2016.3-1.fc24')

    You can optionally pass a release_name to select a different release than the default F17, but
    the release must already exist in the database.
    """
    release = session.query(Release).filter_by(name=release_name).one()
    user = session.query(User).filter_by(name=u'guest').one()

    builds = []
    for nvr in build_nvrs:
        name, version, rel = nvr.rsplit('-', 2)
        try:
            package = session.query(RpmPackage).filter_by(name=name).one()
        except sqlalchemy.orm.exc.NoResultFound:
            package = RpmPackage(name=name)
            session.add(package)
            user.packages.append(package)
            testcase = TestCase(name=u'Wat')
            session.add(testcase)
            package.test_cases.append(testcase)

        builds.append(RpmBuild(nvr=nvr, release=release, package=package, signed=True))
        session.add(builds[-1])

        # Add a buildroot override for this build
        expiration_date = datetime.utcnow()
        expiration_date = expiration_date + timedelta(days=1)
        override = BuildrootOverride(build=builds[-1], submitter=user,
                                     notes=u'blah blah blah',
                                     expiration_date=expiration_date)
        session.add(override)

    update = Update(
        title=', '.join(build_nvrs), builds=builds, user=user, request=UpdateRequest.testing,
        notes=u'Useful details!', type=UpdateType.bugfix, date_submitted=datetime(1984, 11, 2),
        requirements=u'rpmlint', stable_karma=3, unstable_karma=-3,
        test_gating_status=TestGatingStatus.passed)
    session.add(update)
    update.release = release

    return update
Пример #3
0
    def test_list_comments_by_update_no_comments(self):
        nvr = u'bodhi-2.0-201.fc17'
        update = Update(
            title=nvr,
            request=UpdateRequest.testing,
            type=UpdateType.enhancement,
            notes=u'Useful details!',
            date_submitted=datetime(1984, 11, 2),
            requirements=u'rpmlint',
            stable_karma=3,
            unstable_karma=-3,
        )
        update.release = Release.query.one()
        self.db.add(update)
        self.db.flush()

        res = self.app.get('/comments/', {"updates": nvr})
        body = res.json_body
        self.assertEquals(len(body['comments']), 0)