1# @file TestSBase.rb 2# @brief SBase unit tests 3# 4# @author Akiya Jouraku (Ruby conversion) 5# @author Ben Bornstein 6# 7# 8# ====== WARNING ===== WARNING ===== WARNING ===== WARNING ===== WARNING ====== 9# 10# DO NOT EDIT THIS FILE. 11# 12# This file was generated automatically by converting the file located at 13# src/sbml/test/TestSBase.cpp 14# using the conversion program dev/utilities/translateTests/translateTests.pl. 15# Any changes made here will be lost the next time the file is regenerated. 16# 17# ----------------------------------------------------------------------------- 18# This file is part of libSBML. Please visit http://sbml.org for more 19# information about SBML, and the latest version of libSBML. 20# 21# Copyright 2005-2010 California Institute of Technology. 22# Copyright 2002-2005 California Institute of Technology and 23# Japan Science and Technology Corporation. 24# 25# This library is free software; you can redistribute it and/or modify it 26# under the terms of the GNU Lesser General Public License as published by 27# the Free Software Foundation. A copy of the license agreement is provided 28# in the file named "LICENSE.txt" included with this software distribution 29# and also available online as http://sbml.org/software/libsbml/license.html 30# ----------------------------------------------------------------------------- 31require 'test/unit' 32require 'libSBML' 33 34class TestSBase < Test::Unit::TestCase 35 36 def setup 37 @@s = LibSBML::Model.new(2,4) 38 if (@@s == nil) 39 end 40 end 41 42 def teardown 43 @@s = nil 44 end 45 46 def test_SBase_CVTerms 47 cv = LibSBML::CVTerm.new(LibSBML::BIOLOGICAL_QUALIFIER) 48 cv.setBiologicalQualifierType(LibSBML::BQB_IS) 49 cv.addResource( "foo") 50 assert( @@s.getNumCVTerms() == 0 ) 51 assert( @@s.getCVTerms() == nil ) 52 @@s.setMetaId( "_id") 53 @@s.addCVTerm(cv) 54 assert( @@s.getNumCVTerms() == 1 ) 55 assert( @@s.getCVTerms() != nil ) 56 assert( @@s.getCVTerm(0) != cv ) 57 cv = nil 58 end 59 60 def test_SBase_addCVTerms 61 cv = LibSBML::CVTerm.new(LibSBML::BIOLOGICAL_QUALIFIER) 62 cv.setBiologicalQualifierType(LibSBML::BQB_ENCODES) 63 cv.addResource( "foo") 64 @@s.setMetaId( "sbase1") 65 @@s.addCVTerm(cv) 66 assert( @@s.getNumCVTerms() == 1 ) 67 assert( @@s.getCVTerms() != nil ) 68 res = @@s.getCVTerm(0).getResources() 69 assert (( "foo" == res.getValue(0) )) 70 cv1 = LibSBML::CVTerm.new(LibSBML::BIOLOGICAL_QUALIFIER) 71 cv1.setBiologicalQualifierType(LibSBML::BQB_IS) 72 cv1.addResource( "bar") 73 @@s.addCVTerm(cv1) 74 assert( @@s.getNumCVTerms() == 2 ) 75 cv2 = LibSBML::CVTerm.new(LibSBML::BIOLOGICAL_QUALIFIER) 76 cv2.setBiologicalQualifierType(LibSBML::BQB_IS) 77 cv2.addResource( "bar1") 78 @@s.addCVTerm(cv2) 79 assert( @@s.getNumCVTerms() == 2 ) 80 res = @@s.getCVTerm(1).getResources() 81 assert( res.getLength() == 2 ) 82 assert (( "bar" == res.getValue(0) )) 83 assert (( "bar1" == res.getValue(1) )) 84 cv4 = LibSBML::CVTerm.new(LibSBML::BIOLOGICAL_QUALIFIER) 85 cv4.setBiologicalQualifierType(LibSBML::BQB_IS) 86 cv4.addResource( "bar1") 87 @@s.addCVTerm(cv4) 88 assert( @@s.getNumCVTerms() == 2 ) 89 res = @@s.getCVTerm(1).getResources() 90 assert( res.getLength() == 2 ) 91 assert (( "bar" == res.getValue(0) )) 92 assert (( "bar1" == res.getValue(1) )) 93 cv5 = LibSBML::CVTerm.new(LibSBML::BIOLOGICAL_QUALIFIER) 94 cv5.setBiologicalQualifierType(LibSBML::BQB_HAS_PART) 95 cv5.addResource( "bar1") 96 @@s.addCVTerm(cv5) 97 assert( @@s.getNumCVTerms() == 2 ) 98 res = @@s.getCVTerm(1).getResources() 99 assert( res.getLength() == 2 ) 100 assert (( "bar" == res.getValue(0) )) 101 assert (( "bar1" == res.getValue(1) )) 102 cv = nil 103 cv2 = nil 104 cv1 = nil 105 cv4 = nil 106 end 107 108 def test_SBase_appendNotes 109 triple = LibSBML::XMLTriple.new("p", "", "") 110 att = LibSBML::XMLAttributes.new() 111 ns = LibSBML::XMLNamespaces.new() 112 ns.add( "http://www.w3.org/1999/xhtml", "") 113 token4 = LibSBML::XMLToken.new("This is my text") 114 node4 = LibSBML::XMLNode.new(token4) 115 token5 = LibSBML::XMLToken.new("This is additional text") 116 node5 = LibSBML::XMLNode.new(token5) 117 token = LibSBML::XMLToken.new(triple,att,ns) 118 node = LibSBML::XMLNode.new(token) 119 node.addChild(node4) 120 @@s.setNotes(node) 121 assert( @@s.isSetNotes() == true ) 122 token1 = LibSBML::XMLToken.new(triple,att,ns) 123 node1 = LibSBML::XMLNode.new(token1) 124 node1.addChild(node5) 125 @@s.appendNotes(node1) 126 assert( @@s.isSetNotes() == true ) 127 node2 = @@s.getNotes() 128 assert( node2.getNumChildren() == 2 ) 129 assert (( "p" == node2.getChild(0).getName() )) 130 assert( node2.getChild(0).getNumChildren() == 1 ) 131 assert (( "p" == node2.getChild(1).getName() )) 132 assert( node2.getChild(1).getNumChildren() == 1 ) 133 chars1 = node2.getChild(0).getChild(0).getCharacters() 134 chars2 = node2.getChild(1).getChild(0).getCharacters() 135 assert (( "This is my text" == chars1 )) 136 assert (( "This is additional text" == chars2 )) 137 node = nil 138 node1 = nil 139 end 140 141 def test_SBase_appendNotes1 142 att = LibSBML::XMLAttributes.new() 143 ns = LibSBML::XMLNamespaces.new() 144 ns.add( "http://www.w3.org/1999/xhtml", "") 145 html_triple = LibSBML::XMLTriple.new("html", "", "") 146 head_triple = LibSBML::XMLTriple.new("head", "", "") 147 title_triple = LibSBML::XMLTriple.new("title", "", "") 148 body_triple = LibSBML::XMLTriple.new("body", "", "") 149 p_triple = LibSBML::XMLTriple.new("p", "", "") 150 html_token = LibSBML::XMLToken.new(html_triple,att,ns) 151 head_token = LibSBML::XMLToken.new(head_triple,att) 152 title_token = LibSBML::XMLToken.new(title_triple,att) 153 body_token = LibSBML::XMLToken.new(body_triple,att) 154 p_token = LibSBML::XMLToken.new(p_triple,att) 155 text_token = LibSBML::XMLToken.new("This is my text") 156 html_node = LibSBML::XMLNode.new(html_token) 157 head_node = LibSBML::XMLNode.new(head_token) 158 title_node = LibSBML::XMLNode.new(title_token) 159 body_node = LibSBML::XMLNode.new(body_token) 160 p_node = LibSBML::XMLNode.new(p_token) 161 text_node = LibSBML::XMLNode.new(text_token) 162 text_token1 = LibSBML::XMLToken.new("This is more text") 163 html_node1 = LibSBML::XMLNode.new(html_token) 164 head_node1 = LibSBML::XMLNode.new(head_token) 165 title_node1 = LibSBML::XMLNode.new(title_token) 166 body_node1 = LibSBML::XMLNode.new(body_token) 167 p_node1 = LibSBML::XMLNode.new(p_token) 168 text_node1 = LibSBML::XMLNode.new(text_token1) 169 p_node.addChild(text_node) 170 body_node.addChild(p_node) 171 head_node.addChild(title_node) 172 html_node.addChild(head_node) 173 html_node.addChild(body_node) 174 p_node1.addChild(text_node1) 175 body_node1.addChild(p_node1) 176 head_node1.addChild(title_node1) 177 html_node1.addChild(head_node1) 178 html_node1.addChild(body_node1) 179 @@s.setNotes(html_node) 180 @@s.appendNotes(html_node1) 181 notes = @@s.getNotes() 182 assert (( "notes" == notes.getName() )) 183 assert( notes.getNumChildren() == 1 ) 184 child = notes.getChild(0) 185 assert (( "html" == child.getName() )) 186 assert( child.getNumChildren() == 2 ) 187 child = child.getChild(1) 188 assert (( "body" == child.getName() )) 189 assert( child.getNumChildren() == 2 ) 190 child1 = child.getChild(0) 191 assert (( "p" == child1.getName() )) 192 assert( child1.getNumChildren() == 1 ) 193 child1 = child1.getChild(0) 194 assert (( "This is my text" == child1.getCharacters() )) 195 assert( child1.getNumChildren() == 0 ) 196 child1 = child.getChild(1) 197 assert (( "p" == child1.getName() )) 198 assert( child1.getNumChildren() == 1 ) 199 child1 = child1.getChild(0) 200 assert (( "This is more text" == child1.getCharacters() )) 201 assert( child1.getNumChildren() == 0 ) 202 att = nil 203 ns = nil 204 html_triple = nil 205 head_triple = nil 206 body_triple = nil 207 p_triple = nil 208 html_token = nil 209 head_token = nil 210 body_token = nil 211 p_token = nil 212 text_token = nil 213 text_token1 = nil 214 html_node = nil 215 head_node = nil 216 body_node = nil 217 p_node = nil 218 text_node = nil 219 html_node1 = nil 220 head_node1 = nil 221 body_node1 = nil 222 p_node1 = nil 223 text_node1 = nil 224 end 225 226 def test_SBase_appendNotes2 227 att = LibSBML::XMLAttributes.new() 228 ns = LibSBML::XMLNamespaces.new() 229 ns.add( "http://www.w3.org/1999/xhtml", "") 230 html_triple = LibSBML::XMLTriple.new("html", "", "") 231 head_triple = LibSBML::XMLTriple.new("head", "", "") 232 title_triple = LibSBML::XMLTriple.new("title", "", "") 233 body_triple = LibSBML::XMLTriple.new("body", "", "") 234 p_triple = LibSBML::XMLTriple.new("p", "", "") 235 html_token = LibSBML::XMLToken.new(html_triple,att,ns) 236 head_token = LibSBML::XMLToken.new(head_triple,att) 237 title_token = LibSBML::XMLToken.new(title_triple,att) 238 body_token = LibSBML::XMLToken.new(body_triple,att) 239 p_token = LibSBML::XMLToken.new(p_triple,att) 240 text_token = LibSBML::XMLToken.new("This is my text") 241 html_node = LibSBML::XMLNode.new(html_token) 242 head_node = LibSBML::XMLNode.new(head_token) 243 title_node = LibSBML::XMLNode.new(title_token) 244 body_node = LibSBML::XMLNode.new(body_token) 245 p_node = LibSBML::XMLNode.new(p_token) 246 text_node = LibSBML::XMLNode.new(text_token) 247 body_token1 = LibSBML::XMLToken.new(body_triple,att,ns) 248 text_token1 = LibSBML::XMLToken.new("This is more text") 249 body_node1 = LibSBML::XMLNode.new(body_token1) 250 p_node1 = LibSBML::XMLNode.new(p_token) 251 text_node1 = LibSBML::XMLNode.new(text_token1) 252 p_node.addChild(text_node) 253 body_node.addChild(p_node) 254 head_node.addChild(title_node) 255 html_node.addChild(head_node) 256 html_node.addChild(body_node) 257 p_node1.addChild(text_node1) 258 body_node1.addChild(p_node1) 259 @@s.setNotes(html_node) 260 @@s.appendNotes(body_node1) 261 notes = @@s.getNotes() 262 assert (( "notes" == notes.getName() )) 263 assert( notes.getNumChildren() == 1 ) 264 child = notes.getChild(0) 265 assert (( "html" == child.getName() )) 266 assert( child.getNumChildren() == 2 ) 267 child = child.getChild(1) 268 assert (( "body" == child.getName() )) 269 assert( child.getNumChildren() == 2 ) 270 child1 = child.getChild(0) 271 assert (( "p" == child1.getName() )) 272 assert( child1.getNumChildren() == 1 ) 273 child1 = child1.getChild(0) 274 assert (( "This is my text" == child1.getCharacters() )) 275 assert( child1.getNumChildren() == 0 ) 276 child1 = child.getChild(1) 277 assert (( "p" == child1.getName() )) 278 assert( child1.getNumChildren() == 1 ) 279 child1 = child1.getChild(0) 280 assert (( "This is more text" == child1.getCharacters() )) 281 assert( child1.getNumChildren() == 0 ) 282 att = nil 283 ns = nil 284 html_triple = nil 285 head_triple = nil 286 body_triple = nil 287 p_triple = nil 288 html_token = nil 289 head_token = nil 290 body_token = nil 291 p_token = nil 292 text_token = nil 293 text_token1 = nil 294 body_token1 = nil 295 html_node = nil 296 head_node = nil 297 body_node = nil 298 p_node = nil 299 text_node = nil 300 body_node1 = nil 301 p_node1 = nil 302 text_node1 = nil 303 end 304 305 def test_SBase_appendNotes3 306 att = LibSBML::XMLAttributes.new() 307 ns = LibSBML::XMLNamespaces.new() 308 ns.add( "http://www.w3.org/1999/xhtml", "") 309 html_triple = LibSBML::XMLTriple.new("html", "", "") 310 head_triple = LibSBML::XMLTriple.new("head", "", "") 311 title_triple = LibSBML::XMLTriple.new("title", "", "") 312 body_triple = LibSBML::XMLTriple.new("body", "", "") 313 p_triple = LibSBML::XMLTriple.new("p", "", "") 314 html_token = LibSBML::XMLToken.new(html_triple,att,ns) 315 head_token = LibSBML::XMLToken.new(head_triple,att) 316 title_token = LibSBML::XMLToken.new(title_triple,att) 317 body_token = LibSBML::XMLToken.new(body_triple,att) 318 p_token = LibSBML::XMLToken.new(p_triple,att) 319 text_token = LibSBML::XMLToken.new("This is my text") 320 html_node = LibSBML::XMLNode.new(html_token) 321 head_node = LibSBML::XMLNode.new(head_token) 322 title_node = LibSBML::XMLNode.new(title_token) 323 body_node = LibSBML::XMLNode.new(body_token) 324 p_node = LibSBML::XMLNode.new(p_token) 325 text_node = LibSBML::XMLNode.new(text_token) 326 p_token1 = LibSBML::XMLToken.new(p_triple,att,ns) 327 text_token1 = LibSBML::XMLToken.new("This is more text") 328 p_node1 = LibSBML::XMLNode.new(p_token1) 329 text_node1 = LibSBML::XMLNode.new(text_token1) 330 p_node.addChild(text_node) 331 body_node.addChild(p_node) 332 head_node.addChild(title_node) 333 html_node.addChild(head_node) 334 html_node.addChild(body_node) 335 p_node1.addChild(text_node1) 336 @@s.setNotes(html_node) 337 @@s.appendNotes(p_node1) 338 notes = @@s.getNotes() 339 assert (( "notes" == notes.getName() )) 340 assert( notes.getNumChildren() == 1 ) 341 child = notes.getChild(0) 342 assert (( "html" == child.getName() )) 343 assert( child.getNumChildren() == 2 ) 344 child = child.getChild(1) 345 assert (( "body" == child.getName() )) 346 assert( child.getNumChildren() == 2 ) 347 child1 = child.getChild(0) 348 assert (( "p" == child1.getName() )) 349 assert( child1.getNumChildren() == 1 ) 350 child1 = child1.getChild(0) 351 assert (( "This is my text" == child1.getCharacters() )) 352 assert( child1.getNumChildren() == 0 ) 353 child1 = child.getChild(1) 354 assert (( "p" == child1.getName() )) 355 assert( child1.getNumChildren() == 1 ) 356 child1 = child1.getChild(0) 357 assert (( "This is more text" == child1.getCharacters() )) 358 assert( child1.getNumChildren() == 0 ) 359 att = nil 360 ns = nil 361 html_triple = nil 362 head_triple = nil 363 body_triple = nil 364 p_triple = nil 365 html_token = nil 366 head_token = nil 367 body_token = nil 368 p_token = nil 369 text_token = nil 370 text_token1 = nil 371 p_token1 = nil 372 html_node = nil 373 head_node = nil 374 body_node = nil 375 p_node = nil 376 text_node = nil 377 p_node1 = nil 378 text_node1 = nil 379 end 380 381 def test_SBase_appendNotes4 382 att = LibSBML::XMLAttributes.new() 383 ns = LibSBML::XMLNamespaces.new() 384 ns.add( "http://www.w3.org/1999/xhtml", "") 385 html_triple = LibSBML::XMLTriple.new("html", "", "") 386 head_triple = LibSBML::XMLTriple.new("head", "", "") 387 title_triple = LibSBML::XMLTriple.new("title", "", "") 388 body_triple = LibSBML::XMLTriple.new("body", "", "") 389 p_triple = LibSBML::XMLTriple.new("p", "", "") 390 html_token = LibSBML::XMLToken.new(html_triple,att,ns) 391 head_token = LibSBML::XMLToken.new(head_triple,att) 392 title_token = LibSBML::XMLToken.new(title_triple,att) 393 body_token = LibSBML::XMLToken.new(body_triple,att) 394 p_token = LibSBML::XMLToken.new(p_triple,att) 395 body_token1 = LibSBML::XMLToken.new(body_triple,att,ns) 396 text_token = LibSBML::XMLToken.new("This is my text") 397 body_node = LibSBML::XMLNode.new(body_token1) 398 p_node = LibSBML::XMLNode.new(p_token) 399 text_node = LibSBML::XMLNode.new(text_token) 400 text_token1 = LibSBML::XMLToken.new("This is more text") 401 html_node1 = LibSBML::XMLNode.new(html_token) 402 head_node1 = LibSBML::XMLNode.new(head_token) 403 title_node1 = LibSBML::XMLNode.new(title_token) 404 body_node1 = LibSBML::XMLNode.new(body_token) 405 p_node1 = LibSBML::XMLNode.new(p_token) 406 text_node1 = LibSBML::XMLNode.new(text_token1) 407 p_node.addChild(text_node) 408 body_node.addChild(p_node) 409 p_node1.addChild(text_node1) 410 body_node1.addChild(p_node1) 411 head_node1.addChild(title_node1) 412 html_node1.addChild(head_node1) 413 html_node1.addChild(body_node1) 414 @@s.setNotes(body_node) 415 @@s.appendNotes(html_node1) 416 notes = @@s.getNotes() 417 assert (( "notes" == notes.getName() )) 418 assert( notes.getNumChildren() == 1 ) 419 child = notes.getChild(0) 420 assert (( "html" == child.getName() )) 421 assert( child.getNumChildren() == 2 ) 422 child = child.getChild(1) 423 assert (( "body" == child.getName() )) 424 assert( child.getNumChildren() == 2 ) 425 child1 = child.getChild(0) 426 assert (( "p" == child1.getName() )) 427 assert( child1.getNumChildren() == 1 ) 428 child1 = child1.getChild(0) 429 assert (( "This is my text" == child1.getCharacters() )) 430 assert( child1.getNumChildren() == 0 ) 431 child1 = child.getChild(1) 432 assert (( "p" == child1.getName() )) 433 assert( child1.getNumChildren() == 1 ) 434 child1 = child1.getChild(0) 435 assert (( "This is more text" == child1.getCharacters() )) 436 assert( child1.getNumChildren() == 0 ) 437 att = nil 438 ns = nil 439 html_triple = nil 440 head_triple = nil 441 body_triple = nil 442 p_triple = nil 443 body_token = nil 444 p_token = nil 445 text_token = nil 446 text_token1 = nil 447 body_token1 = nil 448 body_node = nil 449 p_node = nil 450 text_node = nil 451 html_node1 = nil 452 head_node1 = nil 453 body_node1 = nil 454 p_node1 = nil 455 text_node1 = nil 456 end 457 458 def test_SBase_appendNotes5 459 att = LibSBML::XMLAttributes.new() 460 ns = LibSBML::XMLNamespaces.new() 461 ns.add( "http://www.w3.org/1999/xhtml", "") 462 html_triple = LibSBML::XMLTriple.new("html", "", "") 463 head_triple = LibSBML::XMLTriple.new("head", "", "") 464 title_triple = LibSBML::XMLTriple.new("title", "", "") 465 body_triple = LibSBML::XMLTriple.new("body", "", "") 466 p_triple = LibSBML::XMLTriple.new("p", "", "") 467 html_token = LibSBML::XMLToken.new(html_triple,att,ns) 468 head_token = LibSBML::XMLToken.new(head_triple,att) 469 title_token = LibSBML::XMLToken.new(title_triple,att) 470 body_token = LibSBML::XMLToken.new(body_triple,att) 471 p_token = LibSBML::XMLToken.new(p_triple,att) 472 p_token1 = LibSBML::XMLToken.new(p_triple,att,ns) 473 text_token = LibSBML::XMLToken.new("This is my text") 474 p_node = LibSBML::XMLNode.new(p_token1) 475 text_node = LibSBML::XMLNode.new(text_token) 476 text_token1 = LibSBML::XMLToken.new("This is more text") 477 html_node1 = LibSBML::XMLNode.new(html_token) 478 head_node1 = LibSBML::XMLNode.new(head_token) 479 title_node1 = LibSBML::XMLNode.new(title_token) 480 body_node1 = LibSBML::XMLNode.new(body_token) 481 p_node1 = LibSBML::XMLNode.new(p_token) 482 text_node1 = LibSBML::XMLNode.new(text_token1) 483 p_node.addChild(text_node) 484 p_node1.addChild(text_node1) 485 body_node1.addChild(p_node1) 486 head_node1.addChild(title_node1) 487 html_node1.addChild(head_node1) 488 html_node1.addChild(body_node1) 489 @@s.setNotes(p_node) 490 @@s.appendNotes(html_node1) 491 notes = @@s.getNotes() 492 assert (( "notes" == notes.getName() )) 493 assert( notes.getNumChildren() == 1 ) 494 child = notes.getChild(0) 495 assert (( "html" == child.getName() )) 496 assert( child.getNumChildren() == 2 ) 497 child = child.getChild(1) 498 assert (( "body" == child.getName() )) 499 assert( child.getNumChildren() == 2 ) 500 child1 = child.getChild(0) 501 assert (( "p" == child1.getName() )) 502 assert( child1.getNumChildren() == 1 ) 503 child1 = child1.getChild(0) 504 assert (( "This is my text" == child1.getCharacters() )) 505 assert( child1.getNumChildren() == 0 ) 506 child1 = child.getChild(1) 507 assert (( "p" == child1.getName() )) 508 assert( child1.getNumChildren() == 1 ) 509 child1 = child1.getChild(0) 510 assert (( "This is more text" == child1.getCharacters() )) 511 assert( child1.getNumChildren() == 0 ) 512 att = nil 513 ns = nil 514 html_triple = nil 515 head_triple = nil 516 body_triple = nil 517 p_triple = nil 518 body_token = nil 519 p_token = nil 520 p_token1 = nil 521 text_token = nil 522 text_token1 = nil 523 p_node = nil 524 text_node = nil 525 html_node1 = nil 526 head_node1 = nil 527 body_node1 = nil 528 p_node1 = nil 529 text_node1 = nil 530 end 531 532 def test_SBase_appendNotes6 533 att = LibSBML::XMLAttributes.new() 534 ns = LibSBML::XMLNamespaces.new() 535 ns.add( "http://www.w3.org/1999/xhtml", "") 536 body_triple = LibSBML::XMLTriple.new("body", "", "") 537 p_triple = LibSBML::XMLTriple.new("p", "", "") 538 body_token = LibSBML::XMLToken.new(body_triple,att,ns) 539 p_token = LibSBML::XMLToken.new(p_triple,att) 540 text_token = LibSBML::XMLToken.new("This is my text") 541 body_node = LibSBML::XMLNode.new(body_token) 542 p_node = LibSBML::XMLNode.new(p_token) 543 text_node = LibSBML::XMLNode.new(text_token) 544 text_token1 = LibSBML::XMLToken.new("This is more text") 545 body_node1 = LibSBML::XMLNode.new(body_token) 546 p_node1 = LibSBML::XMLNode.new(p_token) 547 text_node1 = LibSBML::XMLNode.new(text_token1) 548 p_node.addChild(text_node) 549 body_node.addChild(p_node) 550 p_node1.addChild(text_node1) 551 body_node1.addChild(p_node1) 552 @@s.setNotes(body_node) 553 @@s.appendNotes(body_node1) 554 notes = @@s.getNotes() 555 assert (( "notes" == notes.getName() )) 556 assert( notes.getNumChildren() == 1 ) 557 child = notes.getChild(0) 558 assert (( "body" == child.getName() )) 559 assert( child.getNumChildren() == 2 ) 560 child1 = child.getChild(0) 561 assert (( "p" == child1.getName() )) 562 assert( child1.getNumChildren() == 1 ) 563 child1 = child1.getChild(0) 564 assert (( "This is my text" == child1.getCharacters() )) 565 assert( child1.getNumChildren() == 0 ) 566 child1 = child.getChild(1) 567 assert (( "p" == child1.getName() )) 568 assert( child1.getNumChildren() == 1 ) 569 child1 = child1.getChild(0) 570 assert (( "This is more text" == child1.getCharacters() )) 571 assert( child1.getNumChildren() == 0 ) 572 att = nil 573 ns = nil 574 body_triple = nil 575 p_triple = nil 576 body_token = nil 577 p_token = nil 578 text_token = nil 579 text_token1 = nil 580 body_node = nil 581 p_node = nil 582 text_node = nil 583 body_node1 = nil 584 p_node1 = nil 585 text_node1 = nil 586 end 587 588 def test_SBase_appendNotes7 589 att = LibSBML::XMLAttributes.new() 590 ns = LibSBML::XMLNamespaces.new() 591 ns.add( "http://www.w3.org/1999/xhtml", "") 592 body_triple = LibSBML::XMLTriple.new("body", "", "") 593 p_triple = LibSBML::XMLTriple.new("p", "", "") 594 body_token = LibSBML::XMLToken.new(body_triple,att,ns) 595 p_token1 = LibSBML::XMLToken.new(p_triple,att,ns) 596 text_token = LibSBML::XMLToken.new("This is my text") 597 p_token = LibSBML::XMLToken.new(p_triple,att) 598 p_node = LibSBML::XMLNode.new(p_token1) 599 text_node = LibSBML::XMLNode.new(text_token) 600 text_token1 = LibSBML::XMLToken.new("This is more text") 601 body_node1 = LibSBML::XMLNode.new(body_token) 602 p_node1 = LibSBML::XMLNode.new(p_token) 603 text_node1 = LibSBML::XMLNode.new(text_token1) 604 p_node.addChild(text_node) 605 p_node1.addChild(text_node1) 606 body_node1.addChild(p_node1) 607 @@s.setNotes(p_node) 608 @@s.appendNotes(body_node1) 609 notes = @@s.getNotes() 610 assert (( "notes" == notes.getName() )) 611 assert( notes.getNumChildren() == 1 ) 612 child = notes.getChild(0) 613 assert (( "body" == child.getName() )) 614 assert( child.getNumChildren() == 2 ) 615 child1 = child.getChild(0) 616 assert (( "p" == child1.getName() )) 617 assert( child1.getNumChildren() == 1 ) 618 child1 = child1.getChild(0) 619 assert (( "This is my text" == child1.getCharacters() )) 620 assert( child1.getNumChildren() == 0 ) 621 child1 = child.getChild(1) 622 assert (( "p" == child1.getName() )) 623 assert( child1.getNumChildren() == 1 ) 624 child1 = child1.getChild(0) 625 assert (( "This is more text" == child1.getCharacters() )) 626 assert( child1.getNumChildren() == 0 ) 627 att = nil 628 ns = nil 629 body_triple = nil 630 p_triple = nil 631 body_token = nil 632 p_token = nil 633 p_token1 = nil 634 text_token = nil 635 text_token1 = nil 636 p_node = nil 637 text_node = nil 638 body_node1 = nil 639 p_node1 = nil 640 text_node1 = nil 641 end 642 643 def test_SBase_appendNotes8 644 att = LibSBML::XMLAttributes.new() 645 ns = LibSBML::XMLNamespaces.new() 646 ns.add( "http://www.w3.org/1999/xhtml", "") 647 body_triple = LibSBML::XMLTriple.new("body", "", "") 648 p_triple = LibSBML::XMLTriple.new("p", "", "") 649 body_token = LibSBML::XMLToken.new(body_triple,att,ns) 650 p_token = LibSBML::XMLToken.new(p_triple,att) 651 text_token = LibSBML::XMLToken.new("This is my text") 652 body_node = LibSBML::XMLNode.new(body_token) 653 p_node = LibSBML::XMLNode.new(p_token) 654 text_node = LibSBML::XMLNode.new(text_token) 655 p_token1 = LibSBML::XMLToken.new(p_triple,att,ns) 656 text_token1 = LibSBML::XMLToken.new("This is more text") 657 p_node1 = LibSBML::XMLNode.new(p_token1) 658 text_node1 = LibSBML::XMLNode.new(text_token1) 659 p_node.addChild(text_node) 660 body_node.addChild(p_node) 661 p_node1.addChild(text_node1) 662 @@s.setNotes(body_node) 663 @@s.appendNotes(p_node1) 664 notes = @@s.getNotes() 665 assert (( "notes" == notes.getName() )) 666 assert( notes.getNumChildren() == 1 ) 667 child = notes.getChild(0) 668 assert (( "body" == child.getName() )) 669 assert( child.getNumChildren() == 2 ) 670 child1 = child.getChild(0) 671 assert (( "p" == child1.getName() )) 672 assert( child1.getNumChildren() == 1 ) 673 child1 = child1.getChild(0) 674 assert (( "This is my text" == child1.getCharacters() )) 675 assert( child1.getNumChildren() == 0 ) 676 child1 = child.getChild(1) 677 assert (( "p" == child1.getName() )) 678 assert( child1.getNumChildren() == 1 ) 679 child1 = child1.getChild(0) 680 assert (( "This is more text" == child1.getCharacters() )) 681 assert( child1.getNumChildren() == 0 ) 682 att = nil 683 ns = nil 684 body_triple = nil 685 p_triple = nil 686 body_token = nil 687 p_token = nil 688 text_token = nil 689 text_token1 = nil 690 p_token1 = nil 691 body_node = nil 692 p_node = nil 693 text_node = nil 694 p_node1 = nil 695 text_node1 = nil 696 end 697 698 def test_SBase_appendNotesString 699 notes = "<p xmlns=\"http://www.w3.org/1999/xhtml\">This is a test note </p>"; 700 taggednewnotes = "<notes>\n" + " <p xmlns=\"http://www.w3.org/1999/xhtml\">This is a test note </p>\n" + 701 " <p xmlns=\"http://www.w3.org/1999/xhtml\">This is more test notes </p>\n" + 702 "</notes>" 703 taggednewnotes2 = "<notes>\n" + " <p xmlns=\"http://www.w3.org/1999/xhtml\">This is a test note </p>\n" + 704 " <p xmlns=\"http://www.w3.org/1999/xhtml\">This is more test notes 1</p>\n" + 705 " <p xmlns=\"http://www.w3.org/1999/xhtml\">This is more test notes 2</p>\n" + 706 "</notes>" 707 newnotes = "<p xmlns=\"http://www.w3.org/1999/xhtml\">This is more test notes </p>"; 708 newnotes2 = "<p xmlns=\"http://www.w3.org/1999/xhtml\">This is more test notes 1</p>" + "<p xmlns=\"http://www.w3.org/1999/xhtml\">This is more test notes 2</p>"; 709 newnotes3 = "<notes>\n" + " <p xmlns=\"http://www.w3.org/1999/xhtml\">This is more test notes </p>\n" + "</notes>"; 710 newnotes4 = "<notes>\n" + " <p xmlns=\"http://www.w3.org/1999/xhtml\">This is more test notes 1</p>\n" + 711 " <p xmlns=\"http://www.w3.org/1999/xhtml\">This is more test notes 2</p>\n" + 712 "</notes>" 713 @@s.setNotes(notes) 714 assert( @@s.isSetNotes() == true ) 715 @@s.appendNotes(newnotes) 716 notes1 = @@s.getNotesString() 717 assert( @@s.isSetNotes() == true ) 718 assert (( notes1 == taggednewnotes )) 719 @@s.setNotes(notes) 720 @@s.appendNotes(newnotes2) 721 notes2 = @@s.getNotesString() 722 assert( @@s.isSetNotes() == true ) 723 assert (( notes2 == taggednewnotes2 )) 724 @@s.setNotes(notes) 725 @@s.appendNotes(newnotes3) 726 notes3 = @@s.getNotesString() 727 assert( @@s.isSetNotes() == true ) 728 assert (( notes3 == taggednewnotes )) 729 @@s.setNotes(notes) 730 @@s.appendNotes(newnotes4) 731 notes4 = @@s.getNotesString() 732 assert( @@s.isSetNotes() == true ) 733 assert (( notes4 == taggednewnotes2 )) 734 end 735 736 def test_SBase_appendNotesString1 737 notes = "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n" + " <head>\n" + 738 " <title/>\n" + 739 " </head>\n" + 740 " <body>\n" + 741 " <p>This is a test note </p>\n" + 742 " </body>\n" + 743 "</html>" 744 taggednewnotes = "<notes>\n" + 745 " <html xmlns=\"http://www.w3.org/1999/xhtml\">\n" + 746 " <head>\n" + 747 " <title/>\n" + 748 " </head>\n" + 749 " <body>\n" + 750 " <p>This is a test note </p>\n" + 751 " <p>This is more test notes </p>\n" + 752 " </body>\n" + 753 " </html>\n" + 754 "</notes>" 755 addnotes = "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n" + " <head>\n" + 756 " <title/>\n" + 757 " </head>\n" + 758 " <body>\n" + 759 " <p>This is more test notes </p>\n" + 760 " </body>\n" + 761 "</html>" 762 addnotes2 = "<notes>\n" + 763 " <html xmlns=\"http://www.w3.org/1999/xhtml\">\n" + 764 " <head>\n" + 765 " <title/>\n" + 766 " </head>\n" + 767 " <body>\n" + 768 " <p>This is more test notes </p>\n" + 769 " </body>\n" + 770 " </html>\n" + 771 "</notes>" 772 @@s.setNotes(notes) 773 @@s.appendNotes(addnotes) 774 notes1 = @@s.getNotesString() 775 assert( @@s.isSetNotes() == true ) 776 assert (( notes1 == taggednewnotes )) 777 @@s.setNotes(notes) 778 @@s.appendNotes(addnotes2) 779 notes2 = @@s.getNotesString() 780 assert( @@s.isSetNotes() == true ) 781 assert (( notes2 == taggednewnotes )) 782 end 783 784 def test_SBase_appendNotesString2 785 notes = "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n" + " <head>\n" + 786 " <title/>\n" + 787 " </head>\n" + 788 " <body>\n" + 789 " <p>This is a test note </p>\n" + 790 " </body>\n" + 791 "</html>" 792 taggednewnotes = "<notes>\n" + 793 " <html xmlns=\"http://www.w3.org/1999/xhtml\">\n" + 794 " <head>\n" + 795 " <title/>\n" + 796 " </head>\n" + 797 " <body>\n" + 798 " <p>This is a test note </p>\n" + 799 " <p>This is more test notes </p>\n" + 800 " </body>\n" + 801 " </html>\n" + 802 "</notes>" 803 addnotes = "<body xmlns=\"http://www.w3.org/1999/xhtml\">\n" + " <p>This is more test notes </p>\n" + "</body>\n"; 804 addnotes2 = "<notes>\n" + 805 " <body xmlns=\"http://www.w3.org/1999/xhtml\">\n" + 806 " <p>This is more test notes </p>\n" + 807 " </body>\n" + 808 "</notes>" 809 @@s.setNotes(notes) 810 @@s.appendNotes(addnotes) 811 notes1 = @@s.getNotesString() 812 assert( @@s.isSetNotes() == true ) 813 assert (( notes1 == taggednewnotes )) 814 @@s.setNotes(notes) 815 @@s.appendNotes(addnotes2) 816 notes2 = @@s.getNotesString() 817 assert( @@s.isSetNotes() == true ) 818 assert (( notes2 == taggednewnotes )) 819 end 820 821 def test_SBase_appendNotesString3 822 notes = "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n" + " <head>\n" + 823 " <title/>\n" + 824 " </head>\n" + 825 " <body>\n" + 826 " <p>This is a test note </p>\n" + 827 " </body>\n" + 828 "</html>" 829 taggednewnotes = "<notes>\n" + 830 " <html xmlns=\"http://www.w3.org/1999/xhtml\">\n" + 831 " <head>\n" + 832 " <title/>\n" + 833 " </head>\n" + 834 " <body>\n" + 835 " <p>This is a test note </p>\n" + 836 " <p xmlns=\"http://www.w3.org/1999/xhtml\">This is more test notes </p>\n" + 837 " </body>\n" + 838 " </html>\n" + 839 "</notes>" 840 taggednewnotes2 = "<notes>\n" + 841 " <html xmlns=\"http://www.w3.org/1999/xhtml\">\n" + 842 " <head>\n" + 843 " <title/>\n" + 844 " </head>\n" + 845 " <body>\n" + 846 " <p>This is a test note </p>\n" + 847 " <p xmlns=\"http://www.w3.org/1999/xhtml\">This is more test notes 1</p>\n" + 848 " <p xmlns=\"http://www.w3.org/1999/xhtml\">This is more test notes 2</p>\n" + 849 " </body>\n" + 850 " </html>\n" + 851 "</notes>" 852 addnotes = "<p xmlns=\"http://www.w3.org/1999/xhtml\">This is more test notes </p>\n"; 853 addnotes2 = "<p xmlns=\"http://www.w3.org/1999/xhtml\">This is more test notes 1</p>\n" + "<p xmlns=\"http://www.w3.org/1999/xhtml\">This is more test notes 2</p>"; 854 addnotes3 = "<notes>\n" + " <p xmlns=\"http://www.w3.org/1999/xhtml\">This is more test notes </p>\n" + "</notes>"; 855 addnotes4 = "<notes>\n" + " <p xmlns=\"http://www.w3.org/1999/xhtml\">This is more test notes 1</p>\n" + 856 " <p xmlns=\"http://www.w3.org/1999/xhtml\">This is more test notes 2</p>\n" + 857 "</notes>" 858 @@s.setNotes(notes) 859 @@s.appendNotes(addnotes) 860 notes1 = @@s.getNotesString() 861 assert( @@s.isSetNotes() == true ) 862 assert (( notes1 == taggednewnotes )) 863 @@s.setNotes(notes) 864 @@s.appendNotes(addnotes2) 865 notes2 = @@s.getNotesString() 866 assert( @@s.isSetNotes() == true ) 867 assert (( notes2 == taggednewnotes2 )) 868 @@s.setNotes(notes) 869 @@s.appendNotes(addnotes3) 870 notes3 = @@s.getNotesString() 871 assert( @@s.isSetNotes() == true ) 872 assert (( notes3 == taggednewnotes )) 873 @@s.setNotes(notes) 874 @@s.appendNotes(addnotes4) 875 notes4 = @@s.getNotesString() 876 assert( @@s.isSetNotes() == true ) 877 assert (( notes4 == taggednewnotes2 )) 878 end 879 880 def test_SBase_appendNotesString4 881 notes = "<body xmlns=\"http://www.w3.org/1999/xhtml\">\n" + " <p>This is a test note </p>\n" + "</body>"; 882 taggednewnotes = "<notes>\n" + 883 " <html xmlns=\"http://www.w3.org/1999/xhtml\">\n" + 884 " <head>\n" + 885 " <title/>\n" + 886 " </head>\n" + 887 " <body>\n" + 888 " <p>This is a test note </p>\n" + 889 " <p>This is more test notes </p>\n" + 890 " </body>\n" + 891 " </html>\n" + 892 "</notes>" 893 addnotes = "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n" + " <head>\n" + 894 " <title/>\n" + 895 " </head>\n" + 896 " <body>\n" + 897 " <p>This is more test notes </p>\n" + 898 " </body>\n" + 899 "</html>" 900 addnotes2 = "<notes>\n" + 901 " <html xmlns=\"http://www.w3.org/1999/xhtml\">\n" + 902 " <head>\n" + 903 " <title/>\n" + 904 " </head>\n" + 905 " <body>\n" + 906 " <p>This is more test notes </p>\n" + 907 " </body>\n" + 908 " </html>\n" + 909 "</notes>" 910 @@s.setNotes(notes) 911 @@s.appendNotes(addnotes) 912 notes1 = @@s.getNotesString() 913 assert( @@s.isSetNotes() == true ) 914 assert (( notes1 == taggednewnotes )) 915 @@s.setNotes(notes) 916 @@s.appendNotes(addnotes2) 917 notes2 = @@s.getNotesString() 918 assert( @@s.isSetNotes() == true ) 919 assert (( notes2 == taggednewnotes )) 920 end 921 922 def test_SBase_appendNotesString5 923 notes = "<p xmlns=\"http://www.w3.org/1999/xhtml\">This is a test note </p>"; 924 taggednewnotes = "<notes>\n" + 925 " <html xmlns=\"http://www.w3.org/1999/xhtml\">\n" + 926 " <head>\n" + 927 " <title/>\n" + 928 " </head>\n" + 929 " <body>\n" + 930 " <p xmlns=\"http://www.w3.org/1999/xhtml\">This is a test note </p>\n" + 931 " <p>This is more test notes </p>\n" + 932 " </body>\n" + 933 " </html>\n" + 934 "</notes>" 935 addnotes = "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n" + " <head>\n" + 936 " <title/>\n" + 937 " </head>\n" + 938 " <body>\n" + 939 " <p>This is more test notes </p>\n" + 940 " </body>\n" + 941 "</html>" 942 addnotes2 = "<notes>\n" + 943 " <html xmlns=\"http://www.w3.org/1999/xhtml\">\n" + 944 " <head>\n" + 945 " <title/>\n" + 946 " </head>\n" + 947 " <body>\n" + 948 " <p>This is more test notes </p>\n" + 949 " </body>\n" + 950 " </html>\n" + 951 "</notes>" 952 @@s.setNotes(notes) 953 @@s.appendNotes(addnotes) 954 notes1 = @@s.getNotesString() 955 assert( @@s.isSetNotes() == true ) 956 assert (( notes1 == taggednewnotes )) 957 @@s.setNotes(notes) 958 @@s.appendNotes(addnotes2) 959 notes2 = @@s.getNotesString() 960 assert( @@s.isSetNotes() == true ) 961 assert (( notes2 == taggednewnotes )) 962 end 963 964 def test_SBase_appendNotesString6 965 notes = "<body xmlns=\"http://www.w3.org/1999/xhtml\">\n" + " <p>This is a test note </p>\n" + "</body>"; 966 taggednewnotes = "<notes>\n" + 967 " <body xmlns=\"http://www.w3.org/1999/xhtml\">\n" + 968 " <p>This is a test note </p>\n" + 969 " <p>This is more test notes </p>\n" + 970 " </body>\n" + 971 "</notes>" 972 addnotes = "<body xmlns=\"http://www.w3.org/1999/xhtml\">\n" + " <p>This is more test notes </p>\n" + "</body>"; 973 addnotes2 = "<notes>\n" + 974 " <body xmlns=\"http://www.w3.org/1999/xhtml\">\n" + 975 " <p>This is more test notes </p>\n" + 976 " </body>\n" + 977 "</notes>" 978 @@s.setNotes(notes) 979 @@s.appendNotes(addnotes) 980 notes1 = @@s.getNotesString() 981 assert( @@s.isSetNotes() == true ) 982 assert (( notes1 == taggednewnotes )) 983 @@s.setNotes(notes) 984 @@s.appendNotes(addnotes2) 985 notes2 = @@s.getNotesString() 986 assert( @@s.isSetNotes() == true ) 987 assert (( notes2 == taggednewnotes )) 988 end 989 990 def test_SBase_appendNotesString7 991 notes = "<p xmlns=\"http://www.w3.org/1999/xhtml\">This is a test note </p>"; 992 taggednewnotes = "<notes>\n" + 993 " <body xmlns=\"http://www.w3.org/1999/xhtml\">\n" + 994 " <p xmlns=\"http://www.w3.org/1999/xhtml\">This is a test note </p>\n" + 995 " <p>This is more test notes </p>\n" + 996 " </body>\n" + 997 "</notes>" 998 addnotes = "<body xmlns=\"http://www.w3.org/1999/xhtml\">\n" + " <p>This is more test notes </p>\n" + "</body>"; 999 addnotes2 = "<notes>\n" + 1000 " <body xmlns=\"http://www.w3.org/1999/xhtml\">\n" + 1001 " <p>This is more test notes </p>\n" + 1002 " </body>\n" + 1003 "</notes>" 1004 @@s.setNotes(notes) 1005 @@s.appendNotes(addnotes) 1006 notes1 = @@s.getNotesString() 1007 assert( @@s.isSetNotes() == true ) 1008 assert (( notes1 == taggednewnotes )) 1009 @@s.setNotes(notes) 1010 @@s.appendNotes(addnotes2) 1011 notes2 = @@s.getNotesString() 1012 assert( @@s.isSetNotes() == true ) 1013 assert (( notes2 == taggednewnotes )) 1014 end 1015 1016 def test_SBase_appendNotesString8 1017 notes = "<body xmlns=\"http://www.w3.org/1999/xhtml\">\n" + " <p>This is a test note </p>\n" + "</body>"; 1018 taggednewnotes = "<notes>\n" + 1019 " <body xmlns=\"http://www.w3.org/1999/xhtml\">\n" + 1020 " <p>This is a test note </p>\n" + 1021 " <p xmlns=\"http://www.w3.org/1999/xhtml\">This is more test notes </p>\n" + 1022 " </body>\n" + 1023 "</notes>" 1024 taggednewnotes2 = "<notes>\n" + 1025 " <body xmlns=\"http://www.w3.org/1999/xhtml\">\n" + 1026 " <p>This is a test note </p>\n" + 1027 " <p xmlns=\"http://www.w3.org/1999/xhtml\">This is more test notes 1</p>\n" + 1028 " <p xmlns=\"http://www.w3.org/1999/xhtml\">This is more test notes 2</p>\n" + 1029 " </body>\n" + 1030 "</notes>" 1031 addnotes = "<p xmlns=\"http://www.w3.org/1999/xhtml\">This is more test notes </p>"; 1032 addnotes2 = "<p xmlns=\"http://www.w3.org/1999/xhtml\">This is more test notes 1</p>\n" + "<p xmlns=\"http://www.w3.org/1999/xhtml\">This is more test notes 2</p>"; 1033 addnotes3 = "<notes>\n" + 1034 " <p xmlns=\"http://www.w3.org/1999/xhtml\">This is more test notes </p>\n" + 1035 "</notes>" 1036 addnotes4 = "<notes>\n" + 1037 " <p xmlns=\"http://www.w3.org/1999/xhtml\">This is more test notes 1</p>\n" + 1038 " <p xmlns=\"http://www.w3.org/1999/xhtml\">This is more test notes 2</p>\n" + 1039 "</notes>" 1040 @@s.setNotes(notes) 1041 @@s.appendNotes(addnotes) 1042 notes1 = @@s.getNotesString() 1043 assert( @@s.isSetNotes() == true ) 1044 assert (( notes1 == taggednewnotes )) 1045 @@s.setNotes(notes) 1046 @@s.appendNotes(addnotes2) 1047 notes2 = @@s.getNotesString() 1048 assert( @@s.isSetNotes() == true ) 1049 assert (( notes2 == taggednewnotes2 )) 1050 @@s.setNotes(notes) 1051 @@s.appendNotes(addnotes3) 1052 notes3 = @@s.getNotesString() 1053 assert( @@s.isSetNotes() == true ) 1054 assert (( notes3 == taggednewnotes )) 1055 @@s.setNotes(notes) 1056 @@s.appendNotes(addnotes4) 1057 notes4 = @@s.getNotesString() 1058 assert( @@s.isSetNotes() == true ) 1059 assert (( notes4 == taggednewnotes2 )) 1060 end 1061 1062 def test_SBase_getQualifiersFromResources 1063 cv = LibSBML::CVTerm.new(LibSBML::BIOLOGICAL_QUALIFIER) 1064 cv.setBiologicalQualifierType(LibSBML::BQB_ENCODES) 1065 cv.addResource( "foo") 1066 @@s.setMetaId( "sbase1") 1067 @@s.addCVTerm(cv) 1068 assert( @@s.getResourceBiologicalQualifier( "foo") == LibSBML::BQB_ENCODES ) 1069 cv1 = LibSBML::CVTerm.new(LibSBML::MODEL_QUALIFIER) 1070 cv1.setModelQualifierType(LibSBML::BQM_IS) 1071 cv1.addResource( "bar") 1072 @@s.addCVTerm(cv1) 1073 assert( @@s.getResourceModelQualifier( "bar") == LibSBML::BQM_IS ) 1074 cv = nil 1075 cv1 = nil 1076 end 1077 1078 def test_SBase_setAnnotation 1079 token = LibSBML::XMLToken.new("This is a test note") 1080 node = LibSBML::XMLNode.new(token) 1081 @@s.setAnnotation(node) 1082 assert( @@s.isSetAnnotation() == true ) 1083 t1 = @@s.getAnnotation() 1084 assert( t1.getNumChildren() == 1 ) 1085 assert (( "This is a test note" == t1.getChild(0).getCharacters() )) 1086 if (@@s.getAnnotation() == node) 1087 end 1088 @@s.setAnnotation(@@s.getAnnotation()) 1089 assert (( "This is a test note" == @@s.getAnnotation().getChild(0).getCharacters() )) 1090 @@s.setAnnotation(nil) 1091 assert( @@s.isSetAnnotation() == false ) 1092 if (@@s.getAnnotation() != nil) 1093 end 1094 @@s.setAnnotation(node) 1095 assert( @@s.isSetAnnotation() == true ) 1096 @@s.unsetAnnotation() 1097 assert( @@s.isSetAnnotation() == false ) 1098 token = LibSBML::XMLToken.new("(CR) ¨ ¨ ¨ (NOT CR) &#; &#x; �a8; ¨ ¨") 1099 node = LibSBML::XMLNode.new(token) 1100 @@s.setAnnotation(node) 1101 t1 = @@s.getAnnotation() 1102 assert( t1.getNumChildren() == 1 ) 1103 s = t1.getChild(0).toXMLString() 1104 expected = "(CR) ¨ ¨ ¨ (NOT CR) &#; &#x; &#00a8; &#0168 &#x00a8"; 1105 assert (( expected == s )) 1106 token = LibSBML::XMLToken.new("& ' > < \" & ' > < "") 1107 node = LibSBML::XMLNode.new(token) 1108 @@s.setAnnotation(node) 1109 t1 = @@s.getAnnotation() 1110 assert( t1.getNumChildren() == 1 ) 1111 s2 = t1.getChild(0).toXMLString() 1112 expected2 = "& ' > < " & ' > < ""; 1113 assert (( expected2 == s2 )) 1114 token = nil 1115 node = nil 1116 end 1117 1118 def test_SBase_setAnnotationString 1119 annotation = "This is a test note"; 1120 taggedannotation = "<annotation>This is a test note</annotation>"; 1121 @@s.setAnnotation(annotation) 1122 assert( @@s.isSetAnnotation() == true ) 1123 if (( taggedannotation != @@s.getAnnotationString() )) 1124 end 1125 t1 = @@s.getAnnotation() 1126 assert( t1.getNumChildren() == 1 ) 1127 assert (( "This is a test note" == t1.getChild(0).getCharacters() )) 1128 @@s.setAnnotation(@@s.getAnnotationString()) 1129 t1 = @@s.getAnnotation() 1130 assert( t1.getNumChildren() == 1 ) 1131 chars = @@s.getAnnotationString() 1132 assert (( taggedannotation == chars )) 1133 @@s.setAnnotation( "") 1134 assert( @@s.isSetAnnotation() == false ) 1135 if (@@s.getAnnotationString() != nil) 1136 end 1137 @@s.setAnnotation(taggedannotation) 1138 assert( @@s.isSetAnnotation() == true ) 1139 if (( taggedannotation != @@s.getAnnotationString() )) 1140 end 1141 t1 = @@s.getAnnotation() 1142 assert( t1.getNumChildren() == 1 ) 1143 t2 = t1.getChild(0) 1144 assert (( "This is a test note" == t2.getCharacters() )) 1145 end 1146 1147 def test_SBase_setMetaId 1148 metaid = "x12345"; 1149 @@s.setMetaId(metaid) 1150 assert (( metaid == @@s.getMetaId() )) 1151 assert_equal true, @@s.isSetMetaId() 1152 if (@@s.getMetaId() == metaid) 1153 end 1154 @@s.setMetaId(@@s.getMetaId()) 1155 assert (( metaid == @@s.getMetaId() )) 1156 @@s.setMetaId("") 1157 assert_equal false, @@s.isSetMetaId() 1158 if (@@s.getMetaId() != nil) 1159 end 1160 end 1161 1162 def test_SBase_setNotes 1163 c = LibSBML::Model.new(1,2) 1164 token = LibSBML::XMLToken.new("This is a test note") 1165 node = LibSBML::XMLNode.new(token) 1166 c.setNotes(node) 1167 assert( c.isSetNotes() == true ) 1168 if (c.getNotes() == node) 1169 end 1170 t1 = c.getNotes() 1171 assert( t1.getNumChildren() == 1 ) 1172 assert (( "This is a test note" == t1.getChild(0).getCharacters() )) 1173 c.setNotes(c.getNotes()) 1174 t1 = c.getNotes() 1175 assert( t1.getNumChildren() == 1 ) 1176 chars = t1.getChild(0).getCharacters() 1177 assert (( "This is a test note" == chars )) 1178 c.setNotes(nil) 1179 assert( c.isSetNotes() == false ) 1180 if (c.getNotes() != nil) 1181 end 1182 c.setNotes(node) 1183 assert( c.isSetNotes() == true ) 1184 token = LibSBML::XMLToken.new("(CR) ¨ ¨ ¨ (NOT CR) &#; &#x; �a8; ¨ ¨") 1185 node = LibSBML::XMLNode.new(token) 1186 c.setNotes(node) 1187 t1 = c.getNotes() 1188 assert( t1.getNumChildren() == 1 ) 1189 s = t1.getChild(0).toXMLString() 1190 expected = "(CR) ¨ ¨ ¨ (NOT CR) &#; &#x; &#00a8; &#0168 &#x00a8"; 1191 assert (( expected == s )) 1192 token = LibSBML::XMLToken.new("& ' > < \" & ' > < "") 1193 node = LibSBML::XMLNode.new(token) 1194 c.setNotes(node) 1195 t1 = c.getNotes() 1196 assert( t1.getNumChildren() == 1 ) 1197 s2 = t1.getChild(0).toXMLString() 1198 expected2 = "& ' > < " & ' > < ""; 1199 assert (( expected2 == s2 )) 1200 token = nil 1201 node = nil 1202 end 1203 1204 def test_SBase_setNotesString 1205 c = LibSBML::Model.new(1,2) 1206 notes = "This is a test note"; 1207 taggednotes = "<notes>This is a test note</notes>"; 1208 c.setNotes(notes) 1209 assert( c.isSetNotes() == true ) 1210 if (( taggednotes != c.getNotesString() )) 1211 end 1212 t1 = c.getNotes() 1213 assert( t1.getNumChildren() == 1 ) 1214 t2 = t1.getChild(0) 1215 assert (( "This is a test note" == t2.getCharacters() )) 1216 c.setNotes(c.getNotesString()) 1217 t1 = c.getNotes() 1218 assert( t1.getNumChildren() == 1 ) 1219 chars = c.getNotesString() 1220 assert (( taggednotes == chars )) 1221 c.setNotes("") 1222 assert( c.isSetNotes() == false ) 1223 if (c.getNotesString() != nil) 1224 end 1225 c.setNotes(taggednotes) 1226 assert( c.isSetNotes() == true ) 1227 if (( taggednotes != c.getNotesString() )) 1228 end 1229 t1 = c.getNotes() 1230 assert( t1.getNumChildren() == 1 ) 1231 t2 = t1.getChild(0) 1232 assert (( "This is a test note" == t2.getCharacters() )) 1233 end 1234 1235 def test_SBase_setNotesString_l3 1236 c = LibSBML::Model.new(3,1) 1237 notes = "This is a test note"; 1238 c.setNotes(notes) 1239 assert( c.isSetNotes() == false ) 1240 end 1241 1242 def test_SBase_setNotesString_l3_addMarkup 1243 c = LibSBML::Model.new(3,1) 1244 notes = "This is a test note"; 1245 taggednotes = "<notes>\n" + 1246 " <p xmlns=\"http://www.w3.org/1999/xhtml\">" + 1247 "This is a test note</p>\n" + 1248 "</notes>" 1249 c.setNotes(notes, true) 1250 assert( c.isSetNotes() == true ) 1251 if (( taggednotes != c.getNotesString() )) 1252 end 1253 t1 = c.getNotes() 1254 assert( t1.getNumChildren() == 1 ) 1255 t2 = t1.getChild(0) 1256 assert( t2.getNumChildren() == 1 ) 1257 t3 = t2.getChild(0) 1258 assert (( "This is a test note" == t3.getCharacters() )) 1259 c.setNotes(c.getNotesString(), true) 1260 t1 = c.getNotes() 1261 assert( t1.getNumChildren() == 1 ) 1262 chars = c.getNotesString() 1263 assert (( taggednotes == chars )) 1264 c.setNotes("", true) 1265 assert( c.isSetNotes() == false ) 1266 if (c.getNotesString() != nil) 1267 end 1268 c.setNotes(taggednotes, true) 1269 assert( c.isSetNotes() == true ) 1270 if (( taggednotes != c.getNotesString() )) 1271 end 1272 t1 = c.getNotes() 1273 assert( t1.getNumChildren() == 1 ) 1274 t2 = t1.getChild(0) 1275 assert( t2.getNumChildren() == 1 ) 1276 t3 = t2.getChild(0) 1277 assert (( "This is a test note" == t3.getCharacters() )) 1278 end 1279 1280 def test_SBase_unsetAnnotationWithCVTerms 1281 annt = "<annotation>\n" + 1282 " <test:test xmlns:test=\"http://test.org/test\">this is a test node</test:test>\n" + 1283 "</annotation>" 1284 annt_with_cvterm = "<annotation>\n" + 1285 " <test:test xmlns:test=\"http://test.org/test\">this is a test node</test:test>\n" + 1286 " <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" " + 1287 "xmlns:dc=\"http://purl.org/dc/elements/1.1/\" " + 1288 "xmlns:dcterms=\"http://purl.org/dc/terms/\" " + 1289 "xmlns:vCard=\"http://www.w3.org/2001/vcard-rdf/3.0#\" " + 1290 "xmlns:bqbiol=\"http://biomodels.net/biology-qualifiers/\" " + 1291 "xmlns:bqmodel=\"http://biomodels.net/model-qualifiers/\">\n" + 1292 " <rdf:Description rdf:about=\"#_000001\">\n" + 1293 " <bqbiol:is>\n" + 1294 " <rdf:Bag>\n" + 1295 " <rdf:li rdf:resource=\"http://www.geneontology.org/#GO:0005895\"/>\n" + 1296 " </rdf:Bag>\n" + 1297 " </bqbiol:is>\n" + 1298 " </rdf:Description>\n" + 1299 " </rdf:RDF>\n" + 1300 "</annotation>" 1301 @@s.setAnnotation(annt) 1302 assert( @@s.isSetAnnotation() == true ) 1303 assert (( annt == @@s.getAnnotationString() )) 1304 @@s.unsetAnnotation() 1305 assert( @@s.isSetAnnotation() == false ) 1306 assert( @@s.getAnnotation() == nil ) 1307 @@s.setAnnotation(annt) 1308 @@s.setMetaId( "_000001") 1309 cv = LibSBML::CVTerm.new(LibSBML::BIOLOGICAL_QUALIFIER) 1310 cv.setBiologicalQualifierType(LibSBML::BQB_IS) 1311 cv.addResource( "http://www.geneontology.org/#GO:0005895") 1312 @@s.addCVTerm(cv) 1313 assert( @@s.isSetAnnotation() == true ) 1314 assert (( annt_with_cvterm == @@s.getAnnotationString() )) 1315 @@s.unsetAnnotation() 1316 assert( @@s.isSetAnnotation() == false ) 1317 assert( @@s.getAnnotation() == nil ) 1318 cv = nil 1319 end 1320 1321 def test_SBase_unsetAnnotationWithModelHistory 1322 h = LibSBML::ModelHistory.new() 1323 c = LibSBML::ModelCreator.new() 1324 annt = "<annotation>\n" + 1325 " <test:test xmlns:test=\"http://test.org/test\">this is a test node</test:test>\n" + 1326 "</annotation>" 1327 annt_with_modelhistory = "<annotation>\n" + 1328 " <test:test xmlns:test=\"http://test.org/test\">this is a test node</test:test>\n" + 1329 " <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" " + 1330 "xmlns:dc=\"http://purl.org/dc/elements/1.1/\" " + 1331 "xmlns:dcterms=\"http://purl.org/dc/terms/\" " + 1332 "xmlns:vCard=\"http://www.w3.org/2001/vcard-rdf/3.0#\" " + 1333 "xmlns:bqbiol=\"http://biomodels.net/biology-qualifiers/\" " + 1334 "xmlns:bqmodel=\"http://biomodels.net/model-qualifiers/\">\n" + 1335 " <rdf:Description rdf:about=\"#_000001\">\n" + 1336 " <dc:creator>\n" + 1337 " <rdf:Bag>\n" + 1338 " <rdf:li rdf:parseType=\"Resource\">\n" + 1339 " <vCard:N rdf:parseType=\"Resource\">\n" + 1340 " <vCard:Family>Keating</vCard:Family>\n" + 1341 " <vCard:Given>Sarah</vCard:Given>\n" + 1342 " </vCard:N>\n" + 1343 " <vCard:EMAIL>sbml-team@caltech.edu</vCard:EMAIL>\n" + 1344 " </rdf:li>\n" + 1345 " </rdf:Bag>\n" + 1346 " </dc:creator>\n" + 1347 " <dcterms:created rdf:parseType=\"Resource\">\n" + 1348 " <dcterms:W3CDTF>2005-12-29T12:15:45+02:00</dcterms:W3CDTF>\n" + 1349 " </dcterms:created>\n" + 1350 " <dcterms:modified rdf:parseType=\"Resource\">\n" + 1351 " <dcterms:W3CDTF>2005-12-30T12:15:45+02:00</dcterms:W3CDTF>\n" + 1352 " </dcterms:modified>\n" + 1353 " </rdf:Description>\n" + 1354 " </rdf:RDF>\n" + 1355 "</annotation>" 1356 @@s.setAnnotation(annt) 1357 assert( @@s.isSetAnnotation() == true ) 1358 assert (( annt == @@s.getAnnotationString() )) 1359 @@s.unsetAnnotation() 1360 assert( @@s.isSetAnnotation() == false ) 1361 assert( @@s.getAnnotation() == nil ) 1362 @@s.setAnnotation(annt) 1363 @@s.setMetaId( "_000001") 1364 c.setFamilyName("Keating") 1365 c.setGivenName("Sarah") 1366 c.setEmail("sbml-team@caltech.edu") 1367 h.addCreator(c) 1368 dc = LibSBML::Date.new(2005,12,29,12,15,45,1,2,0) 1369 h.setCreatedDate(dc) 1370 dm = LibSBML::Date.new(2005,12,30,12,15,45,1,2,0) 1371 h.setModifiedDate(dm) 1372 @@s.setModelHistory(h) 1373 assert( @@s.isSetAnnotation() == true ) 1374 assert (( annt_with_modelhistory == @@s.getAnnotationString() )) 1375 @@s.unsetAnnotation() 1376 assert( @@s.isSetAnnotation() == false ) 1377 assert( @@s.getAnnotation() == nil ) 1378 c = nil 1379 h = nil 1380 end 1381 1382 def test_SBase_unsetCVTerms 1383 cv = LibSBML::CVTerm.new(LibSBML::BIOLOGICAL_QUALIFIER) 1384 cv.setBiologicalQualifierType(LibSBML::BQB_ENCODES) 1385 cv.addResource( "foo") 1386 @@s.setMetaId( "sbase1") 1387 @@s.addCVTerm(cv) 1388 cv1 = LibSBML::CVTerm.new(LibSBML::BIOLOGICAL_QUALIFIER) 1389 cv1.setBiologicalQualifierType(LibSBML::BQB_IS) 1390 cv1.addResource( "bar") 1391 @@s.addCVTerm(cv1) 1392 cv2 = LibSBML::CVTerm.new(LibSBML::BIOLOGICAL_QUALIFIER) 1393 cv2.setBiologicalQualifierType(LibSBML::BQB_IS) 1394 cv2.addResource( "bar1") 1395 @@s.addCVTerm(cv2) 1396 cv4 = LibSBML::CVTerm.new(LibSBML::BIOLOGICAL_QUALIFIER) 1397 cv4.setBiologicalQualifierType(LibSBML::BQB_IS) 1398 cv4.addResource( "bar1") 1399 @@s.addCVTerm(cv4) 1400 assert( @@s.getNumCVTerms() == 2 ) 1401 @@s.unsetCVTerms() 1402 assert( @@s.getNumCVTerms() == 0 ) 1403 assert( @@s.getCVTerms() == nil ) 1404 cv = nil 1405 cv2 = nil 1406 cv1 = nil 1407 cv4 = nil 1408 end 1409 1410end 1411 1412