unipept 1.4.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,14 +5,14 @@ module Unipept
5
5
  def test_help
6
6
  out, _err = capture_io_while do
7
7
  assert_raises SystemExit do
8
- Commands::Unipept.run(%w(-h))
8
+ Commands::Unipept.run(%w[-h])
9
9
  end
10
10
  end
11
11
  assert(out.include?('show help for this command'))
12
12
 
13
13
  out, _err = capture_io_while do
14
14
  assert_raises SystemExit do
15
- Commands::Unipept.run(%w(--help))
15
+ Commands::Unipept.run(%w[--help])
16
16
  end
17
17
  end
18
18
  assert(out.include?('show help for this command'))
@@ -21,7 +21,7 @@ module Unipept
21
21
  def test_no_valid_subcommand
22
22
  _out, err = capture_io_while do
23
23
  assert_raises SystemExit do
24
- Commands::Unipept.run(%w())
24
+ Commands::Unipept.run(%w[])
25
25
  end
26
26
  end
27
27
  assert(err.include?('show help for this command'))
@@ -29,7 +29,7 @@ module Unipept
29
29
 
30
30
  def test_version
31
31
  out, _err = capture_io_while do
32
- Commands::Unipept.run(%w(-v))
32
+ Commands::Unipept.run(%w[-v])
33
33
  end
34
34
  assert_equal(VERSION, out.chomp)
35
35
  end
@@ -4,56 +4,56 @@ module Unipept
4
4
  class UniprotTestCase < Unipept::TestCase
5
5
  def test_argument_input
6
6
  out, _err = capture_io_while do
7
- Commands::Uniprot.run(%w(Q6GZX3))
7
+ Commands::Uniprot.run(%w[Q6GZX3])
8
8
  end
9
9
  assert_equal(1, out.split(/\n/).length)
10
10
 
11
11
  out, _err = capture_io_while do
12
- Commands::Uniprot.run(%w(Q6GZX3 Q6GZX4))
12
+ Commands::Uniprot.run(%w[Q6GZX3 Q6GZX4])
13
13
  end
14
14
  assert_equal(2, out.split(/\n/).length)
15
15
 
16
16
  out, _err = capture_io_while do
17
- Commands::Uniprot.run(%w(-f fasta Q6GZX3 Q6GZX4))
17
+ Commands::Uniprot.run(%w[-f fasta Q6GZX3 Q6GZX4])
18
18
  end
19
19
  assert_equal(2, out.count('>'))
20
20
 
21
21
  out, _err = capture_io_while do
22
- Commands::Uniprot.run(%w(--format fasta Q6GZX3 Q6GZX4))
22
+ Commands::Uniprot.run(%w[--format fasta Q6GZX3 Q6GZX4])
23
23
  end
24
24
  assert_equal(2, out.count('>'))
25
25
  end
26
26
 
27
27
  def test_stdin_input
28
28
  out, _err = capture_io_with_input('Q6GZX3') do
29
- Commands::Uniprot.run(%w())
29
+ Commands::Uniprot.run(%w[])
30
30
  end
31
31
  assert_equal(1, out.split(/\n/).length)
32
32
 
33
- out, _err = capture_io_with_input(%w(Q6GZX3 Q6GZX4)) do
34
- Commands::Uniprot.run(%w())
33
+ out, _err = capture_io_with_input(%w[Q6GZX3 Q6GZX4]) do
34
+ Commands::Uniprot.run(%w[])
35
35
  end
36
36
  assert_equal(2, out.split(/\n/).length)
37
37
 
38
- out, _err = capture_io_with_input(%w(Q6GZX3 Q6GZX4)) do
39
- Commands::Uniprot.run(%w(-f fasta))
38
+ out, _err = capture_io_with_input(%w[Q6GZX3 Q6GZX4]) do
39
+ Commands::Uniprot.run(%w[-f fasta])
40
40
  end
41
41
  assert_equal(2, out.count('>'))
42
42
 
43
- out, _err = capture_io_with_input(%w(Q6GZX3 Q6GZX4)) do
44
- Commands::Uniprot.run(%w(--format fasta))
43
+ out, _err = capture_io_with_input(%w[Q6GZX3 Q6GZX4]) do
44
+ Commands::Uniprot.run(%w[--format fasta])
45
45
  end
46
46
  assert_equal(2, out.count('>'))
47
47
  end
48
48
 
49
49
  def test_argument_input_priority
50
50
  out, _err = capture_io_with_input('Q6GZX3') do
51
- Commands::Uniprot.run(%w(Q6GZX3 Q6GZX4))
51
+ Commands::Uniprot.run(%w[Q6GZX3 Q6GZX4])
52
52
  end
53
53
  assert_equal(2, out.split(/\n/).length)
54
54
 
55
- out, _err = capture_io_with_input(%w(Q6GZX3 Q6GZX4)) do
56
- Commands::Uniprot.run(%w(Q6GZX3))
55
+ out, _err = capture_io_with_input(%w[Q6GZX3 Q6GZX4]) do
56
+ Commands::Uniprot.run(%w[Q6GZX3])
57
57
  end
58
58
  assert_equal(1, out.split(/\n/).length)
59
59
  end
@@ -61,7 +61,7 @@ module Unipept
61
61
  def test_invalid_format
62
62
  out, err = capture_io_while do
63
63
  assert_raises SystemExit do
64
- Commands::Uniprot.run(%w(--format xxx))
64
+ Commands::Uniprot.run(%w[--format xxx])
65
65
  end
66
66
  end
67
67
  assert_equal('', out)
@@ -70,17 +70,17 @@ module Unipept
70
70
 
71
71
  def test_default_format
72
72
  out_default, _err = capture_io_while do
73
- Commands::Uniprot.run(%w(Q6GZX3))
73
+ Commands::Uniprot.run(%w[Q6GZX3])
74
74
  end
75
75
  assert_equal(1, out_default.split(/\n/).length)
76
76
 
77
77
  out_sequence, _err = capture_io_while do
78
- Commands::Uniprot.run(%w(-f sequence Q6GZX3))
78
+ Commands::Uniprot.run(%w[-f sequence Q6GZX3])
79
79
  end
80
80
  assert_equal(out_default, out_sequence)
81
81
 
82
82
  out_sequence, _err = capture_io_while do
83
- Commands::Uniprot.run(%w(--format sequence Q6GZX3))
83
+ Commands::Uniprot.run(%w[--format sequence Q6GZX3])
84
84
  end
85
85
  assert_equal(out_default, out_sequence)
86
86
  end
@@ -88,37 +88,37 @@ module Unipept
88
88
  def test_format_options
89
89
  # fasta txt xml rdf gff sequence
90
90
  out, err = capture_io_while do
91
- Commands::Uniprot.run(%w(-f fasta Q6GZX3))
91
+ Commands::Uniprot.run(%w[-f fasta Q6GZX3])
92
92
  end
93
93
  assert(!out.empty?)
94
94
  assert(err.empty?)
95
95
 
96
96
  out, err = capture_io_while do
97
- Commands::Uniprot.run(%w(-f txt Q6GZX3))
97
+ Commands::Uniprot.run(%w[-f txt Q6GZX3])
98
98
  end
99
99
  assert(!out.empty?)
100
100
  assert(err.empty?)
101
101
 
102
102
  out, err = capture_io_while do
103
- Commands::Uniprot.run(%w(-f xml Q6GZX3))
103
+ Commands::Uniprot.run(%w[-f xml Q6GZX3])
104
104
  end
105
105
  assert(!out.empty?)
106
106
  assert(err.empty?)
107
107
 
108
108
  out, err = capture_io_while do
109
- Commands::Uniprot.run(%w(-f rdf Q6GZX3))
109
+ Commands::Uniprot.run(%w[-f rdf Q6GZX3])
110
110
  end
111
111
  assert(!out.empty?)
112
112
  assert(err.empty?)
113
113
 
114
114
  out, err = capture_io_while do
115
- Commands::Uniprot.run(%w(-f gff Q6GZX3))
115
+ Commands::Uniprot.run(%w[-f gff Q6GZX3])
116
116
  end
117
117
  assert(!out.empty?)
118
118
  assert(err.empty?)
119
119
 
120
120
  out, err = capture_io_while do
121
- Commands::Uniprot.run(%w(-f sequence Q6GZX3))
121
+ Commands::Uniprot.run(%w[-f sequence Q6GZX3])
122
122
  end
123
123
  assert(!out.empty?)
124
124
  assert(err.empty?)
@@ -127,7 +127,7 @@ module Unipept
127
127
  def test_help
128
128
  out, _err = capture_io_while do
129
129
  assert_raises SystemExit do
130
- Commands::Uniprot.run(%w(-h))
130
+ Commands::Uniprot.run(%w[-h])
131
131
  end
132
132
  end
133
133
  assert(out.include?('show help for this command'))
@@ -8,17 +8,17 @@ module Unipept
8
8
 
9
9
  class UnipeptAPIRunnerTestCase < Unipept::TestCase
10
10
  def test_init
11
- runner = new_runner('test', { host: 'test_host' }, %w(a b c))
11
+ runner = new_runner('test', { host: 'test_host' }, %w[a b c])
12
12
  assert_equal('test', runner.command.name)
13
13
  assert_equal('test_host', runner.options[:host])
14
- assert_equal(%w(a b c), runner.arguments)
14
+ assert_equal(%w[a b c], runner.arguments)
15
15
  assert(!runner.configuration.nil?)
16
16
  assert_equal('http://test_host/api/v1/test.json', runner.url)
17
17
  assert(/Unipept CLI - unipept [0-9]*\.[0-9]*\.[0-9]*/.match runner.user_agent)
18
18
  end
19
19
 
20
20
  def test_config_host
21
- runner = new_runner('test', { host: 'http://param_host' }, %w(a b c))
21
+ runner = new_runner('test', { host: 'http://param_host' }, %w[a b c])
22
22
  runner.options.delete(:host)
23
23
  runner.configuration['host'] = 'http://config_host'
24
24
  host = runner.host
@@ -26,14 +26,14 @@ module Unipept
26
26
  end
27
27
 
28
28
  def test_param_host
29
- runner = new_runner('test', { host: 'http://param_host' }, %w(a b c))
29
+ runner = new_runner('test', { host: 'http://param_host' }, %w[a b c])
30
30
  runner.configuration.delete('host')
31
31
  host = runner.host
32
32
  assert_equal('http://param_host', host)
33
33
  end
34
34
 
35
35
  def test_no_host
36
- runner = new_runner('test', { host: 'param_host' }, %w(a b c))
36
+ runner = new_runner('test', { host: 'param_host' }, %w[a b c])
37
37
  runner.configuration.delete('host')
38
38
  runner.options.delete(:host)
39
39
  host = runner.host
@@ -41,66 +41,66 @@ module Unipept
41
41
  end
42
42
 
43
43
  def test_host_priority
44
- runner = new_runner('test', { host: 'http://param_host' }, %w(a b c))
44
+ runner = new_runner('test', { host: 'http://param_host' }, %w[a b c])
45
45
  runner.configuration['host'] = 'http://config_host'
46
46
  host = runner.host
47
47
  assert_equal('http://param_host', host)
48
48
  end
49
49
 
50
50
  def test_http_host
51
- runner = new_runner('test', { host: 'param_host' }, %w(a b c))
51
+ runner = new_runner('test', { host: 'param_host' }, %w[a b c])
52
52
  host = runner.host
53
53
  assert_equal('http://param_host', host)
54
54
  end
55
55
 
56
56
  def test_https_host
57
- runner = new_runner('test', { host: 'https://param_host' }, %w(a b c))
57
+ runner = new_runner('test', { host: 'https://param_host' }, %w[a b c])
58
58
  host = runner.host
59
59
  assert_equal('https://param_host', host)
60
60
  end
61
61
 
62
62
  def test_input_iterator_args
63
- runner = new_runner('test', { host: 'https://param_host' }, %w(a b c))
63
+ runner = new_runner('test', { host: 'https://param_host' }, %w[a b c])
64
64
  output = []
65
65
  runner.input_iterator.each { |el| output << el.chomp }
66
- assert_equal(%w(a b c), output)
66
+ assert_equal(%w[a b c], output)
67
67
  end
68
68
 
69
69
  def test_input_iterator_file
70
- File.open('input_file', 'w') { |file| file.write(%w(a b c).join("\n")) }
70
+ File.open('input_file', 'w') { |file| file.write(%w[a b c].join("\n")) }
71
71
  runner = new_runner('test', host: 'https://param_host', input: 'input_file')
72
72
  output = []
73
73
  runner.input_iterator.each { |el| output << el.chomp }
74
- assert_equal(%w(a b c), output)
74
+ assert_equal(%w[a b c], output)
75
75
  end
76
76
 
77
77
  def test_input_iterator_stdin
78
78
  runner = new_runner('test', host: 'https://param_host')
79
79
  output = []
80
- _out, _err = capture_io_with_input(%w(a b c)) do
80
+ _out, _err = capture_io_with_input(%w[a b c]) do
81
81
  runner.input_iterator.each { |el| output << el.chomp }
82
82
  end
83
- assert_equal(%w(a b c), output)
83
+ assert_equal(%w[a b c], output)
84
84
  end
85
85
 
86
86
  def test_input_iterator_arguments_priority
87
- File.open('input_file', 'w') { |file| file.write(%w(1 2 3).join("\n")) }
88
- runner = new_runner('test', { host: 'https://param_host', input: 'input_file' }, %w(a b c))
87
+ File.open('input_file', 'w') { |file| file.write(%w[1 2 3].join("\n")) }
88
+ runner = new_runner('test', { host: 'https://param_host', input: 'input_file' }, %w[a b c])
89
89
  output = []
90
- _out, _err = capture_io_with_input(%w(1 2 3)) do
90
+ _out, _err = capture_io_with_input(%w[1 2 3]) do
91
91
  runner.input_iterator.each { |el| output << el.chomp }
92
92
  end
93
- assert_equal(%w(a b c), output)
93
+ assert_equal(%w[a b c], output)
94
94
  end
95
95
 
96
96
  def test_input_iterator_file_priority
97
- File.open('input_file', 'w') { |file| file.write(%w(a b c).join("\n")) }
97
+ File.open('input_file', 'w') { |file| file.write(%w[a b c].join("\n")) }
98
98
  runner = new_runner('test', host: 'https://param_host', input: 'input_file')
99
99
  output = []
100
- _out, _err = capture_io_with_input(%w(1 2 3)) do
100
+ _out, _err = capture_io_with_input(%w[1 2 3]) do
101
101
  runner.input_iterator.each { |el| output << el.chomp }
102
102
  end
103
- assert_equal(%w(a b c), output)
103
+ assert_equal(%w[a b c], output)
104
104
  end
105
105
 
106
106
  def test_required_fields
@@ -199,7 +199,7 @@ module Unipept
199
199
  end
200
200
 
201
201
  def test_multiple_selected_fields
202
- runner = new_runner('test', host: 'http://param_host', select: %w(field1 field2))
202
+ runner = new_runner('test', host: 'http://param_host', select: %w[field1 field2])
203
203
  assert_equal([/^field1$/, /^field2$/], runner.selected_fields)
204
204
  end
205
205
 
@@ -348,7 +348,7 @@ module Unipept
348
348
  lambda = runner.handle_response(response, 0, nil)
349
349
  assert(lambda.lambda?)
350
350
  def runner.save_error(input)
351
- $stderr.puts(input)
351
+ warn(input)
352
352
  end
353
353
  out, err = capture_io_while(&lambda)
354
354
  assert_equal('', out)
@@ -361,7 +361,7 @@ module Unipept
361
361
  lambda = runner.handle_response(response, 0, nil)
362
362
  assert(lambda.lambda?)
363
363
  def runner.save_error(input)
364
- $stderr.puts(input)
364
+ warn(input)
365
365
  end
366
366
  out, err = capture_io_while(&lambda)
367
367
  assert_equal('', out)
@@ -374,7 +374,7 @@ module Unipept
374
374
  lambda = runner.handle_response(response, 0, nil)
375
375
  assert(lambda.lambda?)
376
376
  def runner.save_error(input)
377
- $stderr.puts(input)
377
+ warn(input)
378
378
  end
379
379
  out, err = capture_io_while(&lambda)
380
380
  assert_equal('', out)
@@ -385,7 +385,7 @@ module Unipept
385
385
  runner = new_runner('taxonomy', host: 'http://api.unipept.ugent.be')
386
386
  out, err = capture_io_while do
387
387
  def runner.input_iterator
388
- %w(0 1 2).each
388
+ %w[0 1 2].each
389
389
  end
390
390
 
391
391
  def runner.batch_size
@@ -5,14 +5,14 @@ module Unipept
5
5
  def test_help
6
6
  out, _err = capture_io_while do
7
7
  assert_raises SystemExit do
8
- Commands::Unipept.run(%w(config -h))
8
+ Commands::Unipept.run(%w[config -h])
9
9
  end
10
10
  end
11
11
  assert(out.include?('show help for this command'))
12
12
 
13
13
  out, _err = capture_io_while do
14
14
  assert_raises SystemExit do
15
- Commands::Unipept.run(%w(config --help))
15
+ Commands::Unipept.run(%w[config --help])
16
16
  end
17
17
  end
18
18
  assert(out.include?('show help for this command'))
@@ -21,7 +21,7 @@ module Unipept
21
21
  def test_no_args
22
22
  _out, err = capture_io_while do
23
23
  assert_raises SystemExit do
24
- Commands::Unipept.run(%w(config))
24
+ Commands::Unipept.run(%w[config])
25
25
  end
26
26
  end
27
27
  assert(err.include?('show help for this command'))
@@ -30,7 +30,7 @@ module Unipept
30
30
  def test_too_many_args
31
31
  _out, err = capture_io_while do
32
32
  assert_raises SystemExit do
33
- Commands::Unipept.run(%w(config a b c))
33
+ Commands::Unipept.run(%w[config a b c])
34
34
  end
35
35
  end
36
36
  assert(err.include?('show help for this command'))
@@ -54,7 +54,7 @@ module Unipept
54
54
  config['test'] = value
55
55
  config.save
56
56
  out, _err = capture_io_while do
57
- Commands::Unipept.run(%w(config test))
57
+ Commands::Unipept.run(%w[config test])
58
58
  end
59
59
  config.delete('test')
60
60
  config.save
@@ -31,14 +31,14 @@ module Unipept
31
31
  def test_help
32
32
  out, _err = capture_io_while do
33
33
  assert_raises SystemExit do
34
- Commands::Unipept.run(%w(pept2lca -h))
34
+ Commands::Unipept.run(%w[pept2lca -h])
35
35
  end
36
36
  end
37
37
  assert(out.include?('show help for this command'))
38
38
 
39
39
  out, _err = capture_io_while do
40
40
  assert_raises SystemExit do
41
- Commands::Unipept.run(%w(pept2lca --help))
41
+ Commands::Unipept.run(%w[pept2lca --help])
42
42
  end
43
43
  end
44
44
  assert(out.include?('show help for this command'))
@@ -46,7 +46,7 @@ module Unipept
46
46
 
47
47
  def test_run
48
48
  out, err = capture_io_while do
49
- Commands::Unipept.run(%w(pept2lca --host http://api.unipept.ugent.be AALTER))
49
+ Commands::Unipept.run(%w[pept2lca --host http://api.unipept.ugent.be AALTER])
50
50
  end
51
51
  lines = out.each_line
52
52
  assert_equal('', err)
@@ -57,7 +57,7 @@ module Unipept
57
57
 
58
58
  def test_run_with_fasta_multiple_batches
59
59
  out, err = capture_io_while do
60
- Commands::Unipept.run(%w(pept2lca --host http://api.unipept.ugent.be --batch 2 >test AALTER AALER >tost AALTER))
60
+ Commands::Unipept.run(%w[pept2lca --host http://api.unipept.ugent.be --batch 2 >test AALTER AALER >tost AALTER])
61
61
  end
62
62
  lines = out.each_line
63
63
  assert_equal('', err)
@@ -70,7 +70,7 @@ module Unipept
70
70
 
71
71
  def test_run_with_fasta_multiple_batches_and_select
72
72
  out, err = capture_io_while do
73
- Commands::Unipept.run(%w(pept2lca --host http://api.unipept.ugent.be --batch 2 --select taxon_id >test AALTER AALER >tost AALTER))
73
+ Commands::Unipept.run(%w[pept2lca --host http://api.unipept.ugent.be --batch 2 --select taxon_id >test AALTER AALER >tost AALTER])
74
74
  end
75
75
  lines = out.each_line
76
76
  assert_equal('', err)
@@ -83,7 +83,7 @@ module Unipept
83
83
 
84
84
  def test_run_with_fasta_multiple_batches_json
85
85
  out, err = capture_io_while do
86
- Commands::Unipept.run(%w(pept2lca --host http://api.unipept.ugent.be --batch 2 --format json >test AALTER AALER >tost AALTER))
86
+ Commands::Unipept.run(%w[pept2lca --host http://api.unipept.ugent.be --batch 2 --format json >test AALTER AALER >tost AALTER])
87
87
  end
88
88
  lines = out.each_line
89
89
  assert_equal('', err)
@@ -96,7 +96,7 @@ module Unipept
96
96
 
97
97
  def test_run_with_fasta_multiple_batches_xml
98
98
  out, err = capture_io_while do
99
- Commands::Unipept.run(%w(pept2lca --host http://api.unipept.ugent.be --batch 2 --format xml >test AALTER AALER >tost AALTER))
99
+ Commands::Unipept.run(%w[pept2lca --host http://api.unipept.ugent.be --batch 2 --format xml >test AALTER AALER >tost AALTER])
100
100
  end
101
101
  lines = out.each_line
102
102
  assert_equal('', err)