예제 #1
0
    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
예제 #2
0
    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
예제 #3
0
    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
예제 #4
0
    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
예제 #5
0
    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
예제 #6
0
    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
예제 #7
0
    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
예제 #8
0
    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
예제 #9
0
 def test_no_cache_control(self):
     headers = {'content-type': 'application/json'}
     assert get_max_age(headers) == CACHE_CONTROL_MIN
예제 #10
0
 def test_simple(self):
     headers = {
         'content-type': 'application/json',
         'cache-control': 'max-age=120'
     }
     assert get_max_age(headers) == 120
예제 #11
0
    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
예제 #12
0
 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
예제 #13
0
 def test_simple(self):
     headers = {'content-type': 'application/json', 'cache-control': 'max-age=120'}
     assert get_max_age(headers) == 120
예제 #14
0
 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
예제 #15
0
 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
예제 #16
0
 def test_no_cache_control(self):
     headers = {'content-type': 'application/json'}
     assert get_max_age(headers) == CACHE_CONTROL_MIN
예제 #17
0
 def test_simple(self):
     headers = {
         "content-type": "application/json",
         "cache-control": "max-age=120"
     }
     assert get_max_age(headers) == 120