<s> import unittest <EOL> from mock import patch <EOL> from drupan . site import Site <EOL> from drupan . config import Config <EOL> from drupan . deployment . s3cf import ( <EOL> Deploy , <EOL> S3HostMissingException , <EOL> guess_mime_type , <EOL> ) <EOL> class TestS3cf ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . site = Site ( ) <EOL> self . config = Config ( ) <EOL> cfg = { <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> } , <EOL> } <EOL> } <EOL> self . config . from_dict ( cfg ) <EOL> def test_init_missing_bucket ( self ) : <EOL> """<STR_LIT>""" <EOL> self . config . options [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> self . assertRaises ( <EOL> S3HostMissingException , <EOL> Deploy , <EOL> self . site , <EOL> self . config , <EOL> ) <EOL> self . config . options [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT:foo>" <EOL> Deploy ( self . site , self . config ) <EOL> def test_guess_mime_type ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( guess_mime_type ( "<STR_LIT:foo>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( guess_mime_type ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( guess_mime_type ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( guess_mime_type ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( guess_mime_type ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> def test_redirects ( self ) : <EOL> """<STR_LIT>""" <EOL> deploy = Deploy ( self . site , self . config ) <EOL> self . assertEqual ( deploy . redirects , "<STR_LIT>" ) <EOL> self . config . redirects = "<STR_LIT>" <EOL> self . config . options [ "<STR_LIT>" ] [ "<STR_LIT>" ] = None <EOL> deploy = Deploy ( self . site , self . config ) <EOL> self . assertEqual ( deploy . redirects , "<STR_LIT>" ) <EOL> def test_redirect_exists ( self ) : <EOL> """<STR_LIT>""" <EOL> class BucketMock ( object ) : <EOL> @ classmethod <EOL> def get_key ( cls , redirect ) : <EOL> return redirect <EOL> deploy = Deploy ( self . site , self . config ) <EOL> deploy . bucket = BucketMock ( ) <EOL> self . assertTrue ( deploy . redirect_exists ( True ) ) <EOL> self . assertFalse ( deploy . redirect_exists ( False ) ) <EOL> @ patch ( "<STR_LIT>" ) <EOL> def test_upload_assets ( self , mock ) : <EOL> """<STR_LIT>""" <EOL> deploy = Deploy ( self . site , self . config ) <EOL> deploy . site . assets [ "<STR_LIT:foo>" ] = "<STR_LIT:foo>" <EOL> deploy . site . assets [ "<STR_LIT>" ] = "<STR_LIT:bar>" <EOL> deploy . upload_assets ( ) <EOL> mock . assert_called_once_with ( "<STR_LIT:foo>" , "<STR_LIT:foo>" ) </s>
