def test_deleteViewpoint(self): """ Tests whether the referenced viewpoint file gets deleted if the viewpoint reference is deleted AND the state of viewpoint is also DELETED. """ srcFilePath = os.path.join(self.testFileDir, self.testFiles[4]) testFile = setupBCFFile(srcFilePath, self.testFileDir, self.testTopicDir, self.testBCFName) p = reader.readBcfFile(testFile) vpRefToDelete = p.topicList[0].viewpoints[0] vpRefToDelete.state = s.State.States.DELETED vpRefToDelete.viewpoint.state = s.State.States.DELETED writer.deleteElement(vpRefToDelete) vpFilePath = os.path.join(util.getSystemTmp(), self.testBCFName, self.testTopicDir, "viewpoint.bcfv") stillExists = os.path.exists(vpFilePath) equal = handleFileCheck(self.checkFiles[4], "markup.bcf", self.testFileDir, self.testTopicDir, self.testBCFName) if not equal or stillExists: printVimDiffCommand(self.testFileDir, self.checkFiles[4]) self.assertTrue((not stillExists) and equal, "Failed to delete the "\ "viewpoint and the accompanying file"\ " {}".format(vpRefToDelete.viewpoint))
def test_deleteComment(self): srcFilePath = os.path.join(self.testFileDir, self.testFiles[0]) testFile = setupBCFFile(srcFilePath, self.testFileDir, self.testTopicDir, self.testBCFName) p = reader.readBcfFile(testFile) commentToDelete = p.topicList[0].comments[0] commentToDelete.state = s.State.States.DELETED writer.deleteElement(commentToDelete) equal = handleFileCheck(self.checkFiles[0], "markup.bcf", self.testFileDir, self.testTopicDir, self.testBCFName) if not equal: printVimDiffCommand(self.testFileDir, self.checkFiles[0]) self.assertTrue(equal, "Failed to delete comment" \ " {}".format(commentToDelete))
def test_deleteIfcProject(self): srcFilePath = os.path.join(self.testFileDir, self.testFiles[2]) testFile = setupBCFFile(srcFilePath, self.testFileDir, self.testTopicDir, self.testBCFName) p = reader.readBcfFile(testFile) fileToDeleteFrom = p.topicList[0].header.files[0] ifcProject = fileToDeleteFrom._ifcProjectId ifcProject.state = s.State.States.DELETED writer.deleteElement(ifcProject) equal = handleFileCheck(self.checkFiles[2], "markup.bcf", self.testFileDir, self.testTopicDir, self.testBCFName) if not equal: printVimDiffCommand(self.testFileDir, self.checkFiles[2]) self.assertTrue(equal, "Failed to delete ifcProject attribute"\ " {}".format(ifcProject))
def test_deleteFile(self): """ Tests the deletion of a File node inside a Header. """ srcFilePath = os.path.join(self.testFileDir, self.testFiles[3]) testFile = setupBCFFile(srcFilePath, self.testFileDir, self.testTopicDir, self.testBCFName) p = reader.readBcfFile(testFile) fileToDelete = p.topicList[0].header.files[1] fileToDelete.state = s.State.States.DELETED writer.deleteElement(fileToDelete) equal = handleFileCheck(self.checkFiles[3], "markup.bcf", self.testFileDir, self.testTopicDir, self.testBCFName) if not equal: printVimDiffCommand(self.testFileDir, self.checkFiles[3]) self.assertTrue(equal, "Failed to delete file {}".format(fileToDelete))
def test_deleteViewpointReference(self): """ Tests whether the first in the file testfiles[5] viewpoint reference can be deleted. """ srcFilePath = os.path.join(self.testFileDir, self.testFiles[5]) testFile = setupBCFFile(srcFilePath, self.testFileDir, self.testTopicDir, self.testBCFName) p = reader.readBcfFile(testFile) vpRefToDelete = p.topicList[0].viewpoints[0] vpRefToDelete.state = s.State.States.DELETED writer.deleteElement(vpRefToDelete) equal = handleFileCheck(self.checkFiles[5], "markup.bcf", self.testFileDir, self.testTopicDir, self.testBCFName) if not equal: printVimDiffCommand(self.testFileDir, self.checkFiles[5]) self.assertTrue(equal, "Failed to delete viewpoint Reference"\ " {}".format(vpRefToDelete))
def test_deleteLabel(self): """ Tests the deletion of the label <Label>mechanical</Label> from topic 2e.... """ srcFilePath = os.path.join(self.testFileDir, self.testFiles[1]) testFile = setupBCFFile(srcFilePath, self.testFileDir, self.testTopicDir, self.testBCFName) p = reader.readBcfFile(testFile) labelToDelete = p.topicList[0].topic.labels[2] labelToDelete.state = s.State.States.DELETED writer.deleteElement(labelToDelete) equal = handleFileCheck(self.checkFiles[1], "markup.bcf", self.testFileDir, self.testTopicDir, self.testBCFName) if not equal: printVimDiffCommand(self.testFileDir, self.checkFiles[1]) self.assertTrue(equal, "Failed to delete label {}".format(labelToDelete))