コード例 #1
0
ファイル: test_cass.py プロジェクト: rackerlabs/bobby
    def test_get_policy_by_policy_id_integrity_problems(self):
        """Raises an error if more than one policy is found."""
        self.client.execute.return_value = defer.succeed(['policy-abc', 'policy-def'])

        d = cass.get_policy_by_policy_id(self.client, '101010', 'policy-abc')

        result = self.failureResultOf(d)
        self.assertTrue(result.check(cass.ExcessiveResultsError))
コード例 #2
0
ファイル: test_cass.py プロジェクト: rackerlabs/bobby
    def test_get_policy_by_policy_id_not_found(self):
        """Raises an error if no policy is found."""
        self.client.execute.return_value = defer.succeed([])

        d = cass.get_policy_by_policy_id(self.client, '101010', 'policy-abc')

        result = self.failureResultOf(d)
        self.assertTrue(result.check(cass.ResultNotFoundError))
コード例 #3
0
ファイル: test_cass.py プロジェクト: rackerlabs/bobby
    def test_get_policy_by_policy_id_not_found(self):
        """Raises an error if no policy is found."""
        self.client.execute.return_value = defer.succeed([])

        d = cass.get_policy_by_policy_id(self.client, '101010', 'policy-abc')

        result = self.failureResultOf(d)
        self.assertTrue(result.check(cass.ResultNotFoundError))
コード例 #4
0
ファイル: test_cass.py プロジェクト: rackerlabs/bobby
    def test_get_policy_by_policy_id_integrity_problems(self):
        """Raises an error if more than one policy is found."""
        self.client.execute.return_value = defer.succeed(
            ['policy-abc', 'policy-def'])

        d = cass.get_policy_by_policy_id(self.client, '101010', 'policy-abc')

        result = self.failureResultOf(d)
        self.assertTrue(result.check(cass.ExcessiveResultsError))
コード例 #5
0
ファイル: test_cass.py プロジェクト: rackerlabs/bobby
    def test_get_policy_by_policy_id(self):
        """Return a single policy dict, rather than a single item list."""
        expected = {'policyId': 'policy-abc',
                    'groupId': 'group-def',
                    'alarmTemplate': 'alarmTemplate-ghi',
                    'checkTemplate': 'checkTemplate-jkl'}
        self.client.execute.return_value = defer.succeed([expected])

        d = cass.get_policy_by_policy_id(self.client, '101010', 'policy-abc')

        result = self.successResultOf(d)
        self.assertEqual(result, expected)
        self.client.execute.assert_called_once_with(
            'SELECT * FROM policies WHERE "policyId"=:policyId AND "groupId"=:groupId;',
            {'policyId': 'policy-abc', 'groupId': '101010'},
            1)
コード例 #6
0
ファイル: test_cass.py プロジェクト: rackerlabs/bobby
    def test_get_policy_by_policy_id(self):
        """Return a single policy dict, rather than a single item list."""
        expected = {
            'policyId': 'policy-abc',
            'groupId': 'group-def',
            'alarmTemplate': 'alarmTemplate-ghi',
            'checkTemplate': 'checkTemplate-jkl'
        }
        self.client.execute.return_value = defer.succeed([expected])

        d = cass.get_policy_by_policy_id(self.client, '101010', 'policy-abc')

        result = self.successResultOf(d)
        self.assertEqual(result, expected)
        self.client.execute.assert_called_once_with(
            'SELECT * FROM policies WHERE "policyId"=:policyId AND "groupId"=:groupId;',
            {
                'policyId': 'policy-abc',
                'groupId': '101010'
            }, 1)