def test_delete_raises_file_not_found_for_unknown_file(self): mock_s3() (flexmock(S3Connection).should_receive('get_bucket').and_return( MockBucket())) storage = S3BotoStorage('some bucket') with raises(FileNotFoundError): storage.delete('key')
def setup_method(self, method): TestCase.setup_method(self, method) flexmock(S3BotoStorage) \ .should_receive('_get_or_create_bucket') \ .with_args('some_bucket') \ .and_return(MockBucket()) self.storage = S3BotoStorage('some_bucket') self.file = S3BotoStorageFile(self.storage, 'some_file')
def test_open_returns_file_object(self): mock_s3() flexmock(S3BotoStorage) \ .should_receive('_get_or_create_bucket') \ .with_args('some_bucket') \ .and_return(MockBucket()) storage = S3BotoStorage('some_bucket') file_ = storage.open('some_file') assert isinstance(file_, S3BotoStorageFile)
def test_save_file_with_content_as_string(self): mock_s3() (flexmock(S3Connection).should_receive('get_bucket').and_return( MockBucket())) storage = S3BotoStorage('some bucket') storage.save('some_file', 'some content')
def test_list_files_returns_list_of_key_names(self): mock_s3() (flexmock(S3Connection).should_receive('get_bucket').and_return( MockBucket())) storage = S3BotoStorage('some bucket') assert storage.list_files() == []
def test_assigns_folder_on_initialization(self): mock_s3() storage = S3BotoStorage('some bucket') assert storage.folder_name == 'some bucket'
def setup_method(self, method): TestCase.setup_method(self, method) self.storage = S3BotoStorage()