# Path: dlstats/tests/base.py
# RESOURCES_DIR = os.path.abspath(os.path.dirname(resources.__file__))
# 
# Path: dlstats/utils.py
# MONGO_DENIED_KEY_CHARS = [".", "$"]
#     DEFAULT_HEADERS = {
#         'user-agent': 'dlstats - https://git.nomics.world/dbnomics/dlstats'
#     }
# def last_error():
# def make_store_path(base_path=None, provider_name=None, dataset_code=None):
# def get_url_hash(url):
#     def __init__(self, url=None, filename=None, store_filepath=None,
#                  timeout=None, max_retries=0,
#                  replace=True, force_replace=True, use_existing_file=False,
#                  headers={}, client=None):
#     def _download(self, raise_errors=True):
#     def get_filepath(self):
#     def get_filepath_and_response(self):
# def clean_datetime(dt=None,
#                    rm_hour=False,
#                    rm_minute=False,
#                    rm_second=False,
#                    rm_microsecond=True,
#                    rm_tzinfo=True):
# def remove_file_and_dir(filepath, let_root=False):
# def get_year(date_str):
# def get_month(date_str):
# def get_day(date_str):
# def get_datetime_from_period(date_str, freq=None):
# def get_ordinal_from_period(date_str, freq=None):
# def slugify(text, **kwargs):
# def clean_key(key):
# def clean_dict(dct):
# def json_dump_convert(obj):
# class Downloader:
# 
# Path: dlstats/cache.py
# class Cache(object):
#     DEFAULT_KEY_PREFIX = 'dlstats'
#     def __init__(self, 
#                  cache_url='simple', 
#                  cache_timeout=7200, #2H
#                  cache_threshold=20000,
#                  cache_prefix=None):
#     def _configure_null_cache(self):
#     def _configure_cache_simple(self):
#     def _configure_cache_redis(self, url):
#     def get(self, key, **kwargs):
#     def set(self, key, value, timeout=None):
#     def add(self, *args, **kwargs):
#     def delete(self, *args, **kwargs):
#     def delete_many(self, *args, **kwargs):
#     def clear(self):
#     def get_many(self, *args, **kwargs):
#     def set_many(self, *args, **kwargs):
# def configure_cache(**kwargs):
# def remove_cache():


from dlstats.tests.base import BaseTestCase
from dlstats import utils
from dlstats import cache
             ("1970", "A", 0),
             ("1969", "A", -1),
             ("1971", "A", 1),
             ("1970-01-01", "A", 0),
             ("19700101", "A", 0),

             ("1970-01", "M", 0),
             ("197001", "M", 0),
             ("1970-02", "M", 1),
             ("1969-12", "M", -1),
             ("1969-01", "M", -12),
             ("1971-01", "M", 12),
             ("1970-07", "M", 6),
             ("1971-07", "M", 18),
             ("1969-07", "M", -6),
             
             ("1970-Q1", "Q", 0),
             ("1970Q1", "Q", 0),
             ("1968-Q1", "Q", -8)
             
        ]
        
        for date_str, freq, result in TEST_VALUES:
            _value = utils.get_ordinal_from_period(date_str, freq)
            msg = "DATE[%s] - FREQ[%s] - ATEMPT[%s] - RETURN[%s]" % (date_str, freq, result, _value)
            self.assertEquals(_value, result, msg) 
    
        cache.configure_cache()
        
        for date_str, freq, result in TEST_VALUES:

# Path: dlstats/tests/base.py
# RESOURCES_DIR = os.path.abspath(os.path.dirname(resources.__file__))
# 
# Path: dlstats/utils.py
# MONGO_DENIED_KEY_CHARS = [".", "$"]
#     DEFAULT_HEADERS = {
#         'user-agent': 'dlstats - https://git.nomics.world/dbnomics/dlstats'
#     }
# def last_error():
# def make_store_path(base_path=None, provider_name=None, dataset_code=None):
# def get_url_hash(url):
#     def __init__(self, url=None, filename=None, store_filepath=None,
#                  timeout=None, max_retries=0,
#                  replace=True, force_replace=True, use_existing_file=False,
#                  headers={}, client=None):
#     def _download(self, raise_errors=True):
#     def get_filepath(self):
#     def get_filepath_and_response(self):
# def clean_datetime(dt=None,
#                    rm_hour=False,
#                    rm_minute=False,
#                    rm_second=False,
#                    rm_microsecond=True,
#                    rm_tzinfo=True):
# def remove_file_and_dir(filepath, let_root=False):
# def get_year(date_str):
# def get_month(date_str):
# def get_day(date_str):
# def get_datetime_from_period(date_str, freq=None):
# def get_ordinal_from_period(date_str, freq=None):
# def slugify(text, **kwargs):
# def clean_key(key):
# def clean_dict(dct):
# def json_dump_convert(obj):
# class Downloader:
# 
# Path: dlstats/cache.py
# class Cache(object):
#     DEFAULT_KEY_PREFIX = 'dlstats'
#     def __init__(self, 
#                  cache_url='simple', 
#                  cache_timeout=7200, #2H
#                  cache_threshold=20000,
#                  cache_prefix=None):
#     def _configure_null_cache(self):
#     def _configure_cache_simple(self):
#     def _configure_cache_redis(self, url):
#     def get(self, key, **kwargs):
#     def set(self, key, value, timeout=None):
#     def add(self, *args, **kwargs):
#     def delete(self, *args, **kwargs):
#     def delete_many(self, *args, **kwargs):
#     def clear(self):
#     def get_many(self, *args, **kwargs):
#     def set_many(self, *args, **kwargs):
# def configure_cache(**kwargs):
# def remove_cache():


# Path: dlstats/tests/test_utils.py
from dlstats.tests.base import BaseTestCase
from dlstats import utils
from dlstats import cache

             ("1970", "A", 0),
             ("1969", "A", -1),
             ("1971", "A", 1),
             ("1970-01-01", "A", 0),
             ("19700101", "A", 0),

             ("1970-01", "M", 0),
             ("197001", "M", 0),
             ("1970-02", "M", 1),
             ("1969-12", "M", -1),
             ("1969-01", "M", -12),
             ("1971-01", "M", 12),
             ("1970-07", "M", 6),
             ("1971-07", "M", 18),
             ("1969-07", "M", -6),
             
             ("1970-Q1", "Q", 0),
             ("1970Q1", "Q", 0),
             ("1968-Q1", "Q", -8)
             
        ]
        
        for date_str, freq, result in TEST_VALUES:
            _value = utils.get_ordinal_from_period(date_str, freq)
            msg = "DATE[%s] - FREQ[%s] - ATEMPT[%s] - RETURN[%s]" % (date_str, freq, result, _value)
            self.assertEquals(_value, result, msg) 
    
        cache.configure_cache()
        
        for date_str, freq, result in TEST_VALUES:

            _value = utils.get_ordinal_from_period(date_str, freq)