Esempio n. 1
0
    def test_register_policy_on_server(self):
        """Registers a policy on a server and creates a serverpolicy record."""
        def execute(*args, **kwargs):
            return defer.succeed(None)
        self.client.execute.side_effect = execute

        d = cass.register_policy_on_server(self.client, 'policy-abc', 'server-abc', 'alABCD', 'chABCD')

        self.successResultOf(d)

        calls = [
            mock.call(
                ('INSERT INTO serverpolicies ("serverId", "policyId", "alarmId", "checkId", state)'
                 ' VALUES (:serverId, :policyId, :alarmId, :checkId, false);'),
                {'policyId': 'policy-abc', 'serverId': 'server-abc',
                 'alarmId': 'alABCD', 'checkId': 'chABCD'}, 1),
        ]
        self.assertEqual(calls, self.client.execute.mock_calls)
Esempio n. 2
0
    def test_register_policy_on_server(self):
        """Registers a policy on a server and creates a serverpolicy record."""
        def execute(*args, **kwargs):
            return defer.succeed(None)

        self.client.execute.side_effect = execute

        d = cass.register_policy_on_server(self.client, 'policy-abc',
                                           'server-abc', 'alABCD', 'chABCD')

        self.successResultOf(d)

        calls = [
            mock.call(
                ('INSERT INTO serverpolicies ("serverId", "policyId", "alarmId", "checkId", state)'
                 ' VALUES (:serverId, :policyId, :alarmId, :checkId, false);'),
                {
                    'policyId': 'policy-abc',
                    'serverId': 'server-abc',
                    'alarmId': 'alABCD',
                    'checkId': 'chABCD'
                }, 1),
        ]
        self.assertEqual(calls, self.client.execute.mock_calls)
Esempio n. 3
0
 def register_policy((check_id, alarm_id)):
     return cass.register_policy_on_server(self._db, policy_id,
                                           server_id, alarm_id,
                                           check_id)
Esempio n. 4
0
 def register_policy((check_id, alarm_id)):
     return cass.register_policy_on_server(self._db, policy_id, server_id, alarm_id, check_id)