Esempio n. 1
0
    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))
Esempio n. 2
0
    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))
Esempio n. 3
0
    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))
Esempio n. 4
0
    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))
Esempio n. 5
0
    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)
Esempio n. 6
0
    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)