def test_addAssignedTo(self): """ Tests the addition of the AssignedTo node to a topic """ srcFilePath = os.path.join(self.testFileDir, self.testFiles[11]) testFile = setupBCFFile(srcFilePath, self.testFileDir, self.testTopicDir, self.testBCFName) p = reader.readBcfFile(testFile) t = p.topicList[0].topic t.assignee = "[email protected]" t._assignee.state = s.State.States.ADDED writer.addElement(t._assignee) (equal, diff) = compareFiles(self.checkFiles[11], self.testFileDir, self.testTopicDir, self.testBCFName) if not equal: wrongFileDestination = os.path.join(self.testFileDir, "error_files", "markup_add_assignedTo.bcf") copyfile(self.testFileDestinations[0], wrongFileDestination) project.debug("copied erroneous file to"\ " {}".format(wrongFileDestination)) project.debug("Following is the diff between the file that was generated"\ " and the prepared file:".format( wrongFileDestination)) pprint.pprint(diff) self.assertTrue(equal)
def test_addBimSnippetAttribute(self): """ Tests the addition of the optional attribute of BimSnippet """ srcFilePath = os.path.join(self.testFileDir, self.testFiles[9]) testFile = setupBCFFile(srcFilePath, self.testFileDir, self.testTopicDir, self.testBCFName) p = reader.readBcfFile(testFile) bimSnippet = p.topicList[0].topic.bimSnippet bimSnippet.external = True bimSnippet.state = s.State.States.ADDED writer.addElement(bimSnippet._external) (equal, diff) = compareFiles(self.checkFiles[9], self.testFileDir, self.testTopicDir, self.testBCFName) if not equal: wrongFileDestination = os.path.join(self.testFileDir, "error_files", "markup_add_bim_snippet.bcf") copyfile(self.testFileDestinations[0], wrongFileDestination) project.debug("copied erroneous file to"\ " {}".format(wrongFileDestination)) project.debug("Following is the diff between the file that was generated"\ " and the prepared file:".format( wrongFileDestination)) pprint.pprint(diff) self.assertTrue(equal)
def test_addLabel(self): """ Tests the addition of a label """ srcFilePath = os.path.join(self.testFileDir, self.testFiles[10]) testFile = setupBCFFile(srcFilePath, self.testFileDir, self.testTopicDir, self.testBCFName) p = reader.readBcfFile(testFile) t = p.topicList[0].topic newLabel = "Hello" t.labels.append(newLabel) writer.addElement(t.labels[-1]) (equal, diff) = compareFiles(self.checkFiles[10], self.testFileDir, self.testTopicDir, self.testBCFName) if not equal: wrongFileDestination = os.path.join(self.testFileDir, "error_files", "markup_add_label.bcf") copyfile(self.testFileDestinations[0], wrongFileDestination) project.debug("copied erroneous file to"\ " {}".format(wrongFileDestination)) project.debug("Following is the diff between the file that was generated"\ " and the prepared file:".format( wrongFileDestination)) pprint.pprint(diff) self.assertTrue(equal)
def test_addFileAttributes2(self): """ Tests the addition of the optional attributes to one of the file nodes """ srcFilePath = os.path.join(self.testFileDir, self.testFiles[7]) testFile = setupBCFFile(srcFilePath, self.testFileDir, self.testTopicDir, self.testBCFName) p = reader.readBcfFile(testFile) m = p.topicList[0] file = m.header.files[0] file.ifcSpatialStructureElement = "aaaabbbbcccc" file._ifcSpatialStructureElement.state = s.State.States.ADDED writer.addElement(file._ifcSpatialStructureElement) (equal, diff) = compareFiles(self.checkFiles[7], self.testFileDir, self.testTopicDir, self.testBCFName) if not equal: wrongFileDestination = os.path.join( self.testFileDir, "error_files", "markup_add_file_attribute2.bcf") copyfile(self.testFileDestinations[0], wrongFileDestination) project.debug("copied erroneous file to"\ " {}".format(wrongFileDestination)) project.debug("Following is the diff between the file that was generated"\ " and the prepared file:".format(wrongFileDestination)) pprint.pprint(diff) self.assertTrue(equal)
def test_addDocumentReferenceAttributes(self): """ Tests the addition of the optional attributes to one of the document reference nodes. """ srcFilePath = os.path.join(self.testFileDir, self.testFiles[8]) testFile = setupBCFFile(srcFilePath, self.testFileDir, self.testTopicDir, self.testBCFName) p = reader.readBcfFile(testFile) docRef = p.topicList[0].topic.docRefs[0] docRef.guid = "98b5802c-4ca0-4032-9128-b9c606955c4f" docRef._guid.state = s.State.States.ADDED writer.addElement(docRef._guid) (equal, diff) = compareFiles(self.checkFiles[8], self.testFileDir, self.testTopicDir, self.testBCFName) if not equal: wrongFileDestination = os.path.join( self.testFileDir, "error_files", "markup_add_doc_ref_attribute.bcf") copyfile(self.testFileDestinations[0], wrongFileDestination) project.debug("copied erroneous file to"\ " {}".format(wrongFileDestination)) project.debug("Following is the diff between the file that was generated"\ " and the prepared file:".format( wrongFileDestination)) pprint.pprint(diff) self.assertTrue(equal)
def test_addViewpointReference(self): """ Tests whether a viewpoint reference can be added without having a new viewpoint file created. """ srcFilePath = os.path.join(self.testFileDir, self.testFiles[2]) testFile = setupBCFFile(srcFilePath, self.testFileDir, self.testTopicDir, self.testBCFName) project = reader.readBcfFile(testFile) markup = project.topicList[0] prototypeViewpointRef = copy.deepcopy(markup.viewpoints[0]) prototypeViewpointRef.xmlId = "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" prototypeViewpointRef.viewpoint = None prototypeViewpointRef.state = s.State.States.ADDED prototypeViewpointRef.containingObject = markup markup.viewpoints.append(prototypeViewpointRef) writer.addElement(prototypeViewpointRef) (equal, diff) = compareFiles(self.checkFiles[2], self.testFileDir, self.testTopicDir, self.testBCFName) if not equal: wrongFileDestination = os.path.join( self.testFileDir, "error_files", "markup_add_lone_viewpoint.bcf") copyfile(self.testFileDestinations[0], wrongFileDestination) print("writer_tests.{}(): copied erroneous file to"\ " {}".format(self.test_add_file.__name__, wrongFileDestination)) print("writer_tests.{}(): Following is the diff between the file that was generated"\ " and the prepared file:".format( self.test_add_viewpointreference.__name__)) pprint.pprint(diff) self.assertTrue(equal)
def test_addCommentModification(self): """ Tests the addition of modification data to an existing comment """ srcFilePath = os.path.join(self.testFileDir, self.testFiles[1]) testFile = setupBCFFile(srcFilePath, self.testFileDir, self.testTopicDir, self.testBCFName) project = reader.readBcfFile(testFile) markup = project.topicList[0] comment = markup.comments[0] comment.modAuthor = "*****@*****.**" comment.modDate = dateutil.parser.parse("2014-10-16T13:10:56+00:00") writer.addElement(comment._modAuthor) writer.addElement(comment._modDate) (equal, diff) = compareFiles(self.checkFiles[1], self.testFileDir, self.testTopicDir, self.testBCFName) if not equal: wrongFileDestination = os.path.join( self.testFileDir, "error_files", "markup_add_comment_modification.bcf") copyfile(self.testFileDestinations[0], wrongFileDestination) print("writer_tests.{}(): copied erroneous file to"\ " {}".format(self.test_add_file.__name__, wrongFileDestination)) print("Following is the diff between the file that was generated"\ " and the prepared file:") pprint.pprint(diff) self.assertTrue(equal)
def test_addComment(self): """ Tests the addition of a comment. """ srcFilePath = os.path.join(self.testFileDir, self.testFiles[0]) testFile = setupBCFFile(srcFilePath, self.testFileDir, self.testTopicDir, self.testBCFName) project = reader.readBcfFile(testFile) markup = project.topicList[0] prototypeComment = copy.deepcopy(markup.comments[0]) prototypeComment.comment = "hello this is me mario!" prototypeComment.state = s.State.States.ADDED prototypeComment.containingObject = markup markup.comments.append(prototypeComment) writer.addElement(prototypeComment) (equal, diff) = compareFiles(self.checkFiles[0], self.testFileDir, self.testTopicDir, self.testBCFName) if not equal: wrongFileDestination = os.path.join(self.testFileDir, "error_files", "markup_add_comment.bcf") copyfile(self.testFileDestinations[0], wrongFileDestination) print("writer_tests.{}(): copied erroneous file to"\ " {}".format(self.test_add_file.__name__, wrongFileDestination)) print("Following is the diff between the file that was generated"\ " and the prepared file:") pprint.pprint(diff) self.assertTrue(equal)
def test_addMarkup(self): """ Tests the addition of a whole new markup object. This should result in the creation of a new folder as well as a new markup.bcf file and a new viewpoint file. """ srcFilePath = os.path.join(self.testFileDir, self.testFiles[0]) testFile = setupBCFFile(srcFilePath, self.testFileDir, self.testTopicDir, self.testBCFName) p = reader.readBcfFile(testFile) newMarkup = copy.deepcopy(p.topicList[0]) newMarkup.containingObject = p newMarkup.state = s.State.States.ADDED newMarkup.topic.xmlId = uuid4() # generate random uuid p.topicList.append(newMarkup) writer.addElement(newMarkup) folderPath = os.path.join(util.getSystemTmp(), self.testBCFName, str(newMarkup.topic.xmlId)) folderExists = os.path.exists(folderPath) if not folderExists: project.debug("Folder does not exist") markupFilePath = os.path.join(folderPath, "markup.bcf") markupFileExists = os.path.exists(markupFilePath) if not markupFileExists: project.debug("Markup file does not exist") self.assertTrue(markupFileExists and folderExists)
def test_projectCreation(self): srcFilePath = os.path.join(self.testFileDir, self.testFiles[0]) testFile = setupBCFFile(srcFilePath, self.testFileDir, self.testTopicDir, self.testBCFName) p = reader.readBcfFile(testFile) projectPath = os.path.join(util.getBcfDir(), writer.projectFileName) os.remove(projectPath) writer.addElement(p) self.assertTrue(os.path.exists(projectPath))
def test_addViewpoint(self): """ Tests the correct addition of a complete new viewpoint including a new viewpoint reference in markup """ srcFilePath = os.path.join(self.testFileDir, self.testFiles[3]) testFile = setupBCFFile(srcFilePath, self.testFileDir, self.testTopicDir, self.testBCFName) project = reader.readBcfFile(testFile) markup = project.topicList[0] prototypeViewpointRef = copy.deepcopy(markup.viewpoints[0]) prototypeViewpointRef.file = "viewpoint2.bcfv" prototypeViewpointRef.state = s.State.States.ADDED prototypeViewpointRef.viewpoint.state = s.State.States.ADDED prototypeViewpointRef.containingObject = markup markup.viewpoints.append(prototypeViewpointRef) writer.addElement(prototypeViewpointRef) (vpRefEqual, vpRefDiff) = compareFiles(self.checkFiles[3], self.testFileDir, self.testTopicDir, self.testBCFName) (vpEqual, vpDiff) = compareFiles(self.checkFiles[4], self.testFileDir, self.testTopicDir, self.testBCFName) if not vpRefEqual: wrongFileDestination = os.path.join( self.testFileDir, "error_files", "markup_add_full_viewpoint.bcf") copyfile(self.testFileDestinations[0], wrongFileDestination) print("writer_tests.{}(): copied erroneous file to"\ " {}".format(self.test_add_file.__name__, wrongFileDestination)) print("writer_tests.{}(): Following is the diff between the file that was generated"\ " and the prepared file:".format( self.test_add_viewpoint.__name__)) pprint.pprint(vpRefDiff) if not vpEqual: wrongFileDestination = os.path.join( self.testFileDir, "error_files", "viewpoint_add_full_viewpoint.bcfv") copyfile(self.testFileDestinations[2], wrongFileDestination) print("writer_tests.{}(): copied erroneous file to"\ " {}".format(self.test_add_file.__name__, wrongFileDestination)) print("writer_tests.{}(): Following is the diff between the file that was generated"\ " and the prepared file:".format( self.test_add_viewpoint.__name__)) pprint.pprint(vpDiff) self.assertTrue(vpRefEqual and vpEqual)
def test_addFile(self): """ Tests the addition of a file element in the header node """ srcFilePath = os.path.join(self.testFileDir, self.testFiles[5]) testFile = setupBCFFile(srcFilePath, self.testFileDir, self.testTopicDir, self.testBCFName) p = reader.readBcfFile(testFile) m = p.topicList[0] header = m.header newFile = markup.HeaderFile( ifcProjectId="abcdefghij", ifcSpatialStructureElement="klmnopqrs", isExternal=False, filename="this is some file name", time=dateutil.parser.parse("2014-10-16T13:10:56+00:00"), reference="/path/to/the/file", containingElement=header, state=s.State.States.ADDED) header.files.append(newFile) project.debug("type of newFile is" " {}".format(type(newFile))) writer.addElement(newFile) (equal, diff) = compareFiles(self.checkFiles[5], self.testFileDir, self.testTopicDir, self.testBCFName) if not equal: wrongFileDestination = os.path.join(self.testFileDir, "error_files", "markup_add_file.bcf") copyfile(self.testFileDestinations[0], wrongFileDestination) project.debug("copied erroneous file to"\ " {}".format(self.test_add_file.__name__, wrongFileDestination)) project.debug("Following is the diff between the file that was generated"\ " and the prepared file:".format( self.test_add_viewpointreference.__name__, wrongFileDestination)) pprint.pprint(diff) self.assertTrue(equal)