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)
return os.path.join(testFileDir, testBCFName) def test_letLinesDraw(): topics = [topic[1] for topic in pI.getTopics()] viewpoints = [vp[1] for vp in pI.getViewpoints(topics[0])] vC.createLines(viewpoints[0].lines) def test_addClipPlanes(): topics = [topic[1] for topic in pI.getTopics()] viewpoints = [vp[1] for vp in pI.getViewpoints(topics[0])] clippingPlanes = viewpoints[0].clippingPlanes clip = clippingPlanes[0] vC.createClippingPlane(clip) #if __name__ == "__main__": testFileDir = "viewController-tests" testBCFFile = "bcfexmple_bernd.bcf" setupBCFFile("viewpoint_with_lines.bcfv", "viewController-tests", "d7301aa6-3533-4031-b209-9e1c701802f5", "bcfexmple_bernd.bcf") pI.openProject("./{}/{}".format(testFileDir, testBCFFile)) test_letLinesDraw() test_addClipPlanes()