Esempio n. 1
0
    def test_format_resource_attributes_show_attribute(self):
        res = mock.Mock()
        res.attributes = {'a': 'a_value', 'show': {'b': 'b_value'}}

        formatted_attributes = api.format_resource_attributes(res)
        self.assertIn('b', formatted_attributes)
        self.assertNotIn('a', formatted_attributes)
 def test_format_resource_attributes(self):
     res = self.stack['generic1']
     # the _resolve_attribute method of  'generic1' returns map with all
     # attributes except 'show' (because it's None in this test)
     formatted_attributes = api.format_resource_attributes(res)
     expected = {'foo': 'generic1', 'Foo': 'generic1', 'show': None}
     self.assertEqual(expected, formatted_attributes)
Esempio n. 3
0
    def test_format_resource_attributes_show_attribute_fail(self):
        res = mock.Mock()
        res.attributes = {'a': 'a_value', 'show': ''}

        formatted_attributes = api.format_resource_attributes(res)
        self.assertIn('a', formatted_attributes)
        self.assertIn('show', formatted_attributes)
Esempio n. 4
0
    def test_format_resource_attributes_show_attribute_fail(self):
        res = mock.Mock()
        res.attributes = {'a': 'a_value', 'show': ''}

        formatted_attributes = api.format_resource_attributes(res)
        self.assertIn('a', formatted_attributes)
        self.assertIn('show', formatted_attributes)
Esempio n. 5
0
 def test_format_resource_attributes_show_attribute(self):
     res = self.stack['generic3']
     formatted_attributes = api.format_resource_attributes(res)
     self.assertEqual(3, len(formatted_attributes))
     self.assertIn('foo', formatted_attributes)
     self.assertIn('Foo', formatted_attributes)
     self.assertIn('Another', formatted_attributes)
Esempio n. 6
0
    def test_format_resource_attributes_show_attribute(self):
        res = mock.Mock()
        res.attributes = {'a': 'a_value', 'show': {'b': 'b_value'}}

        formatted_attributes = api.format_resource_attributes(res)
        self.assertIn('b', formatted_attributes)
        self.assertNotIn('a', formatted_attributes)
Esempio n. 7
0
 def test_format_resource_attributes(self):
     res = self.stack['generic1']
     formatted_attributes = api.format_resource_attributes(res)
     self.assertEqual(3, len(formatted_attributes))
     self.assertIn('foo', formatted_attributes)
     self.assertIn('Foo', formatted_attributes)
     self.assertIn('show', formatted_attributes)
 def test_format_resource_attributes_show_attribute(self):
     res = self.stack['generic3']
     res.resource_id = 'generic3_id'
     formatted_attributes = api.format_resource_attributes(res)
     self.assertEqual(3, len(formatted_attributes['show']))
     self.assertIn('foo', formatted_attributes['show'])
     self.assertIn('Foo', formatted_attributes['show'])
     self.assertIn('Another', formatted_attributes['show'])
 def test_format_resource_attributes_show_attribute_with_attr(self):
     res = self.stack['generic3']
     formatted_attributes = api.format_resource_attributes(
         res, with_attr=['c'])
     self.assertEqual(4, len(formatted_attributes))
     self.assertIn('foo', formatted_attributes)
     self.assertIn('Foo', formatted_attributes)
     self.assertIn('Another', formatted_attributes)
     self.assertIn('c', formatted_attributes)
Esempio n. 10
0
    def test_format_resource_attributes_force_attributes(self):
        res = self.stack['generic1']
        force_attrs = ['a1', 'a2']

        formatted_attributes = api.format_resource_attributes(res, force_attrs)
        self.assertEqual(4, len(formatted_attributes))
        self.assertIn('foo', formatted_attributes)
        self.assertIn('Foo', formatted_attributes)
        self.assertIn('a1', formatted_attributes)
        self.assertIn('a2', formatted_attributes)
Esempio n. 11
0
    def test_format_resource_attributes_force_attributes(self):
        res = self.stack['generic1']
        force_attrs = ['a1', 'a2']

        formatted_attributes = api.format_resource_attributes(res, force_attrs)
        self.assertEqual(4, len(formatted_attributes))
        self.assertIn('foo', formatted_attributes)
        self.assertIn('Foo', formatted_attributes)
        self.assertIn('a1', formatted_attributes)
        self.assertIn('a2', formatted_attributes)
Esempio n. 12
0
 def test_format_resource_attributes_show_attribute_with_attr(self):
     res = self.stack['generic3']
     res.resource_id = 'generic3_id'
     formatted_attributes = api.format_resource_attributes(res,
                                                           with_attr=['c'])
     self.assertEqual(4, len(formatted_attributes))
     self.assertIn('foo', formatted_attributes)
     self.assertIn('Foo', formatted_attributes)
     self.assertIn('Another', formatted_attributes)
     self.assertIn('c', formatted_attributes)
Esempio n. 13
0
 def test_format_resource_attributes(self):
     res = self.stack['generic1']
     # the _resolve_attribute method of  'generic1' return res.name
     formatted_attributes = api.format_resource_attributes(res)
     self.assertEqual(res.name, formatted_attributes)
 def test_format_resource_attributes(self):
     res = self.stack['generic1']
     # the _resolve_attribute method of  'generic1' return res.name
     formatted_attributes = api.format_resource_attributes(res)
     self.assertEqual(res.name, formatted_attributes)