コード例 #1
0
 def test_month_min_max(self):
     cases = [
         ((2016,1,5),  (2016,1,1), (2016,1,31)),
         ((2016,2,14), (2016,2,1), (2016,2,29)),
         ((2016,3,19), (2016,3,1), (2016,3,31)),
         ((2016,4,7),  (2016,4,1), (2016,4,30)),
         ((2016,5,4),  (2016,5,1), (2016,5,31)),
     ]
     for given_ymd, start_ymd, end_ymd in cases:
         actual_min_max = utils.month_min_max(datetime(*given_ymd))
         expected_min = datetime(*start_ymd)
         expected_max = datetime(*end_ymd)
         self.assertEqual(actual_min_max, (expected_min, expected_max))
コード例 #2
0
 def test_month_min_max(self):
     cases = [
         ((2016, 1, 5), (2016, 1, 1), (2016, 1, 31)),
         ((2016, 2, 14), (2016, 2, 1), (2016, 2, 29)),
         ((2016, 3, 19), (2016, 3, 1), (2016, 3, 31)),
         ((2016, 4, 7), (2016, 4, 1), (2016, 4, 30)),
         ((2016, 5, 4), (2016, 5, 1), (2016, 5, 31)),
     ]
     for given_ymd, start_ymd, end_ymd in cases:
         actual_min_max = utils.month_min_max(datetime(*given_ymd))
         expected_min = datetime(*start_ymd)
         expected_max = datetime(*end_ymd)
         self.assertEqual(actual_min_max, (expected_min, expected_max))
コード例 #3
0
    root = os.path.dirname(os.path.dirname(__file__))
    if os.environ.get("TESTING"):
        root = os.getenv("TEST_OUTPUT_DIR")
    return join(root, OUTPUT_SUBDIR)


VIEWS_INCEPTION = datetime(year=2014, month=3, day=12)
DOWNLOADS_INCEPTION = datetime(year=2015, month=2, day=13)

# when we switched away from HW
SITE_SWITCH = datetime(year=2016, month=2, day=9)

# when we were told to use versionless urls for latest article version
# https://github.com/elifesciences/elife-website/commit/446408019f7ec999adc6c9a80e8fa28966a42304
VERSIONLESS_URLS = datetime(year=2016, month=5, day=5)
VERSIONLESS_URLS_MONTH = month_min_max(VERSIONLESS_URLS)

#
# utils
#


def valid_dt_pair(dt_pair, inception):
    "returns true if both dates are greater than the date we started collecting on"
    from_date, to_date = dt_pair
    return from_date >= inception and to_date >= inception


def valid_view_dt_pair(dt_pair):
    "returns true if both dates are greater than the date we started collecting on"
    return valid_dt_pair(dt_pair, VIEWS_INCEPTION)
コード例 #4
0
    root = os.path.dirname(os.path.dirname(__file__))
    if os.environ.get('TESTING'):
        root = os.getenv('TEST_OUTPUT_DIR')
    return join(root, OUTPUT_SUBDIR)


VIEWS_INCEPTION = datetime(year=2014, month=3, day=12)
DOWNLOADS_INCEPTION = datetime(year=2015, month=2, day=13)

# when we switched away from HW
SITE_SWITCH = datetime(year=2016, month=2, day=9)

# when we were told to use versionless urls for latest article version
# https://github.com/elifesciences/elife-website/commit/446408019f7ec999adc6c9a80e8fa28966a42304
VERSIONLESS_URLS = datetime(year=2016, month=5, day=5)
VERSIONLESS_URLS_MONTH = month_min_max(VERSIONLESS_URLS)

#
# utils
#


def valid_dt_pair(dt_pair, inception):
    "returns true if both dates are greater than the date we started collecting on"
    from_date, to_date = dt_pair
    return from_date >= inception and to_date >= inception


def valid_view_dt_pair(dt_pair):
    "returns true if both dates are greater than the date we started collecting on"
    return valid_dt_pair(dt_pair, VIEWS_INCEPTION)