Esempio n. 1
0
    def test_init_assigns_basic_values(self, mock_boto3):
        input_attrs = dict(INPUT_ATTRS, **{'aws_region': 'eu-west-1'})
        aws_base_scaler = AwsBaseScaler(**input_attrs)

        assert aws_base_scaler.min_instances == input_attrs['min_instances']
        assert aws_base_scaler.max_instances == input_attrs['max_instances']
        assert aws_base_scaler.threshold == input_attrs['threshold']
Esempio n. 2
0
    def test_init_assigns_basic_values(self, mock_boto3):
        input_attrs = {'aws_region': 'eu-west-1'}
        aws_base_scaler = AwsBaseScaler(app_name, min_instances, max_instances, **input_attrs)

        assert aws_base_scaler.app_name == app_name
        assert aws_base_scaler.min_instances == min_instances
        assert aws_base_scaler.max_instances == max_instances
Esempio n. 3
0
    def test_aws_account_id_from_boto_client(self, mock_boto3):
        mock_client = mock_boto3.client
        mock_client.return_value.get_caller_identity.return_value = {'Account': 123456}

        aws_base_scaler = AwsBaseScaler(app_name, min_instances, max_instances)
        assert aws_base_scaler.aws_region == 'eu-west-1'
        assert aws_base_scaler.aws_account_id == 123456
        mock_client.assert_called_with('sts', region_name='eu-west-1')
Esempio n. 4
0
 def test_aws_credentials_default_value(self, mock_boto3):
     aws_base_scaler = AwsBaseScaler(**INPUT_ATTRS)
     assert aws_base_scaler.aws_region == 'eu-west-1'
Esempio n. 5
0
 def test_aws_credentials_from_env_var(self, mock_boto3):
     with patch.dict(os.environ, {'AWS_REGION': 'us-west-1'}):
         aws_base_scaler = AwsBaseScaler(**INPUT_ATTRS)
         assert aws_base_scaler.aws_region == 'us-west-1'
Esempio n. 6
0
    def test_aws_credentials_from_attributes(self, mock_boto3):
        input_attrs = dict(INPUT_ATTRS, **{'aws_region': 'eu-west-1'})
        aws_base_scaler = AwsBaseScaler(**input_attrs)

        assert aws_base_scaler.aws_region == input_attrs['aws_region']
Esempio n. 7
0
 def test_aws_credentials_default_value(self, mock_boto3):
     aws_base_scaler = AwsBaseScaler(app_name, min_instances, max_instances)
     assert aws_base_scaler.aws_region == 'eu-west-1'
Esempio n. 8
0
 def test_aws_credentials_from_env_var(self, mock_boto3):
     with patch.dict(os.environ, {'AWS_REGION': 'us-west-1'}):
         aws_base_scaler = AwsBaseScaler(app_name, min_instances, max_instances)
         assert aws_base_scaler.aws_region == 'us-west-1'
Esempio n. 9
0
    def test_aws_credentials_from_attributes(self, mock_boto3):
        input_attrs = {'aws_region': 'eu-west-1'}
        aws_base_scaler = AwsBaseScaler(app_name, min_instances, max_instances, **input_attrs)

        assert aws_base_scaler.aws_region == input_attrs['aws_region']