Example #1
0
class TrafficTest(TestCase):
    def setUp(self):
        self.admin = RequestAdmin(Request, site)
        self.factory = RequestFactory()

    def test_traffic(self):
        request = self.factory.get('/foo')
        self.admin.traffic(request)

    @override_settings(USE_I18N=False)
    def test_traffic_without_i18n(self):
        del _trans.gettext
        request = self.factory.get('/foo')
        self.admin.traffic(request)

    def test_bad_days(self):
        request = self.factory.get('/foo', {'days': 'foo'})
        self.admin.traffic(request)

    def test_days(self):
        for days, intervals in ((9, 10), (30, 16), (365, 13)):
            request = self.factory.get('/foo', {'days': days})
            data = json.loads(self.admin.traffic(request).content.decode())
            for single_data in data:
                self.assertEqual(len(single_data['data']), intervals)
Example #2
0
class TrafficTest(TestCase):
    def setUp(self):
        self.admin = RequestAdmin(Request, site)
        self.factory = RequestFactory()

    def test_traffic(self):
        request = self.factory.get('/foo')
        self.admin.traffic(request)

    def test_bad_days(self):
        request = self.factory.get('/foo', {'days': 'foo'})
        self.admin.traffic(request)

    def test_days_lt_10(self):
        request = self.factory.get('/foo', {'days': 9})
        self.admin.traffic(request)

    def test_days_gt_60(self):
        request = self.factory.get('/foo', {'days': 61})
        self.admin.traffic(request)
Example #3
0
 def setUp(self):
     self.admin = RequestAdmin(Request, site)
     self.factory = RequestFactory()
Example #4
0
 def test_overview(self):
     admin = RequestAdmin(Request, site)
     factory = RequestFactory()
     request = factory.get('/foo')
     admin.overview(request)
Example #5
0
 def test_get_urls(self):
     admin = RequestAdmin(Request, site)
     admin.get_urls()
Example #6
0
 def test_without_user_id(self):
     admin = RequestAdmin(Request, site)
     request = Request.objects.create(ip='1.2.3.4')
     admin.request_from(request)
Example #7
0
 def test_user_id(self):
     admin = RequestAdmin(Request, site)
     user = get_user_model().objects.create(username='******')
     request = Request.objects.create(user=user, ip='1.2.3.4')
     admin.request_from(request)
Example #8
0
 def test_lookup_allowed(self):
     admin = RequestAdmin(Request, site)
     admin.lookup_allowed('user__username', 'foo')
     admin.lookup_allowed('response', 200)