def test_max_and_min(self): headers = {'content-type': 'application/json', 'cache-control': 'max-age=%s' % CACHE_CONTROL_MAX} assert get_max_age(headers) == CACHE_CONTROL_MAX headers = {'content-type': 'application/json', 'cache-control': 'max-age=%s' % CACHE_CONTROL_MIN} assert get_max_age(headers) == CACHE_CONTROL_MIN
def test_out_of_bounds(self): greater_than_max = CACHE_CONTROL_MAX + 1 headers = {'content-type': 'application/json', 'cache-control': 'max-age=%s' % greater_than_max} assert get_max_age(headers) == CACHE_CONTROL_MAX less_than_min = CACHE_CONTROL_MIN - 1 headers = {'content-type': 'application/json', 'cache-control': 'max-age=%s' % less_than_min} assert get_max_age(headers) == CACHE_CONTROL_MIN
def test_max_and_min(self): headers = { 'content-type': 'application/json', 'cache-control': 'max-age=%s' % CACHE_CONTROL_MAX } assert get_max_age(headers) == CACHE_CONTROL_MAX headers = { 'content-type': 'application/json', 'cache-control': 'max-age=%s' % CACHE_CONTROL_MIN } assert get_max_age(headers) == CACHE_CONTROL_MIN
def test_max_and_min(self): headers = { "content-type": "application/json", "cache-control": "max-age=%s" % CACHE_CONTROL_MAX, } assert get_max_age(headers) == CACHE_CONTROL_MAX headers = { "content-type": "application/json", "cache-control": "max-age=%s" % CACHE_CONTROL_MIN, } assert get_max_age(headers) == CACHE_CONTROL_MIN
def test_valid_input(self): headers = { "content-type": "application/json", "cache-control": "max-age=12df0sdgfjhdgf" } assert get_max_age(headers) == CACHE_CONTROL_MIN headers = { "content-type": "application/json", "cache-control": "max-age=df0sdgfjhdgf" } assert get_max_age(headers) == CACHE_CONTROL_MIN
def test_valid_input(self): headers = { 'content-type': 'application/json', 'cache-control': 'max-age=12df0sdgfjhdgf' } assert get_max_age(headers) == CACHE_CONTROL_MIN headers = { 'content-type': 'application/json', 'cache-control': 'max-age=df0sdgfjhdgf' } assert get_max_age(headers) == CACHE_CONTROL_MIN
def test_out_of_bounds(self): greater_than_max = CACHE_CONTROL_MAX + 1 headers = { 'content-type': 'application/json', 'cache-control': 'max-age=%s' % greater_than_max } assert get_max_age(headers) == CACHE_CONTROL_MAX less_than_min = CACHE_CONTROL_MIN - 1 headers = { 'content-type': 'application/json', 'cache-control': 'max-age=%s' % less_than_min } assert get_max_age(headers) == CACHE_CONTROL_MIN
def test_out_of_bounds(self): greater_than_max = CACHE_CONTROL_MAX + 1 headers = { "content-type": "application/json", "cache-control": "max-age=%s" % greater_than_max, } assert get_max_age(headers) == CACHE_CONTROL_MAX less_than_min = CACHE_CONTROL_MIN - 1 headers = { "content-type": "application/json", "cache-control": "max-age=%s" % less_than_min, } assert get_max_age(headers) == CACHE_CONTROL_MIN
def test_no_cache_control(self): headers = {'content-type': 'application/json'} assert get_max_age(headers) == CACHE_CONTROL_MIN
def test_simple(self): headers = { 'content-type': 'application/json', 'cache-control': 'max-age=120' } assert get_max_age(headers) == 120
def test_valid_input(self): headers = {'content-type': 'application/json', 'cache-control': 'max-age=12df0sdgfjhdgf'} assert get_max_age(headers) == CACHE_CONTROL_MIN headers = {'content-type': 'application/json', 'cache-control': 'max-age=df0sdgfjhdgf'} assert get_max_age(headers) == CACHE_CONTROL_MIN
def test_additional_cache_control_values(self): headers = {'content-type': 'application/json', 'cache-control': 'private, s-maxage=60, max-age=120'} assert get_max_age(headers) == 120
def test_simple(self): headers = {'content-type': 'application/json', 'cache-control': 'max-age=120'} assert get_max_age(headers) == 120
def test_additional_cache_control_values(self): headers = { "content-type": "application/json", "cache-control": "private, s-maxage=60, max-age=120", } assert get_max_age(headers) == 120
def test_additional_cache_control_values(self): headers = { 'content-type': 'application/json', 'cache-control': 'private, s-maxage=60, max-age=120' } assert get_max_age(headers) == 120
def test_simple(self): headers = { "content-type": "application/json", "cache-control": "max-age=120" } assert get_max_age(headers) == 120