'Tests version nomination sort order.'

def test_do_sort_version_nom(self):

    url = reverse('reviewers.apps.queue_pending')
    user = UserProfile.objects.get(email='editor@mozilla.com')
    version_0 = self.apps[0].versions.get()
    version_0.update(nomination=days_ago(1))
    version_1 = self.apps[1].versions.get()
    version_1.update(nomination=days_ago(2))
    version_factory({'status': mkt.STATUS_DISABLED}, addon=self.apps[0], nomination=days_ago(10))
    version_factory({'status': mkt.STATUS_DISABLED}, addon=self.apps[1], nomination=days_ago(1))
    version_factory({'status': mkt.STATUS_DISABLED}, addon=self.apps[1], nomination=days_ago(20))
    req = mkt.site.tests.req_factory_factory(url, user=user, data={'sort': 'nomination'})
    res = queue_apps(req)
    doc = pq(res.content)
    eq_(doc('tbody    tr')[0].get('data-addon'), str(version_1.addon.id))
    eq_(doc('tbody    tr')[2].get('data-addon'), str(version_0.addon.id))
    req = mkt.site.tests.req_factory_factory(url, user=user, data={'sort': 'nomination', 'order': 'desc'})
    res = queue_apps(req)
    doc = pq(res.content)
    eq_(doc('tbody    tr')[0].get('data-addon'), str(version_0.addon.id))
    eq_(doc('tbody    tr')[2].get('data-addon'), str(version_1.addon.id))
