<s> from mock import patch <EOL> from django . test import TestCase <EOL> from dbbackup . storage . base import get_storage , BaseStorage <EOL> from dbbackup . tests . utils import HANDLED_FILES , FakeStorage <EOL> from dbbackup import utils <EOL> DEFAULT_STORAGE_PATH = '<STR_LIT>' <EOL> STORAGE_OPTIONS = { '<STR_LIT:location>' : '<STR_LIT>' } <EOL> class Get_StorageTest ( TestCase ) : <EOL> @ patch ( '<STR_LIT>' , DEFAULT_STORAGE_PATH ) <EOL> @ patch ( '<STR_LIT>' , STORAGE_OPTIONS ) <EOL> def test_func ( self , * args ) : <EOL> storage = get_storage ( ) <EOL> self . assertEqual ( storage . __module__ , DEFAULT_STORAGE_PATH ) <EOL> def test_set_path ( self ) : <EOL> storage = get_storage ( path = FakeStorage . __module__ ) <EOL> self . assertIsInstance ( storage , FakeStorage ) <EOL> @ patch ( '<STR_LIT>' , DEFAULT_STORAGE_PATH ) <EOL> def test_set_options ( self , * args ) : <EOL> storage = get_storage ( options = STORAGE_OPTIONS ) <EOL> self . assertEqual ( storage . __module__ , DEFAULT_STORAGE_PATH ) <EOL> class BaseStorageTest ( TestCase ) : <EOL> def setUp ( self ) : <EOL> self . storageCls = BaseStorage <EOL> self . storageCls . name = '<STR_LIT:foo>' <EOL> self . storage = BaseStorage ( ) <EOL> class StorageListBackupsTest ( TestCase ) : <EOL> def setUp ( self ) : <EOL> self . storage = FakeStorage ( ) <EOL> HANDLED_FILES [ '<STR_LIT>' ] += [ <EOL> ( utils . filename_generate ( ext , '<STR_LIT:foo>' ) , None ) for ext in <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> ] <EOL> HANDLED_FILES [ '<STR_LIT>' ] += [ <EOL> ( utils . filename_generate ( ext , '<STR_LIT:foo>' , None , '<STR_LIT>' ) , None ) for ext in <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> ] <EOL> HANDLED_FILES [ '<STR_LIT>' ] += [ <EOL> ( '<STR_LIT>' , None ) <EOL> ] <EOL> def tearDown ( self ) : <EOL> HANDLED_FILES . clean ( ) <EOL> def test_nofilter ( self ) : <EOL> files = self . storage . list_backups ( ) <EOL> for file in files : <EOL> self . assertNotEqual ( '<STR_LIT>' , file ) <EOL> def test_encrypted ( self ) : <EOL> files = self . storage . list_backups ( encrypted = True ) <EOL> for file in files : <EOL> self . assertIn ( '<STR_LIT>' , file ) <EOL> def test_compressed ( self ) : <EOL> files = self . storage . list_backups ( compressed = True ) <EOL> for file in files : <EOL> self . assertIn ( '<STR_LIT>' , file ) <EOL> def test_dbbackup ( self ) : <EOL> files = self . storage . list_backups ( content_type = '<STR_LIT>' ) <EOL> for file in files : <EOL> self . assertIn ( '<STR_LIT>' , file ) <EOL> def test_database ( self ) : <EOL> files = self . storage . list_backups ( database = '<STR_LIT:foo>' ) <EOL> for file in files : <EOL> self . assertIn ( '<STR_LIT:foo>' , file ) <EOL> def test_mediabackup ( self ) : <EOL> files = self . storage . list_backups ( content_type = '<STR_LIT>' ) <EOL> for file in files : <EOL> self . assertIn ( '<STR_LIT>' , file ) <EOL> class StorageGetLatestTest ( TestCase ) : <EOL> def setUp ( self ) : <EOL> self . storage = FakeStorage ( ) <EOL> HANDLED_FILES [ '<STR_LIT>' ] = [ ( f , None ) for f in [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] ] <EOL> def tearDown ( self ) : <EOL> HANDLED_FILES . clean ( ) <EOL> def test_func ( self ) : <EOL> filename = self . storage . get_latest_backup ( ) <EOL> self . assertEqual ( filename , '<STR_LIT>' ) <EOL> class StorageGetMostRecentTest ( TestCase ) : <EOL> def setUp ( self ) : <EOL> self . storage = FakeStorage ( ) <EOL> HANDLED_FILES [ '<STR_LIT>' ] = [ ( f , None ) for f in [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] ] <EOL> def tearDown ( self ) : <EOL> HANDLED_FILES . clean ( ) <EOL> def test_func ( self ) : <EOL> filename = self . storage . get_older_backup ( ) <EOL> self . assertEqual ( filename , '<STR_LIT>' ) <EOL> class StorageCleanOldBackupsTest ( TestCase ) : <EOL> def setUp ( self ) : <EOL> self . storage = FakeStorage ( ) <EOL> HANDLED_FILES [ '<STR_LIT>' ] = [ ( f , None ) for f in [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] ] <EOL> def tearDown ( self ) : <EOL> HANDLED_FILES . clean ( ) <EOL> def test_func ( self ) : <EOL> self . storage . clean_old_backups ( keep_number = <NUM_LIT:1> ) <EOL> self . assertEqual ( <NUM_LIT:2> , len ( HANDLED_FILES [ '<STR_LIT>' ] ) ) </s>
