Exemplo n.º 1
0
 def test_basic(self):
     sot = policy_type.PolicyType()
     self.assertEqual('policy_type', sot.resource_key)
     self.assertEqual('policy_types', sot.resources_key)
     self.assertEqual('/policy-types', sot.base_path)
     self.assertEqual('clustering', sot.service.service_type)
     self.assertTrue(sot.allow_get)
     self.assertTrue(sot.allow_list)
class TestPolicyTypeList(TestPolicyType):
    expected_columns = ['name']
    list_response = [
        sdk_policy_type.PolicyType({
            'name': 'BBB',
            'schema': {
                'foo': 'bar'
            }
        }),
        sdk_policy_type.PolicyType({
            'name': 'AAA',
            'schema': {
                'foo': 'bar'
            }
        }),
        sdk_policy_type.PolicyType({
            'name': 'CCC',
            'schema': {
                'foo': 'bar'
            }
        }),
    ]
    expected_rows = [['AAA'], ['BBB'], ['CCC']]

    def setUp(self):
        super(TestPolicyTypeList, self).setUp()
        self.cmd = osc_policy_type.PolicyTypeList(self.app, None)
        self.mock_client.policy_types = mock.Mock(
            return_value=self.list_response)

    def test_policy_type_list(self):
        arglist = []
        parsed_args = self.check_parser(self.cmd, arglist, [])
        columns, rows = self.cmd.take_action(parsed_args)

        self.mock_client.policy_types.assert_called_with()
        self.assertEqual(self.expected_columns, columns)
        self.assertEqual(self.expected_rows, rows)
 def setUp(self):
     super(TestPolicyTypeShow, self).setUp()
     self.cmd = osc_policy_type.PolicyTypeShow(self.app, None)
     self.mock_client.get_policy_type = mock.Mock(
         return_value=sdk_policy_type.PolicyType(self.response))
 def test_instantiate(self):
     sot = policy_type.PolicyType(FAKE)
     self.assertEqual(FAKE['name'], sot.id)
     self.assertEqual(FAKE['name'], sot.name)
     self.assertEqual(FAKE['schema'], sot.schema)