# Path: happenings/utils/common.py
# def get_net(req):
#     """Get the net of any 'next' and 'prev' querystrings."""
#     try:
#         nxt, prev = map(
#             int, (req.GET.get('cal_next', 0), req.GET.get('cal_prev', 0))
#         )
#         net = nxt - prev
#     except Exception:
#         net = 0
#     return net


from django.test import TestCase
from django.core.urlresolvers import reverse
from django.test.client import RequestFactory
from happenings.utils.common import get_net
from __future__ import unicode_literals




class GetNetTest(TestCase):
    def setUp(self):
        self.factory = RequestFactory()
        self.url = reverse('calendar:list')

    def test_valid_next(self):
        url = self.url + '?cal_next=1'
        req = self.factory.get(url)
        net = get_net(req)
        self.assertEqual(net, 1)

    def test_valid_prev(self):
        url = self.url + '?cal_prev=1'
        req = self.factory.get(url)

# Path: happenings/utils/common.py
# def get_net(req):
#     """Get the net of any 'next' and 'prev' querystrings."""
#     try:
#         nxt, prev = map(
#             int, (req.GET.get('cal_next', 0), req.GET.get('cal_prev', 0))
#         )
#         net = nxt - prev
#     except Exception:
#         net = 0
#     return net


# Path: tests/unit_tests/test_utils/test_get_net.py
from django.test import TestCase
from django.core.urlresolvers import reverse
from django.test.client import RequestFactory
from happenings.utils.common import get_net

from __future__ import unicode_literals




class GetNetTest(TestCase):
    def setUp(self):
        self.factory = RequestFactory()
        self.url = reverse('calendar:list')

    def test_valid_next(self):
        url = self.url + '?cal_next=1'
        req = self.factory.get(url)
        net = get_net(req)
        self.assertEqual(net, 1)

    def test_valid_prev(self):
        url = self.url + '?cal_prev=1'
        req = self.factory.get(url)

        net = get_net(req)