def test_deleteViewpointReference(self):
        """
        Tests the deletion of a viewpoint reference while preserving the
        underlying viewpoint object
        """

        srcFilePath = os.path.join(self.testFileDir, self.testFiles[0])
        testFile = setupBCFFile(srcFilePath, self.testFileDir,
                                self.testTopicDir, self.testBCFName)
        if pI.openProject(testFile) == pI.OperationResults.FAILURE:
            print("Could not open file")
            self.assertTrue(False)

        objectToDelete = pI.curProject.topicList[0].viewpoints[0]
        objectToDelete.state = s.State.States.DELETED
        pI.deleteObject(objectToDelete)
        newProject = pI.curProject

        vpList = newProject.topicList[0].viewpoints
        searchResult = newProject.searchObject(objectToDelete)
        vpFilePath = os.path.join(util.getSystemTmp(), self.testBCFName,
                                  self.testTopicDir, "viewpoint.bcfv")
        vpFileExists = os.path.exists(vpFilePath)

        self.assertTrue(
            len(vpList) == 0 and searchResult == None and vpFileExists)
    def test_deleteIfcProject(self):
        """
        Checks whether after deletion of the IfcProject attribute, the
        attribute holds the default value or not.
        """

        srcFilePath = os.path.join(self.testFileDir, self.testFiles[0])
        testFile = setupBCFFile(srcFilePath, self.testFileDir,
                                self.testTopicDir, self.testBCFName)
        if pI.openProject(testFile) == pI.OperationResults.FAILURE:
            print("Could not open file")
            self.assertTrue(False)

        objectToDelete = pI.curProject.topicList[0].header.files[
            1]._ifcProjectId
        objectToDelete.state = s.State.States.DELETED
        pI.deleteObject(objectToDelete)
        elementHierarchy = hierarchy.Hierarchy.checkAndGetHierarchy(
            objectToDelete)
        logger.debug("Hierarchy of element {}".format(elementHierarchy))

        newObject = pI.curProject.topicList[0].header.files[1]._ifcProjectId
        newObjectValue = newObject.value
        defaultValue = newObject.defaultValue
        self.assertTrue(newObjectValue == defaultValue)
    def test_deleteComment(self):

        srcFilePath = os.path.join(self.testFileDir, self.testFiles[0])
        testFile = setupBCFFile(srcFilePath, self.testFileDir,
                                self.testTopicDir, self.testBCFName)
        if pI.openProject(testFile) == pI.OperationResults.FAILURE:
            print("Could not open file")
            self.assertTrue(False)

        commentToDelete = pI.curProject.topicList[0].comments[0]
        pI.deleteObject(commentToDelete)

        self.assertTrue(len(pI.curProject.topicList[0].comments) == 0)
    def test_deleteCopiedComment(self):

        srcFilePath = os.path.join(self.testFileDir, self.testFiles[0])
        testFile = setupBCFFile(srcFilePath, self.testFileDir,
                                self.testTopicDir, self.testBCFName)
        if pI.openProject(testFile) == pI.OperationResults.FAILURE:
            print("Could not open file")
            self.assertTrue(False)

        logger.debug("Id of created project is {}".format(id(pI.curProject)))
        topics = [topic[1] for topic in pI.getTopics()]
        comments = [comment[1] for comment in pI.getComments(topics[0])]

        commentToDelete = comments[0]
        logger.debug("Id of the comment copy {}".format(id(commentToDelete)))
        pI.deleteObject(commentToDelete)

        self.assertTrue(len(pI.curProject.topicList[0].comments) == 0)
    def test_deleteLabel(self):
        """
        Tests the deletion of a Label
        """

        srcFilePath = os.path.join(self.testFileDir, self.testFiles[0])
        testFile = setupBCFFile(srcFilePath, self.testFileDir,
                                self.testTopicDir, self.testBCFName)
        if pI.openProject(testFile) == pI.OperationResults.FAILURE:
            print("Could not open file")
            self.assertTrue(False)

        objectToDelete = pI.curProject.topicList[0].topic.labels[0]
        objectToDelete.state = s.State.States.DELETED
        pI.deleteObject(objectToDelete)
        newProject = pI.curProject

        labelList = newProject.topicList[0].topic.labels
        searchResult = newProject.searchObject(objectToDelete)
        self.assertTrue(len(labelList) == 2 and searchResult == None)
    def test_deleteHeader(self):
        """
        Tests the deletion of the complete Header element
        """

        srcFilePath = os.path.join(self.testFileDir, self.testFiles[0])
        testFile = setupBCFFile(srcFilePath, self.testFileDir,
                                self.testTopicDir, self.testBCFName)
        if pI.openProject(testFile) == pI.OperationResults.FAILURE:
            print("Could not open file")
            self.assertTrue(False)

        objectToDelete = pI.curProject.topicList[0].header
        objectToDelete.state = s.State.States.DELETED
        pI.deleteObject(objectToDelete)

        newProject = pI.curProject
        searchResult = newProject.searchObject(objectToDelete)
        self.assertTrue(newProject.topicList[0].header == None
                        and searchResult == None)