Skip to content

Commit

Permalink
Add test for --force option that was moved
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesls committed Feb 4, 2015
1 parent d83bfc4 commit 31260e1
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion tests/unit/customizations/s3/test_subcommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
import botocore.session
from awscli.customizations.s3.s3 import S3
from awscli.customizations.s3.subcommands import CommandParameters, \
CommandArchitecture, CpCommand, SyncCommand, ListCommand, get_endpoint
CommandArchitecture, CpCommand, SyncCommand, ListCommand, get_endpoint, \
RbCommand
from awscli.customizations.s3.syncstrategy.base import \
SizeAndLastModifiedSync, NeverSync, MissingFileSync
from awscli.testutils import unittest, BaseAWSHelpOutputTest
Expand All @@ -34,6 +35,9 @@ class FakeArgs(object):
def __init__(self, **kwargs):
self.__dict__.update(kwargs)

def __contains__(self, key):
return key in self.__dict__


class TestGetEndpoint(unittest.TestCase):
def test_endpoint(self):
Expand All @@ -47,6 +51,28 @@ def test_endpoint(self):
self.assertTrue(endpoint.verify)


class TestRbCommand(unittest.TestCase):
def test_rb_command_with_force_deletes_objects_in_bucket(self):
self.session = mock.Mock()
self.session.get_scoped_config.return_value = {}
rb_command = RbCommand(self.session)
parsed_args = FakeArgs(paths='s3://mybucket/',
force=True,
dir_op=False)
parsed_globals = FakeArgs(region=None, endpoint_url=None,
verify_ssl=None)
cmd_name = 'awscli.customizations.s3.subcommands.RmCommand'
arch_name = 'awscli.customizations.s3.subcommands.CommandArchitecture'
with mock.patch(cmd_name) as rm_command:
with mock.patch(arch_name):
rb_command._run_main(parsed_args,
parsed_globals=parsed_globals)
# Because of --force we should have called the
# rm_command with the --recursive option.
rm_command.return_value.assert_called_with(
['s3://mybucket', '--recursive'], mock.ANY)


class TestLSCommand(unittest.TestCase):
def setUp(self):
self.session = mock.Mock()
Expand Down

0 comments on commit 31260e1

Please sign in to comment.