def test_render_to_csv_response(self): queryset = OSFWebsiteStatistics.objects.all().order_by('-date') response = render_to_csv_response(queryset) self.assertEqual(response['Content-Type'], 'text/csv') self.assertEqual(response.content.split('\n'), self.initial_static) self.assertRegexpMatches(response['Content-Disposition'], r'attachment; filename=osfwebsitestatistics_export.csv;') get_osf_statistics() new_queryset = OSFWebsiteStatistics.objects.all().order_by('-date') new_res = render_to_csv_response(new_queryset) self.assertEqual(new_res['Content-Type'], 'text/csv') self.assertEqual(new_res.content.split('\n'), self.latest_static) self.assertRegexpMatches(new_res['Content-Disposition'], r'attachment; filename=osfwebsitestatistics_export.csv;')
def test_dont_add_another(self): nt.assert_equal(OSFWebsiteStatistics.objects.count(), 1) get_osf_statistics() nt.assert_equal(OSFWebsiteStatistics.objects.count(), 3) get_osf_statistics() nt.assert_equal(OSFWebsiteStatistics.objects.count(), 3)
def test_get_two_more_days(self): nt.assert_equal(OSFWebsiteStatistics.objects.count(), 1) get_osf_statistics() nt.assert_equal(OSFWebsiteStatistics.objects.count(), 3)
def update_metrics(request): get_osf_statistics() return redirect(reverse('metrics:stats_list'))