Exemplo n.º 1
0
    def test_redirecting_speed_without_redis(self):
        for i in range(1000):
            url_obj = Url()
            url_obj.long_url = f'www.google.com/{i}'
            url_obj.time = datetime.now(pytz.utc)
            url_obj.shortened_url = url_obj.generate_id(6)
            url_obj.save()

        url_obj_500 = Url.objects.filter(long_url='www.google.com/500').first()

        start = process_time()
        for i in range(1000):
            response = self.client.get(f'/app/detail_without_redis/{url_obj_500.shortened_url}/')

            self.assertEqual(response.status_code, 302)
            self.assertEqual(response.url, 'https://www.google.com/500')

        end = process_time()

        print(f'Process time without Redis: {end - start}')