<s> from __future__ import unicode_literals <EOL> from django . test import ( <EOL> TestCase , <EOL> ) <EOL> from django . test . utils import override_settings <EOL> from cookie_consent . models import ( <EOL> Cookie , <EOL> CookieGroup , <EOL> ) <EOL> from cookie_consent . cache import ( <EOL> get_cookie_group , <EOL> get_cookie , <EOL> ) <EOL> class CacheTest ( TestCase ) : <EOL> def setUp ( self ) : <EOL> self . cookie_group = CookieGroup . objects . create ( <EOL> varname = "<STR_LIT>" , <EOL> name = "<STR_LIT>" , <EOL> ) <EOL> self . cookie = Cookie . objects . create ( <EOL> cookiegroup = self . cookie_group , <EOL> name = "<STR_LIT:foo>" , <EOL> ) <EOL> def test_get_cookie_group ( self ) : <EOL> self . assertEqual ( get_cookie_group ( "<STR_LIT>" ) , self . cookie_group ) <EOL> def test_get_cookie ( self ) : <EOL> cookie_group = get_cookie_group ( "<STR_LIT>" ) <EOL> self . assertEqual ( get_cookie ( cookie_group , "<STR_LIT:foo>" , "<STR_LIT>" ) , self . cookie ) <EOL> def test_caching ( self ) : <EOL> CookieGroup . objects . create ( <EOL> varname = "<STR_LIT:foo>" , <EOL> name = "<STR_LIT>" , <EOL> ) <EOL> with self . assertNumQueries ( <NUM_LIT:2> ) : <EOL> cookie_group = get_cookie_group ( "<STR_LIT>" ) <EOL> get_cookie_group ( "<STR_LIT:foo>" ) <EOL> get_cookie ( cookie_group , "<STR_LIT:foo>" , "<STR_LIT>" ) <EOL> def test_caching_expire ( self ) : <EOL> with self . assertNumQueries ( <NUM_LIT:2> ) : <EOL> cookie_group = get_cookie_group ( "<STR_LIT>" ) <EOL> self . cookie_group . name = "<STR_LIT>" <EOL> self . cookie_group . save ( ) <EOL> with self . assertNumQueries ( <NUM_LIT:2> ) : <EOL> cookie_group = get_cookie_group ( "<STR_LIT>" ) <EOL> self . assertEqual ( cookie_group . name , "<STR_LIT>" ) </s>
