def test_stats(self): """ stats return a dict """ cache.set("stats_nb_pack", 1) cache.set("stats_nb_packversion", 2) cache.set("stats_nb_dispack", 3) result = stats() attend = {'stats_nb_pack': 1, 'stats_nb_packbersion': 2, 'dispack': 3} self.assertEqual(result, attend)
def userreq(request): """ Main page containing the form to lookup used on homepage """ queryset = Package.objects.all().order_by('-pk')[:7] lkups = Lookup.objects.all().order_by('-pk')[:4] distributions = Distribution.objects.filter(official=None).order_by('-pk') dists = [(r.id, "%s %s" % (r.name, r.version_name)) for r in distributions] form = ReqForm(dists) return render(request, 'form.html', {'form': form, 'packages': queryset, 'lookups': lkups, 'stats': stats() })