# Path: wms/wms_handler.py
# def get_time(request):
#     """
#     Return the min and max times
#     """
#     time = request.GET.get('time')
#     if time is None:
#         return datetime.utcnow()
#     else:
#         dt = parse(time)
#         if dt.tzinfo is not None:
#             utc_dt = dt.astimezone(tzutc())  # convert UTC if tzinfo is available
#             utc_tz_naive = utc_dt.replace(tzinfo=None)
#         else:
#             utc_tz_naive = dt
#         return utc_tz_naive
# 
# def get_projection(request):
#     """
#     Return the projection string passed into the request.
#     Can be specified by \"SRS\" or \"CRS\" key (string).
#     If \"SRS\" or \"CRS\" is not available, default to mercator.
#     """
#     projstr = request.GET.get("srs", request.GET.get("crs"))
#     if not projstr:
#         projstr = "EPSG:3857"
#         logger.debug("SRS or CRS no available in requst, defaulting to EPSG:3857 (mercator)")
# 
#     return pyproj.Proj(init=projstr)


import datetime
import pyproj
from django.test import TestCase
from django.test.client import RequestFactory
from ..wms_handler import get_time, get_projection
'''
Created on Aug 28, 2015

@author: ayan
'''





class TestGetTime(TestCase):

    def setUp(self):
        self.factory = RequestFactory()

    def test_get_time_with_offset(self):
        request = self.factory.get('/dataset?time=2015-01-01T15%3A00%3A00-05%3A00')

# Path: wms/wms_handler.py
# def get_time(request):
#     """
#     Return the min and max times
#     """
#     time = request.GET.get('time')
#     if time is None:
#         return datetime.utcnow()
#     else:
#         dt = parse(time)
#         if dt.tzinfo is not None:
#             utc_dt = dt.astimezone(tzutc())  # convert UTC if tzinfo is available
#             utc_tz_naive = utc_dt.replace(tzinfo=None)
#         else:
#             utc_tz_naive = dt
#         return utc_tz_naive
# 
# def get_projection(request):
#     """
#     Return the projection string passed into the request.
#     Can be specified by \"SRS\" or \"CRS\" key (string).
#     If \"SRS\" or \"CRS\" is not available, default to mercator.
#     """
#     projstr = request.GET.get("srs", request.GET.get("crs"))
#     if not projstr:
#         projstr = "EPSG:3857"
#         logger.debug("SRS or CRS no available in requst, defaulting to EPSG:3857 (mercator)")
# 
#     return pyproj.Proj(init=projstr)


# Path: wms/tests/test_wms_handler.py
import datetime
import pyproj
from django.test import TestCase
from django.test.client import RequestFactory
from ..wms_handler import get_time, get_projection

'''
Created on Aug 28, 2015

@author: ayan
'''





class TestGetTime(TestCase):

    def setUp(self):
        self.factory = RequestFactory()

    def test_get_time_with_offset(self):
        request = self.factory.get('/dataset?time=2015-01-01T15%3A00%3A00-05%3A00')

        result_time = get_time(request)