def setUp(self): super(TestPolicy, self).setUp() self.sess = mock.Mock(spec=adapter.Adapter) self.sess.get = mock.Mock() self.sess.post = mock.Mock() self.sess.list = mock.Mock() self.sess.delete = mock.Mock() self.sess.put = mock.Mock() self.sess.default_microversion = '1' self.sess._get_connection = mock.Mock(return_value=self.cloud) self.sot = _policy.Policy() self.sot_expected = _policy.Policy(**EXAMPLE)
def test_delete(self): arglist = ['p1'] verifylist = [('policy', 'p1')] # Verify cm is triggereg with default parameters parsed_args = self.check_parser(self.cmd, arglist, verifylist) # Set the response self.client.delete_policy.side_effect = [{}] # Set the response for find_policy self.client.find_policy.side_effect = [policySDK.Policy(id='p1')] # Trigger the action self.cmd.take_action(parsed_args) delete_calls = [ mock.call(policy='p1', ignore_missing=False), ] find_calls = [ mock.call(name_or_id='p1', ignore_missing=False), ] self.client.delete_policy.assert_has_calls(delete_calls) self.client.find_policy.assert_has_calls(find_calls) self.assertEqual(1, self.client.delete_policy.call_count)
def test_unbind_policy(self): vault = _vault.Vault(id='vault') policy = _policy.Policy(id='policy') self._verify('otcextensions.sdk.cbr.v3.vault.Vault.unbind_policy', self.proxy.unbind_policy, method_args=[vault, policy], expected_args=[self.proxy], expected_kwargs={'policy_id': 'policy'})
def test_basic(self): sot = _policy.Policy() self.assertEqual('policy', sot.resource_key) self.assertEqual('policies', sot.resources_key) self.assertEqual('/policies', sot.base_path) self.assertTrue(sot.allow_list) self.assertTrue(sot.allow_create) self.assertTrue(sot.allow_fetch) self.assertTrue(sot.allow_commit) self.assertTrue(sot.allow_delete)
def test_make_it(self): test_policy = _policy.Policy(**EXAMPLE) self.assertTrue(test_policy.enabled) self.assertEqual(EXAMPLE['name'], test_policy.name) self.assertEqual(EXAMPLE['operation_type'], test_policy.operation_type) self.assertEqual(EXAMPLE['operation_definition']['day_backups'], test_policy.operation_definition.day_backups) self.assertEqual(EXAMPLE['operation_definition']['month_backups'], test_policy.operation_definition.month_backups) self.assertEqual(EXAMPLE['operation_definition']['max_backups'], test_policy.operation_definition.max_backups) self.assertEqual(EXAMPLE['operation_definition']['timezone'], test_policy.operation_definition.timezone) self.assertEqual(EXAMPLE['operation_definition']['week_backups'], test_policy.operation_definition.week_backups) self.assertEqual(EXAMPLE['operation_definition']['year_backups'], test_policy.operation_definition.year_backups) self.assertEqual(EXAMPLE['trigger']['properties']['pattern'][0], test_policy.trigger.properties.pattern[0])