<s> """<STR_LIT>""" <EOL> import datetime <EOL> import unittest2 as unittest <EOL> import mock <EOL> from googleapiclient . discovery_cache import DISCOVERY_DOC_MAX_AGE <EOL> from googleapiclient . discovery_cache . base import Cache <EOL> from googleapiclient . discovery_cache . file_cache import Cache as FileCache <EOL> class FileCacheTest ( unittest . TestCase ) : <EOL> @ mock . patch ( '<STR_LIT>' , <EOL> new = '<STR_LIT>' ) <EOL> def test_expiration ( self ) : <EOL> def future_now ( ) : <EOL> return datetime . datetime . now ( ) + datetime . timedelta ( <EOL> seconds = DISCOVERY_DOC_MAX_AGE ) <EOL> mocked_datetime = mock . MagicMock ( ) <EOL> mocked_datetime . datetime . now . side_effect = future_now <EOL> cache = FileCache ( max_age = DISCOVERY_DOC_MAX_AGE ) <EOL> first_url = '<STR_LIT>' <EOL> first_url_content = '<STR_LIT>' <EOL> cache . set ( first_url , first_url_content ) <EOL> self . assertEqual ( first_url_content , cache . get ( first_url ) ) <EOL> with mock . patch ( '<STR_LIT>' , <EOL> new = mocked_datetime ) : <EOL> cache . set ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertEqual ( None , cache . get ( first_url ) ) </s>
