Ejemplo n.º 1
0
    def test_list_comments_with_multiple_ignore_user(self):
        another_user = User(name='aUser')
        self.db.add(another_user)
        update = Update(
            user=another_user,
            request=UpdateRequest.testing,
            type=UpdateType.enhancement,
            notes='Just another update.',
            date_submitted=datetime(1981, 10, 11),
            requirements='rpmlint',
            stable_karma=3,
            unstable_karma=-3,
            release=Release.query.one()
        )
        self.db.add(update)

        comment = Comment(karma=1, text='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'], 'Cool! 😃')
Ejemplo n.º 2
0
    def test_list_comments_by_multiple_update_owners(self):
        another_user = User(name='aUser')
        self.db.add(another_user)
        update = Update(
            user=another_user,
            request=UpdateRequest.testing,
            type=UpdateType.enhancement,
            notes='Just another update.',
            date_submitted=datetime(1981, 10, 11),
            requirements='rpmlint',
            stable_karma=3,
            unstable_karma=-3,
            release=Release.query.one()
        )
        self.db.add(update)

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

        res = self.app.get('/comments/', {"update_owner": "guest,aUser"})
        body = res.json_body
        self.assertEqual(len(body['comments']), 3)

        comment = body['comments'][0]
        self.assertEqual(comment['text'], 'Cool! 😃')
        comment = body['comments'][1]
        self.assertEqual(comment['text'], 'srsly.  pretty good.')
Ejemplo n.º 3
0
    def test_list_comments_by_multiple_usernames(self):
        update = Update(request=UpdateRequest.testing,
                        type=UpdateType.enhancement,
                        notes='Just another update.',
                        date_submitted=datetime(1981, 10, 11),
                        requirements='rpmlint',
                        stable_karma=3,
                        unstable_karma=-3,
                        release=Release.query.one())
        self.db.add(update)

        another_user = User(name='aUser')
        self.db.add(another_user)

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

        res = self.app.get('/comments/', {"user": "******"})
        body = res.json_body
        assert len(body['comments']) == 2
        assert body['comments'][0]['text'] == 'Cool! 😃'
        assert body['comments'][1]['text'] == 'wow. amaze.'
Ejemplo n.º 4
0
    def test_list_comments_by_multiple_usernames(self):
        nvr = u'just-testing-1.0-2.fc17'
        update = Update(
            title=nvr,
            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)

        another_user = User(name=u'aUser')
        self.db.add(another_user)

        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/', {"user": "******"})
        body = res.json_body
        self.assertEqual(len(body['comments']), 2)
        self.assertEqual(body['comments'][0]['text'], u'Cool! 😃')
        self.assertEqual(body['comments'][1]['text'], u'wow. amaze.')
Ejemplo n.º 5
0
def populate(db):
    """
    Create some data for tests to use.

    Args:
        db (sqlalchemy.orm.session.Session): The database session.
    """
    user = User(name='guest')
    db.add(user)
    anonymous = User(name='anonymous')
    db.add(anonymous)
    provenpackager = Group(name='provenpackager')
    db.add(provenpackager)
    packager = Group(name='packager')
    db.add(packager)
    user.groups.append(packager)
    release = Release(name='F17',
                      long_name='Fedora 17',
                      id_prefix='FEDORA',
                      version='17',
                      dist_tag='f17',
                      stable_tag='f17-updates',
                      testing_tag='f17-updates-testing',
                      candidate_tag='f17-updates-candidate',
                      pending_signing_tag='f17-updates-signing-pending',
                      pending_testing_tag='f17-updates-testing-pending',
                      pending_stable_tag='f17-updates-pending',
                      override_tag='f17-override',
                      branch='f17',
                      state=ReleaseState.current,
                      create_automatic_updates=True,
                      package_manager=PackageManager.unspecified,
                      testing_repository=None)
    db.add(release)
    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'])
    update.type = UpdateType.bugfix
    update.severity = UpdateSeverity.medium
    bug = Bug(bug_id=12345)
    db.add(bug)
    update.bugs.append(bug)

    comment = Comment(karma=1, text="wow. amaze.")
    db.add(comment)
    comment.user = user
    update.comments.append(comment)

    comment = Comment(karma=0, text="srsly.  pretty good.")
    comment.user = anonymous
    db.add(comment)
    update.comments.append(comment)

    db.add(update)

    db.commit()
Ejemplo n.º 6
0
def populate(db):
    """
    Create some data for tests to use.

    Args:
        db (sqlalchemy.orm.session.Session): The database session.
    """
    user = User(name=u'guest')
    db.add(user)
    anonymous = User(name=u'anonymous')
    db.add(anonymous)
    provenpackager = Group(name=u'provenpackager')
    db.add(provenpackager)
    packager = Group(name=u'packager')
    db.add(packager)
    user.groups.append(packager)
    release = Release(name=u'F17',
                      long_name=u'Fedora 17',
                      id_prefix=u'FEDORA',
                      version=u'17',
                      dist_tag=u'f17',
                      stable_tag=u'f17-updates',
                      testing_tag=u'f17-updates-testing',
                      candidate_tag=u'f17-updates-candidate',
                      pending_signing_tag=u'f17-updates-testing-signing',
                      pending_testing_tag=u'f17-updates-testing-pending',
                      pending_stable_tag=u'f17-updates-pending',
                      override_tag=u'f17-override',
                      branch=u'f17',
                      state=ReleaseState.current)
    db.add(release)
    db.flush()
    update = create_update(db, [u'bodhi-2.0-1.fc17'])
    update.type = UpdateType.bugfix
    update.severity = UpdateSeverity.medium
    bug = Bug(bug_id=12345)
    db.add(bug)
    update.bugs.append(bug)
    cve = CVE(cve_id=u"CVE-1985-0110")
    db.add(cve)
    update.cves.append(cve)

    comment = Comment(karma=1, text=u"wow. amaze.")
    db.add(comment)
    comment.user = user
    update.comments.append(comment)

    comment = Comment(karma=0, text=u"srsly.  pretty good.", anonymous=True)
    comment.user = anonymous
    db.add(comment)
    update.comments.append(comment)

    with mock.patch(target='uuid.uuid4', return_value='wat'):
        update.assign_alias()
    db.add(update)

    db.commit()