miga-base 0.6.4.2 → 0.7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/miga/cli/action/daemon.rb +4 -7
- data/lib/miga/cli/action/lair.rb +25 -15
- data/lib/miga/common/with_daemon.rb +203 -0
- data/lib/miga/common/with_daemon_class.rb +32 -0
- data/lib/miga/daemon.rb +51 -94
- data/lib/miga/daemon/base.rb +0 -18
- data/lib/miga/lair.rb +62 -73
- data/lib/miga/metadata.rb +12 -0
- data/lib/miga/version.rb +2 -2
- data/test/common_test.rb +4 -4
- data/test/daemon_test.rb +64 -51
- data/test/dataset_test.rb +25 -25
- data/test/hook_test.rb +4 -4
- data/test/json_test.rb +2 -2
- data/test/lair_test.rb +93 -0
- data/test/metadata_test.rb +4 -4
- data/test/project_test.rb +12 -14
- data/test/remote_dataset_test.rb +6 -6
- data/test/result_stats_test.rb +2 -2
- data/test/tax_dist_test.rb +5 -5
- data/test/tax_index_test.rb +5 -5
- data/test/taxonomy_test.rb +3 -3
- data/test/with_daemon_test.rb +158 -0
- metadata +7 -3
data/test/dataset_test.rb
CHANGED
@@ -19,25 +19,25 @@ class DatasetTest < Test::Unit::TestCase
|
|
19
19
|
|
20
20
|
def test_known_types
|
21
21
|
assert_respond_to(MiGA::Dataset, :KNOWN_TYPES)
|
22
|
-
assert
|
22
|
+
assert { MiGA::Dataset.KNOWN_TYPES.has_key?(:genome) }
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_exist
|
26
26
|
assert_respond_to(MiGA::Dataset, :exist?)
|
27
|
-
assert
|
28
|
-
assert
|
27
|
+
assert { MiGA::Dataset.exist?($p1, 'dataset1') }
|
28
|
+
assert { !MiGA::Dataset.exist?($p1, 'Nope') }
|
29
29
|
end
|
30
30
|
|
31
31
|
def test_info_fields
|
32
32
|
assert_respond_to(MiGA::Dataset, :INFO_FIELDS)
|
33
|
-
assert
|
33
|
+
assert { MiGA::Dataset.INFO_FIELDS.include?('name') }
|
34
34
|
end
|
35
35
|
|
36
36
|
def test_initialize
|
37
37
|
assert_raise { MiGA::Dataset.new($p1, 'dataset-1') }
|
38
38
|
assert_equal($p1, $d1.project)
|
39
39
|
assert_equal('dataset1', $d1.name)
|
40
|
-
|
40
|
+
assert_predicate($d1, :is_ref?)
|
41
41
|
assert_equal(MiGA::Metadata, $d1.metadata.class)
|
42
42
|
end
|
43
43
|
|
@@ -45,21 +45,21 @@ class DatasetTest < Test::Unit::TestCase
|
|
45
45
|
d2 = $p1.add_dataset('ds_save')
|
46
46
|
assert_respond_to(d2, :save)
|
47
47
|
d2.save
|
48
|
-
|
49
|
-
|
48
|
+
assert_not_predicate(d2, :is_multi?)
|
49
|
+
assert_not_predicate(d2, :is_nonmulti?)
|
50
50
|
assert_nil(d2.metadata[:type])
|
51
51
|
d2.metadata[:type] = :metagenome
|
52
52
|
d2.save
|
53
53
|
assert_equal(:metagenome, d2.metadata[:type])
|
54
|
-
|
55
|
-
|
54
|
+
assert_predicate(d2, :is_multi?)
|
55
|
+
assert_not_predicate(d2, :is_nonmulti?)
|
56
56
|
end
|
57
57
|
|
58
58
|
def test_remove
|
59
59
|
d2 = $p1.add_dataset('ds_remove')
|
60
|
-
|
60
|
+
assert_path_exist(d2.metadata.path)
|
61
61
|
d2.remove!
|
62
|
-
|
62
|
+
assert_path_not_exist(d2.metadata.path)
|
63
63
|
end
|
64
64
|
|
65
65
|
def test_info
|
@@ -82,7 +82,7 @@ class DatasetTest < Test::Unit::TestCase
|
|
82
82
|
d2 = $p1.add_dataset('ds_preprocessing')
|
83
83
|
assert_nil(d2.first_preprocessing)
|
84
84
|
assert_nil(d2.next_preprocessing)
|
85
|
-
|
85
|
+
assert_not_predicate(d2, :done_preprocessing?)
|
86
86
|
FileUtils.touch(File.expand_path(
|
87
87
|
"data/02.trimmed_reads/#{d2.name}.1.clipped.fastq", $p1.path
|
88
88
|
))
|
@@ -91,26 +91,26 @@ class DatasetTest < Test::Unit::TestCase
|
|
91
91
|
))
|
92
92
|
assert_equal(:trimmed_reads, d2.first_preprocessing(true))
|
93
93
|
assert_equal(:read_quality, d2.next_preprocessing(true))
|
94
|
-
assert
|
94
|
+
assert { !d2.done_preprocessing?(true) }
|
95
95
|
# Ref and undeclared multi
|
96
|
-
assert
|
97
|
-
assert
|
98
|
-
assert
|
96
|
+
assert { d2.ignore_task?(:mytaxa) }
|
97
|
+
assert { d2.ignore_task?(:mytaxa_scan) }
|
98
|
+
assert { d2.ignore_task?(:distances) }
|
99
99
|
# Ref and multi
|
100
100
|
d2.metadata[:type] = :metagenome
|
101
|
-
assert
|
102
|
-
assert
|
103
|
-
assert
|
101
|
+
assert { !d2.ignore_task?(:mytaxa) }
|
102
|
+
assert { d2.ignore_task?(:mytaxa_scan) }
|
103
|
+
assert { d2.ignore_task?(:distances) }
|
104
104
|
# Ref and nonmulti
|
105
105
|
d2.metadata[:type] = :genome
|
106
|
-
assert
|
107
|
-
assert
|
108
|
-
assert
|
106
|
+
assert { d2.ignore_task?(:mytaxa) }
|
107
|
+
assert { !d2.ignore_task?(:mytaxa_scan) }
|
108
|
+
assert { !d2.ignore_task?(:distances) }
|
109
109
|
# Qry and nonmulti
|
110
110
|
d2.metadata[:ref] = false
|
111
|
-
assert
|
112
|
-
assert
|
113
|
-
assert
|
111
|
+
assert { d2.ignore_task?(:mytaxa) }
|
112
|
+
assert { d2.ignore_task?(:mytaxa_scan) }
|
113
|
+
assert { !d2.ignore_task?(:distances) }
|
114
114
|
end
|
115
115
|
|
116
116
|
def test_profile_advance
|
data/test/hook_test.rb
CHANGED
@@ -78,18 +78,18 @@ class HookTest < Test::Unit::TestCase
|
|
78
78
|
def test_dataset_run_cmd
|
79
79
|
f = File.expand_path('hook_ds_cmd', $tmp)
|
80
80
|
$d1.metadata[:on_remove] = [[:run_cmd, "echo {{dataset}} > '#{f}'"]]
|
81
|
-
|
81
|
+
assert_path_not_exist(f)
|
82
82
|
$d1.remove!
|
83
|
-
|
83
|
+
assert_path_exist(f)
|
84
84
|
assert_equal($d1.name, File.read(f).chomp)
|
85
85
|
end
|
86
86
|
|
87
87
|
def test_project_run_cmd
|
88
88
|
f = File.expand_path('hook_pr_cmd', $tmp)
|
89
89
|
$p1.add_hook(:on_save, :run_cmd, "echo {{project}} > '#{f}'")
|
90
|
-
|
90
|
+
assert_path_not_exist(f)
|
91
91
|
$p1.save
|
92
|
-
|
92
|
+
assert_path_exist(f)
|
93
93
|
assert_equal($p1.path, File.read(f).chomp)
|
94
94
|
end
|
95
95
|
|
data/test/json_test.rb
CHANGED
@@ -4,11 +4,11 @@ class JsonTest < Test::Unit::TestCase
|
|
4
4
|
|
5
5
|
def test_parse
|
6
6
|
assert_equal(
|
7
|
-
{a: 1, b: 2},
|
7
|
+
{ a: 1, b: 2 },
|
8
8
|
MiGA::Json.parse('{"a": 1, "b": 2}', contents: true)
|
9
9
|
)
|
10
10
|
assert_equal(
|
11
|
-
{'a' => 1, 'b' => 2},
|
11
|
+
{ 'a' => 1, 'b' => 2 },
|
12
12
|
MiGA::Json.parse('{"a": 1, "b": 2}', contents: true, symbolize: false)
|
13
13
|
)
|
14
14
|
assert_equal(1.0, MiGA::Json.parse('1.0', contents: true))
|
data/test/lair_test.rb
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'miga/lair'
|
3
|
+
|
4
|
+
class LairTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
$jruby_tests = !ENV['JRUBY_TESTS'].nil?
|
8
|
+
$tmp = Dir.mktmpdir
|
9
|
+
ENV['MIGA_HOME'] = $tmp
|
10
|
+
FileUtils.touch(File.expand_path('.miga_rc', ENV['MIGA_HOME']))
|
11
|
+
daemon_json = File.expand_path('.miga_daemon.json', ENV['MIGA_HOME'])
|
12
|
+
File.open(daemon_json, 'w') do |fh|
|
13
|
+
fh.puts '{"maxjobs":1,"ppn":1,"latency":1,"varsep":" ",
|
14
|
+
"var":"{{key}}={{value}}","cmd":"echo {{task_name}} >/dev/null",
|
15
|
+
"alive":"echo 1 # {{pid}}","type":"bash","format_version":1}'
|
16
|
+
end
|
17
|
+
Dir.mkdir(File.join($tmp, 'sub'))
|
18
|
+
$p1 = MiGA::Project.new(File.join($tmp, 'project1'))
|
19
|
+
$p2 = MiGA::Project.new(File.join($tmp, 'project2'))
|
20
|
+
$p3 = MiGA::Project.new(File.join($tmp, 'sub/project3'))
|
21
|
+
end
|
22
|
+
|
23
|
+
def teardown
|
24
|
+
FileUtils.rm_rf $tmp
|
25
|
+
ENV['MIGA_HOME'] = nil
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_lair_init
|
29
|
+
path = $tmp
|
30
|
+
lair = MiGA::Lair.new(path, name: 'Alt-X')
|
31
|
+
assert_equal(MiGA::Lair, lair.class)
|
32
|
+
assert_equal(path, lair.path)
|
33
|
+
assert_equal(path, lair.daemon_home)
|
34
|
+
assert_equal('MiGA:Alt-X', lair.daemon_name)
|
35
|
+
assert_equal(lair.daemon_home, MiGA::Lair.daemon_home(lair.daemon_home))
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_in_loop
|
39
|
+
omit_if($jruby_tests, 'JRuby doesn\'t implement fork.')
|
40
|
+
lair = MiGA::Lair.new($tmp, name: 'Oh')
|
41
|
+
omit_if($jruby_tests, 'JRuby doesn\'t implement fork.')
|
42
|
+
child = lair.start(['--shush'])
|
43
|
+
assert_not_nil(child)
|
44
|
+
assert_gt(child, 0, 'The daemon process should have non-zero PID')
|
45
|
+
sleep(2)
|
46
|
+
capture_stderr { lair.stop }
|
47
|
+
assert_raise(Errno::ESRCH) { Process.kill(0, child) }
|
48
|
+
assert_nil(lair.declare_alive_pid)
|
49
|
+
assert_path_exist(lair.output_file)
|
50
|
+
l = File.readlines(lair.output_file)
|
51
|
+
assert_match(/-{20}\n/, l[0])
|
52
|
+
assert_match(/MiGA:Oh launched\n/, l[1])
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_first_loop
|
56
|
+
lair = MiGA::Lair.new($tmp, name: 'Ew')
|
57
|
+
out = capture_stderr { lair.daemon_first_loop }.string
|
58
|
+
assert_match(/-{20}/, out)
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_loop
|
62
|
+
lair = MiGA::Lair.new($tmp, name: 'Ew', latency: 1, dry: true)
|
63
|
+
out = capture_stderr { assert { !lair.daemon_loop } }.string
|
64
|
+
assert_match(/Launching daemon: \S*project1/, out)
|
65
|
+
assert_match(/Launching daemon: \S*project2/, out)
|
66
|
+
assert_match(/Launching daemon: \S*sub\/project3/, out)
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_daemon_launch
|
70
|
+
lair = MiGA::Lair.new(File.join($tmp, 'sub'), latency: 1)
|
71
|
+
p = MiGA::Project.load(File.join(lair.path, 'project3'))
|
72
|
+
d = MiGA::Daemon.new(p)
|
73
|
+
assert_not_predicate(d, :active?)
|
74
|
+
assert_path_exist(d.daemon_home)
|
75
|
+
|
76
|
+
omit_if($jruby_tests, 'JRuby doesn\'t implement fork.')
|
77
|
+
capture_stdout do
|
78
|
+
FileUtils.touch(d.output_file) # <- To prevent test racing
|
79
|
+
out = capture_stderr { lair.check_directories }.string
|
80
|
+
assert_match(/Launching daemon: \S+project3/, out)
|
81
|
+
assert_predicate(d, :active?)
|
82
|
+
end
|
83
|
+
|
84
|
+
out = capture_stderr { lair.terminate_daemons }.string
|
85
|
+
assert_match(/Probing MiGA::Daemon/, out)
|
86
|
+
assert_match(/Sending termination message/, out)
|
87
|
+
sleep(2)
|
88
|
+
assert_not_predicate(d, :active?)
|
89
|
+
|
90
|
+
out = capture_stderr { assert { lair.daemon_loop } }.string
|
91
|
+
assert_equal('', out)
|
92
|
+
end
|
93
|
+
end
|
data/test/metadata_test.rb
CHANGED
@@ -23,8 +23,8 @@ class MetadataTest < Test::Unit::TestCase
|
|
23
23
|
t1 = Time.new
|
24
24
|
md1.save
|
25
25
|
t2 = Time.new
|
26
|
-
|
27
|
-
|
26
|
+
assert_path_not_exist(md1.lock_file)
|
27
|
+
assert_ge(t2 - t1, 1.0)
|
28
28
|
end
|
29
29
|
|
30
30
|
def test_load
|
@@ -41,8 +41,8 @@ class MetadataTest < Test::Unit::TestCase
|
|
41
41
|
md1.load
|
42
42
|
t2 = Time.new
|
43
43
|
assert_equal(2, md1[:t])
|
44
|
-
|
45
|
-
|
44
|
+
assert_path_not_exist(md1.lock_file)
|
45
|
+
assert_ge(t2 - t1, 1.0)
|
46
46
|
end
|
47
47
|
|
48
48
|
end
|
data/test/project_test.rb
CHANGED
@@ -33,7 +33,7 @@ class ProjectTest < Test::Unit::TestCase
|
|
33
33
|
|
34
34
|
def test_create
|
35
35
|
assert_equal("#{$tmp}/create", MiGA::Project.new("#{$tmp}/create").path)
|
36
|
-
|
36
|
+
assert_path_exist("#{$tmp}/create")
|
37
37
|
assert_raise do
|
38
38
|
ENV['MIGA_HOME'] = $tmp + '/chez-moi'
|
39
39
|
MiGA::Project.new($tmp + '/cuckoo')
|
@@ -67,25 +67,23 @@ class ProjectTest < Test::Unit::TestCase
|
|
67
67
|
|
68
68
|
def test_import_dataset
|
69
69
|
p1 = $p1
|
70
|
-
|
70
|
+
d = p1.add_dataset('d1')
|
71
71
|
File.open(
|
72
|
-
"#{p1.path}/data/01.raw_reads/#{
|
72
|
+
"#{p1.path}/data/01.raw_reads/#{d.name}.1.fastq", 'w'
|
73
73
|
) { |f| f.puts ':-)' }
|
74
74
|
File.open(
|
75
|
-
"#{p1.path}/data/01.raw_reads/#{
|
75
|
+
"#{p1.path}/data/01.raw_reads/#{d.name}.done", 'w'
|
76
76
|
) { |f| f.puts ':-)' }
|
77
|
-
|
77
|
+
d.next_preprocessing(true)
|
78
78
|
p2 = MiGA::Project.new(File.expand_path('import_dataset', $tmp))
|
79
|
-
|
79
|
+
assert_empty(p2.datasets)
|
80
80
|
assert_nil(p2.dataset('d1'))
|
81
|
-
p2.import_dataset(
|
81
|
+
p2.import_dataset(d)
|
82
82
|
assert_equal(1, p2.datasets.size)
|
83
83
|
assert_equal(MiGA::Dataset, p2.dataset('d1').class)
|
84
84
|
assert_equal(1, p2.dataset('d1').results.size)
|
85
|
-
|
86
|
-
|
87
|
-
)
|
88
|
-
assert(File.exist?(File.join(p2.path, "metadata/#{d1.name}.json")))
|
85
|
+
assert_path_exist(File.join(p2.path, "data/01.raw_reads/#{d.name}.1.fastq"))
|
86
|
+
assert_path_exist(File.join(p2.path, "metadata/#{d.name}.json"))
|
89
87
|
end
|
90
88
|
|
91
89
|
def test_add_result
|
@@ -113,11 +111,11 @@ class ProjectTest < Test::Unit::TestCase
|
|
113
111
|
|
114
112
|
def test_preprocessing
|
115
113
|
p1 = $p1
|
116
|
-
|
114
|
+
assert_predicate(p1, :done_preprocessing?)
|
117
115
|
d1 = p1.add_dataset('BAH')
|
118
|
-
|
116
|
+
assert_not_predicate(p1, :done_preprocessing?)
|
119
117
|
FileUtils.touch(File.expand_path("data/90.stats/#{d1.name}.done", p1.path))
|
120
|
-
|
118
|
+
assert_predicate(p1, :done_preprocessing?)
|
121
119
|
assert_nil(p1.next_inclade)
|
122
120
|
p1.metadata[:type] = :clade
|
123
121
|
assert_equal(:subclades, p1.next_inclade)
|
data/test/remote_dataset_test.rb
CHANGED
@@ -20,7 +20,7 @@ class RemoteDatasetTest < Test::Unit::TestCase
|
|
20
20
|
|
21
21
|
def test_class_universe
|
22
22
|
assert_respond_to(MiGA::RemoteDataset, :UNIVERSE)
|
23
|
-
|
23
|
+
assert_include(MiGA::RemoteDataset.UNIVERSE.keys, :ebi)
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_bad_remote_dataset
|
@@ -89,26 +89,26 @@ class RemoteDatasetTest < Test::Unit::TestCase
|
|
89
89
|
def test_type_status_asm
|
90
90
|
omit_if(!$remote_tests, 'Remote access is error-prone')
|
91
91
|
rd = MiGA::RemoteDataset.new('GCF_000018105.1', :assembly, :ncbi)
|
92
|
-
assert
|
92
|
+
assert { rd.get_metadata[:is_type] }
|
93
93
|
end
|
94
94
|
|
95
95
|
def test_nontype_status_asm
|
96
96
|
omit_if(!$remote_tests, 'Remote access is error-prone')
|
97
97
|
rd = MiGA::RemoteDataset.new('GCA_004684205.1', :assembly, :ncbi)
|
98
|
-
assert
|
98
|
+
assert { !rd.get_metadata[:is_type] }
|
99
99
|
end
|
100
100
|
|
101
101
|
def test_type_status_nuccore
|
102
102
|
omit_if(!$remote_tests, 'Remote access is error-prone')
|
103
103
|
rd = MiGA::RemoteDataset.new('NC_019748.1', :nuccore, :ncbi)
|
104
|
-
assert
|
104
|
+
assert { rd.get_metadata[:is_type] }
|
105
105
|
end
|
106
106
|
|
107
107
|
def test_ref_type_status
|
108
108
|
omit_if(!$remote_tests, 'Remote access is error-prone')
|
109
109
|
rd = MiGA::RemoteDataset.new('GCA_002849345', :assembly, :ncbi)
|
110
|
-
assert
|
111
|
-
assert
|
110
|
+
assert { !rd.get_metadata[:is_type] }
|
111
|
+
assert { rd.get_metadata[:is_ref_type] }
|
112
112
|
end
|
113
113
|
|
114
114
|
# This test is too expensive (too much time to run it!)
|
data/test/result_stats_test.rb
CHANGED
@@ -33,7 +33,7 @@ class ResultStatsTest < Test::Unit::TestCase
|
|
33
33
|
r = $d.add_result(:raw_reads)
|
34
34
|
assert_equal({}, r[:stats])
|
35
35
|
r.compute_stats
|
36
|
-
|
36
|
+
assert_not_empty(r[:stats])
|
37
37
|
assert_equal(Hash, r[:stats].class)
|
38
38
|
assert_equal(1, r[:stats][:reads])
|
39
39
|
assert_equal([40.0, '%'], r[:stats][:g_c_content])
|
@@ -48,7 +48,7 @@ class ResultStatsTest < Test::Unit::TestCase
|
|
48
48
|
touch_done(dir)
|
49
49
|
r = $d.add_result(:raw_reads)
|
50
50
|
r.compute_stats
|
51
|
-
|
51
|
+
assert_not_empty(r[:stats])
|
52
52
|
assert_nil(r[:stats][:reads])
|
53
53
|
assert_equal(1, r[:stats][:read_pairs])
|
54
54
|
assert_equal([40.0, '%'], r[:stats][:reverse_g_c_content])
|
data/test/tax_dist_test.rb
CHANGED
@@ -4,11 +4,11 @@ require 'miga/tax_dist'
|
|
4
4
|
class TaxDistTest < Test::Unit::TestCase
|
5
5
|
|
6
6
|
def test_aai_path
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
assert_path_exist(MiGA::TaxDist.aai_path(:intax))
|
8
|
+
assert_path_exist(MiGA::TaxDist.aai_path(:novel))
|
9
|
+
assert_path_exist(MiGA::TaxDist.aai_path(:intax, engine: :diamond))
|
10
|
+
assert_path_exist(MiGA::TaxDist.aai_path(:novel, engine: :blast))
|
11
|
+
assert_path_exist(MiGA::TaxDist.aai_path(:novel, engine: :'blast+'))
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_aai_pvalues
|
data/test/tax_index_test.rb
CHANGED
@@ -17,12 +17,12 @@ class TaxIndexTest < Test::Unit::TestCase
|
|
17
17
|
d = p.add_dataset('dataset1')
|
18
18
|
|
19
19
|
ti = MiGA::TaxIndex.new
|
20
|
-
|
20
|
+
assert_empty(ti.datasets)
|
21
21
|
ti << d
|
22
|
-
|
22
|
+
assert_empty(ti.datasets, 'index should ignore datasets without tax')
|
23
23
|
d.metadata[:tax] = MiGA::Taxonomy.new('k:Fantasia g:Unicornia')
|
24
24
|
ti << d
|
25
|
-
assert_equal(1, ti.datasets.size, '
|
25
|
+
assert_equal(1, ti.datasets.size, 'index should have one dataset')
|
26
26
|
assert_equal(1, ti.root.datasets_count)
|
27
27
|
ensure
|
28
28
|
FileUtils.rm_rf $tmp
|
@@ -31,9 +31,9 @@ class TaxIndexTest < Test::Unit::TestCase
|
|
31
31
|
|
32
32
|
def test_to_json
|
33
33
|
js = JSON.parse(MiGA::TaxIndex.new.to_json)
|
34
|
-
|
34
|
+
assert_include(js.keys, 'datasets')
|
35
35
|
assert_equal(2, js.keys.size)
|
36
|
-
|
36
|
+
assert_empty(js['datasets'])
|
37
37
|
end
|
38
38
|
|
39
39
|
def test_to_tab
|
data/test/taxonomy_test.rb
CHANGED
@@ -5,7 +5,7 @@ class TaxonomyTest < Test::Unit::TestCase
|
|
5
5
|
|
6
6
|
def test_ranks
|
7
7
|
assert_respond_to(MiGA::Taxonomy, :KNOWN_RANKS)
|
8
|
-
|
8
|
+
assert_include(MiGA::Taxonomy.KNOWN_RANKS, :s)
|
9
9
|
assert_nil(MiGA::Taxonomy.normalize_rank 'No Rank')
|
10
10
|
assert_nil(MiGA::Taxonomy.normalize_rank 'Captain')
|
11
11
|
assert_equal(:f, MiGA::Taxonomy.normalize_rank(:Family))
|
@@ -41,7 +41,7 @@ class TaxonomyTest < Test::Unit::TestCase
|
|
41
41
|
tx << { genus: 'v3' }
|
42
42
|
assert_equal('v3', tx[:g])
|
43
43
|
tx << 's:v3_0'
|
44
|
-
assert
|
44
|
+
assert { tx.in? MiGA::Taxonomy.new('species:v3_0') }
|
45
45
|
assert_raise(RuntimeError) { tx << 123 }
|
46
46
|
end
|
47
47
|
|
@@ -89,7 +89,7 @@ class TaxonomyTest < Test::Unit::TestCase
|
|
89
89
|
# Delete
|
90
90
|
alt = tx.delete_alternative
|
91
91
|
assert_equal(4, alt.size)
|
92
|
-
|
92
|
+
assert_empty(tx.alternative)
|
93
93
|
end
|
94
94
|
|
95
95
|
def test_reset
|