示例#1
0
    def test_that_when_checking_if_a_policy_exists_and_boto3_returns_an_error_the_policy_exists_method_returns_error(self):
        '''
        Tests checking iot policy existence when boto returns an error
        '''
        self.conn.get_policy.side_effect = ClientError(error_content, 'get_policy')
        result = boto_iot.policy_exists(policyName='mypolicy', **conn_parameters)

        self.assertEqual(result.get('error', {}).get('message'), error_message.format('get_policy'))
示例#2
0
    def test_that_when_checking_if_a_policy_exists_and_a_policy_exists_the_policy_exists_method_returns_true(self):
        '''
        Tests checking iot policy existence when the iot policy already exists
        '''
        self.conn.get_policy.return_value = {'policy': policy_ret}
        result = boto_iot.policy_exists(policyName=policy_ret['policyName'], **conn_parameters)

        self.assertTrue(result['exists'])
示例#3
0
    def test_that_when_checking_if_a_policy_exists_and_a_policy_does_not_exist_the_policy_exists_method_returns_false(self):
        '''
        Tests checking iot policy existence when the iot policy does not exist
        '''
        self.conn.get_policy.side_effect = not_found_error
        result = boto_iot.policy_exists(policyName='mypolicy', **conn_parameters)

        self.assertFalse(result['exists'])
示例#4
0
    def test_that_when_checking_if_a_policy_exists_and_boto3_returns_an_error_the_policy_exists_method_returns_error(self):
        '''
        Tests checking iot policy existence when boto returns an error
        '''
        self.conn.get_policy.side_effect = ClientError(error_content, 'get_policy')
        result = boto_iot.policy_exists(policyName='mypolicy', **conn_parameters)

        self.assertEqual(result.get('error', {}).get('message'), error_message.format('get_policy'))
示例#5
0
    def test_that_when_checking_if_a_policy_exists_and_a_policy_does_not_exist_the_policy_exists_method_returns_false(self):
        '''
        Tests checking iot policy existence when the iot policy does not exist
        '''
        self.conn.get_policy.side_effect = not_found_error
        result = boto_iot.policy_exists(policyName='mypolicy', **conn_parameters)

        self.assertFalse(result['exists'])
示例#6
0
    def test_that_when_checking_if_a_policy_exists_and_a_policy_exists_the_policy_exists_method_returns_true(self):
        '''
        Tests checking iot policy existence when the iot policy already exists
        '''
        self.conn.get_policy.return_value = {'policy': policy_ret}
        result = boto_iot.policy_exists(policyName=policy_ret['policyName'], **conn_parameters)

        self.assertTrue(result['exists'])
    def test_that_when_checking_if_a_policy_exists_and_boto3_returns_an_error_the_policy_exists_method_returns_error(
        self,
    ):
        """
        Tests checking iot policy existence when boto returns an error
        """
        self.conn.get_policy.side_effect = ClientError(error_content, "get_policy")
        result = boto_iot.policy_exists(policyName="mypolicy", **conn_parameters)

        assert result.get("error", {}).get("message") == error_message.format("get_policy")
    def test_that_when_checking_if_a_policy_exists_and_a_policy_does_not_exist_the_policy_exists_method_returns_false(
        self,
    ):
        """
        Tests checking iot policy existence when the iot policy does not exist
        """
        self.conn.get_policy.side_effect = not_found_error
        result = boto_iot.policy_exists(policyName="mypolicy", **conn_parameters)

        assert not result["exists"]
    def test_that_when_checking_if_a_policy_exists_and_a_policy_exists_the_policy_exists_method_returns_true(
        self,
    ):
        """
        Tests checking iot policy existence when the iot policy already exists
        """
        self.conn.get_policy.return_value = {"policy": policy_ret}
        result = boto_iot.policy_exists(policyName=policy_ret["policyName"], **conn_parameters)

        assert result["exists"]
示例#10
0
def test_that_when_checking_if_a_policy_exists_and_boto3_returns_an_error_the_policy_exists_method_returns_error(
        boto_conn):
    '''
    Tests checking iot policy existence when boto returns an error
    '''
    boto_conn.get_policy.side_effect = exceptions.ClientError(
        error_content, 'get_policy')
    result = boto_iot.policy_exists(policyName='mypolicy',
                                    **pytest.conn_parameters)

    assert result.get('error',
                      {}).get('message') == error_message.format('get_policy')