Example #1
0
    def test_delete_typeattr(self, client, mock_template):

        template = mock_template

        attr_1 = client.testutils.create_attribute("link_attr_1",
                                                   dimension='Pressure')
        attr_2 = client.testutils.create_attribute("link_attr_2",
                                                   dimension='Speed')

        templatetype = JSONObject()
        templatetype.name = "Test type name @ %s" % (datetime.datetime.now())
        templatetype.alias = templatetype.name + " alias"
        templatetype.resource_type = 'NODE'
        templatetype.template_id = template.id

        tattr_1 = JSONObject()
        tattr_1.attr_id = attr_1.id

        tattr_2 = JSONObject()
        tattr_2.attr_id = attr_2.id

        templatetype.typeattrs = [tattr_1, tattr_2]

        new_type = JSONObject(client.add_templatetype(templatetype))

        tattr_2.type_id = new_type.id

        client.delete_typeattr(tattr_2)

        updated_type = JSONObject(client.get_templatetype(new_type.id))

        assert len(updated_type.typeattrs
                   ) == 1, "Resource type attr did not add correctly"
Example #2
0
    def test_delete_typeattr(self):

        template = self.test_add_template()

        attr_1 = self.create_attr("link_attr_1", dimension='Pressure')
        attr_2 = self.create_attr("link_attr_2", dimension='Speed')

        templatetype = JSONObject()
        templatetype.name = "Test type name @ %s" % (datetime.datetime.now())
        templatetype.alias = templatetype.name + " alias"
        templatetype.resource_type = 'NODE'
        templatetype.template_id = template.id

        tattr_1 = JSONObject()
        tattr_1.attr_id = attr_1.id

        tattr_2 = JSONObject()
        tattr_2.attr_id = attr_2.id

        templatetype.typeattrs = [tattr_1, tattr_2]

        new_type = JSONObject(add_templatetype(templatetype))

        tattr_2.type_id = new_type.id

        delete_typeattr(tattr_2)

        updated_type = JSONObject(get_templatetype(new_type.id))

        log.info(len(updated_type.typeattrs))

        assert len(updated_type.typeattrs
                   ) == 1, "Resource type attr did not add correctly"
Example #3
0
    def test_add_typeattr(self, client, mock_template):

        attr_1 = client.testutils.create_attribute("link_attr_1",
                                                   dimension='Pressure')
        attr_2 = client.testutils.create_attribute("link_attr_2",
                                                   dimension='Speed')
        attr_3 = client.testutils.create_attribute("node_attr_1",
                                                   dimension='Volume')

        templatetype = JSONObject()
        templatetype.name = "Test type name @ %s" % (datetime.datetime.now())
        templatetype.alias = templatetype.name + " alias"
        templatetype.template_id = mock_template.id
        templatetype.resource_type = 'NODE'

        tattr_1 = JSONObject()
        tattr_1.attr_id = attr_1.id

        tattr_2 = JSONObject()
        tattr_2.attr_id = attr_2.id
        tattr_2.description = "Description of typeattr from test_add_typeattr"
        tattr_2.properties = {"test_property": "property value"}

        templatetype.typeattrs = [tattr_1, tattr_2]

        new_type = JSONObject(client.add_templatetype(templatetype))

        tattr_3 = JSONObject()
        tattr_3.attr_id = attr_3.id
        tattr_3.type_id = new_type.id
        tattr_3.description = "Description of additional typeattr from test_add_typeattr"
        tattr_3.properties = {"add_typeattr_test_property": "property value"}

        log.info("Adding Test Type attribute")

        client.add_typeattr(tattr_3)

        updated_type = JSONObject(client.get_templatetype(new_type.id))

        assert len(
            updated_type.typeattrs) == 3, "Type attr did not add correctly"

        assert eval(updated_type.typeattrs[-1].properties
                    )['add_typeattr_test_property'] == "property value"