1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
#
# test/unit/bio/test_db.rb - Unit test for Bio::DB
#
# Copyright:: Copyright (C) 2005 Mitsuteru Nakao <n@bioruby.org>
# License:: The Ruby License
#
#
# loading helper routine for testing bioruby
require 'pathname'
load Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 2,
'bioruby_test_helper.rb')).cleanpath.to_s
# libraries needed for the tests
require 'test/unit'
require 'bio/db'
module Bio
class TestDB < Test::Unit::TestCase
def setup
@obj = Bio::DB.new
@obj.instance_eval {
@orig = {"TAG" => "TAG value1\n value2"}
@tagsize = nil
}
end
def test_open
assert(Bio::DB.respond_to?(:open))
end
def test_entry_id
assert_raises(NotImplementedError) { @obj.entry_id }
end
def test_tags
assert_equal(["TAG"], @obj.tags)
end
def test_exists
assert_equal(true, @obj.exists?("TAG"))
end
def test_get
assert_equal("TAG value1\n value2", @obj.get("TAG"))
end
def test_fetch
assert(@obj.fetch("TAG"))
assert(@obj.fetch("TAG", 1))
end
end
class TestNCBIDB < Test::Unit::TestCase
def setup
entry =<<END
LOCUS locus
END
@obj = Bio::NCBIDB.new(entry, 10)
end
def test_fetch
assert_equal('locus', @obj.fetch("LOCUS"))
end
def test_p_toptag2array
end
def test_p_subtag2array
end
def test_p_entry2hash
end
end
# class TestKEGGDB < Test::Unit::TestCase
# end
class TestEMBLDB < Test::Unit::TestCase
def setup
@entry =<<END
ID id
XX
CC cc1
CC cc2
END
@obj = Bio::EMBLDB.new(@entry, 2)
end
def test_fetch
assert_equal('id', @obj.fetch("ID"))
assert_equal('cc1 cc2', @obj.fetch("CC"))
end
def test_p_entry2hash
end
end
end
|