def test_resolve_catch_all_to_cache_control(self):
     cache = config.resolve_cache_rules(
         'test', [{
             'match': '*',
             'cache_control': 'public, maxage=500'
         }])
     self.assertEqual(cache, 'public, maxage=500')
 def test_resolve_catch_all_to_both(self):
     cache = config.resolve_cache_rules('test', [{
         'match': '*',
         'cache_control': 'public',
         'maxage': '1 hour'
     }])
     self.assertEqual('public, maxage=3600', cache)
Beispiel #3
0
 def test_resolve_second_rule(self):
     cache = config.resolve_cache_rules('test', [
         {'match': 'other/*', 'maxage': 100},
         {'match': 'test', 'maxage': 200},
         {'match': '*', 'maxage': 300}
     ])
     self.assertEqual(cache, 'max-age=200')
Beispiel #4
0
 def test_resolve_second_rule(self):
     cache = config.resolve_cache_rules('test', [
         {'match': 'other/*', 'maxage': 100},
         {'match': 'test', 'maxage': 200},
         {'match': '*', 'maxage': 300}
     ])
     self.assertEqual(cache, 'maxage=200')
 def test_resolve_no_rules(self):
     cache = config.resolve_cache_rules('test', [{
         'match': 'test1'
     }, {
         'match': 'test2'
     }])
     self.assertIsNone(cache)
Beispiel #6
0
 def test_resolve_catch_all_to_maxage_integer(self):
     cache = config.resolve_cache_rules('test', [
         {'match': '*', 'maxage': 3600}
     ])
     self.assertEqual('max-age=3600', cache)
Beispiel #7
0
 def test_resolve_no_match_key(self):
     with self.assertRaises(ValueError):
         config.resolve_cache_rules('test', [
             {'maxage': 3000},
         ])
Beispiel #8
0
 def test_resolve_empty(self):
     cache = config.resolve_cache_rules('test', [])
     self.assertIsNone(cache)
Beispiel #9
0
 def test_resolve_regexp_match_key(self):
     cache = config.resolve_cache_rules('test', [
         {'match_regexp': 't[es]{2}(t|a)$', 'maxage': 100},
     ])
     self.assertEqual(cache, 'max-age=100')
Beispiel #10
0
 def test_resolve_multiple_match_keys(self):
     with self.assertRaises(ValueError):
         config.resolve_cache_rules('test', [
             {'match': 'test*', 'match_regexp': 'test.*'},
         ])
Beispiel #11
0
 def test_resolve_catch_all_to_cache_control(self):
     cache = config.resolve_cache_rules('test', [
         {'match': '*', 'cache_control': 'public, maxage=500'}
     ])
     self.assertEqual(cache, 'public, maxage=500')
Beispiel #12
0
 def test_resolve_catch_all_to_maxage_string(self):
     cache = config.resolve_cache_rules('test', [
         {'match': '*', 'maxage': '1 hour'}
     ])
     self.assertEqual('max-age=3600', cache)
Beispiel #13
0
 def test_resolve_no_rules(self):
     cache = config.resolve_cache_rules('test', [
         {'match': 'test1'},
         {'match': 'test2'}
     ])
     self.assertIsNone(cache)
Beispiel #14
0
 def test_resolve_catch_all_to_none(self):
     cache = config.resolve_cache_rules('test', [
         {'match': '*'}
     ])
     self.assertIsNone(cache)
Beispiel #15
0
 def test_resolve_catch_all_to_both(self):
     cache = config.resolve_cache_rules('test', [
         {'match': '*', 'cache_control': 'public', 'maxage': '1 hour'}
     ])
     self.assertEqual('public, maxage=3600', cache)
Beispiel #16
0
 def test_resolve_catch_all_to_maxage_string(self):
     cache = config.resolve_cache_rules('test', [
         {'match': '*', 'maxage': '1 hour'}
     ])
     self.assertEqual('maxage=3600', cache)
Beispiel #17
0
 def test_resolve_catch_all_to_maxage_integer(self):
     cache = config.resolve_cache_rules('test', [
         {'match': '*', 'maxage': 3600}
     ])
     self.assertEqual('maxage=3600', cache)
Beispiel #18
0
 def test_resolve_catch_all_to_none(self):
     cache = config.resolve_cache_rules('test', [
         {'match': '*'}
     ])
     self.assertIsNone(cache)
Beispiel #19
0
 def test_resolve_empty(self):
     cache = config.resolve_cache_rules('test', [])
     self.assertIsNone(cache)