def test_get_boto3_with_args(self, mock_boto3): """ get_boto3 correctly passes the arguments to Boto3 contructor """ get_boto3(self.args, self.logger, self.stats) mock_boto3.assert_called_once_with( log_level=self.args.boto_log_level, access_key=self.args.boto_access_key, secret_key=self.args.boto_secret_key, region=self.args.boto_region, logger=self.logger, stats=self.stats, )
def test_get_boto3_with_args(self, mock_boto3): """ get_boto3() correctly passes the arguments to Boto3 contructor """ get_boto3(self.args, self.logger, self.stats) mock_boto3.assert_called_once_with( log_level=self.args.boto_log_level, access_key=self.args.boto_access_key, secret_key=self.args.boto_secret_key, region=self.args.boto_region, logger=self.logger, stats=self.stats, )
def __init__(self, name=NAME): # Call to the superclass to bootstrap. super(Application, self).__init__(name=name) self.boto = get_boto(self.args, self.logger, self.stats) self.boto3 = get_boto3(self.args, self.logger, self.stats)
def test_get_boto3_without_args(self, mock_get_stats, mock_get_logger, mock_boto3): """ get_boto3 correctly parses the CLI arguments and pass them to Boto3 contructor """ mock_get_stats.return_value = self.stats mock_get_logger.return_value = self.logger get_boto3() mock_boto3.assert_called_once_with( log_level=self.args.boto_log_level, access_key=self.args.boto_access_key, secret_key=self.args.boto_secret_key, region=self.args.boto_region, logger=self.logger, stats=self.stats, )
def test_get_boto3_without_args(self, mock_get_stats, mock_get_logger, mock_boto3): """ get_boto3() correctly parses the CLI arguments and pass them to Boto3 contructor """ mock_get_stats.return_value = self.stats mock_get_logger.return_value = self.logger get_boto3() mock_boto3.assert_called_once_with( log_level=self.args.boto_log_level, access_key=self.args.boto_access_key, secret_key=self.args.boto_secret_key, region=self.args.boto_region, logger=self.logger, stats=self.stats, )
def __init__(self, name=NAME, *args, **kwargs): self._VERSIONS[NAME] = self._VERSION # Call to the superclass to bootstrap. super(Application, self).__init__(name=name) self.boto = get_boto(self.args, self.logger, self.stats) self.boto3 = get_boto3(self.args, self.logger, self.stats)
def test_get_boto3_no_args(self, mock_boto3): """ get_boto3() correctly handles when CLI arguments are not present """ args = MagicMock(spec=['']) environ = { REGION: self.FAKE_REGION, ACCESS_KEY: self.FAKE_ACCESS_KEY, SECRET_KEY: self.FAKE_SECRET_KEY, } with patch.dict('krux_boto.boto.os.environ', environ): get_boto3(args=args, logger=self.logger, stats=self.stats) mock_boto3.assert_called_once_with( log_level=DEFAULT['log_level'](), access_key=self.FAKE_ACCESS_KEY, secret_key=self.FAKE_SECRET_KEY, region=self.FAKE_REGION, logger=self.logger, stats=self.stats, )
def __init__(self, name=NAME, *args, **kwargs): # Usually, a VERSION constant should be set in __init__.py and be imported. # However, krux-boto adds some basic classes to __init__.py and importing VERSION constant here # causes a dependency circle. Thus, set VERSION constant in version.json and import it. # path.dirname() gives current file's parent dir, calling twice would give us the correct path to version.json # under the root folder. _VERSION_PATH = path.join(path.dirname(path.dirname(__file__)), 'version.json') with open(_VERSION_PATH, 'r') as f: self._VERSION = json.load(f).get('VERSION') self._VERSIONS[NAME] = self._VERSION # Call to the superclass to bootstrap. super(Application, self).__init__(name=name) self.boto = get_boto(self.args, self.logger, self.stats) self.boto3 = get_boto3(self.args, self.logger, self.stats)