solvebio 1.6.1 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.bumpversion.cfg +6 -0
- data/.gitignore +5 -4
- data/.travis.yml +1 -1
- data/Gemfile +3 -0
- data/README.md +34 -34
- data/Rakefile +1 -18
- data/bin/solvebio.rb +14 -16
- data/installer +64 -0
- data/lib/solvebio.rb +50 -11
- data/lib/solvebio/acccount.rb +4 -0
- data/lib/solvebio/annotation.rb +11 -0
- data/lib/solvebio/api_operations.rb +147 -0
- data/lib/solvebio/api_resource.rb +32 -0
- data/lib/solvebio/cli.rb +75 -0
- data/lib/solvebio/cli/auth.rb +106 -0
- data/lib/solvebio/cli/credentials.rb +54 -0
- data/lib/{cli → solvebio/cli}/irb.rb +0 -23
- data/lib/solvebio/cli/irbrc.rb +48 -0
- data/lib/solvebio/cli/tutorial.rb +12 -0
- data/lib/solvebio/client.rb +149 -0
- data/lib/solvebio/dataset.rb +60 -0
- data/lib/solvebio/dataset_field.rb +12 -0
- data/lib/solvebio/depository.rb +38 -0
- data/lib/solvebio/depository_version.rb +40 -0
- data/lib/solvebio/errors.rb +64 -0
- data/lib/solvebio/filter.rb +315 -0
- data/lib/solvebio/list_object.rb +73 -0
- data/lib/solvebio/locale.rb +43 -0
- data/lib/solvebio/query.rb +341 -0
- data/lib/solvebio/sample.rb +54 -0
- data/lib/solvebio/singleton_api_resource.rb +25 -0
- data/lib/solvebio/solve_object.rb +164 -0
- data/lib/solvebio/tabulate.rb +589 -0
- data/lib/solvebio/user.rb +4 -0
- data/lib/solvebio/util.rb +59 -0
- data/lib/solvebio/version.rb +3 -0
- data/solvebio.gemspec +10 -18
- data/test/helper.rb +6 -2
- data/test/solvebio/data/.gitignore +1 -0
- data/test/solvebio/data/.netrc +6 -0
- data/test/{data → solvebio/data}/netrc-save +0 -0
- data/test/solvebio/data/sample.vcf.gz +0 -0
- data/test/solvebio/data/test_creds +3 -0
- data/test/solvebio/test_annotation.rb +45 -0
- data/test/solvebio/test_client.rb +29 -0
- data/test/solvebio/test_conversion.rb +14 -0
- data/test/solvebio/test_credentials.rb +67 -0
- data/test/solvebio/test_dataset.rb +52 -0
- data/test/solvebio/test_depository.rb +24 -0
- data/test/solvebio/test_depositoryversion.rb +22 -0
- data/test/solvebio/test_error.rb +31 -0
- data/test/solvebio/test_filter.rb +86 -0
- data/test/solvebio/test_query.rb +282 -0
- data/test/solvebio/test_query_batch.rb +38 -0
- data/test/solvebio/test_query_init.rb +30 -0
- data/test/solvebio/test_query_tabulate.rb +73 -0
- data/test/solvebio/test_ratelimit.rb +31 -0
- data/test/solvebio/test_resource.rb +29 -0
- data/test/solvebio/test_sample_access.rb +60 -0
- data/test/solvebio/test_sample_download.rb +20 -0
- data/test/solvebio/test_tabulate.rb +129 -0
- data/test/solvebio/test_util.rb +39 -0
- metadata +100 -85
- data/Makefile +0 -17
- data/demo/README.md +0 -14
- data/demo/cheatsheet.rb +0 -31
- data/demo/dataset/facets.rb +0 -13
- data/demo/dataset/field.rb +0 -13
- data/demo/depository/README.md +0 -24
- data/demo/depository/all.rb +0 -13
- data/demo/depository/retrieve.rb +0 -13
- data/demo/depository/versions-all.rb +0 -13
- data/demo/query/query-filter.rb +0 -30
- data/demo/query/query.rb +0 -13
- data/demo/query/range-filter.rb +0 -18
- data/demo/test-api.rb +0 -98
- data/lib/cli/auth.rb +0 -122
- data/lib/cli/help.rb +0 -13
- data/lib/cli/irbrc.rb +0 -54
- data/lib/cli/options.rb +0 -75
- data/lib/client.rb +0 -154
- data/lib/credentials.rb +0 -67
- data/lib/errors.rb +0 -81
- data/lib/filter.rb +0 -312
- data/lib/locale.rb +0 -47
- data/lib/main.rb +0 -46
- data/lib/query.rb +0 -414
- data/lib/resource/annotation.rb +0 -23
- data/lib/resource/apiresource.rb +0 -241
- data/lib/resource/dataset.rb +0 -91
- data/lib/resource/datasetfield.rb +0 -37
- data/lib/resource/depository.rb +0 -50
- data/lib/resource/depositoryversion.rb +0 -69
- data/lib/resource/main.rb +0 -123
- data/lib/resource/sample.rb +0 -75
- data/lib/resource/solveobject.rb +0 -122
- data/lib/resource/user.rb +0 -5
- data/lib/tabulate.rb +0 -706
- data/lib/util.rb +0 -29
- data/test/Makefile +0 -9
- data/test/data/sample.vcf.gz +0 -0
- data/test/test-annotation.rb +0 -46
- data/test/test-auth.rb +0 -58
- data/test/test-client.rb +0 -27
- data/test/test-conversion.rb +0 -13
- data/test/test-dataset.rb +0 -42
- data/test/test-depository.rb +0 -35
- data/test/test-error.rb +0 -36
- data/test/test-filter.rb +0 -70
- data/test/test-netrc.rb +0 -52
- data/test/test-query-batch.rb +0 -40
- data/test/test-query-init.rb +0 -29
- data/test/test-query-paging.rb +0 -102
- data/test/test-query.rb +0 -71
- data/test/test-resource.rb +0 -40
- data/test/test-sample-access.rb +0 -59
- data/test/test-sample-download.rb +0 -20
- data/test/test-tabulate.rb +0 -131
- data/test/test-util.rb +0 -42
@@ -0,0 +1,59 @@
|
|
1
|
+
module SolveBio
|
2
|
+
module Util
|
3
|
+
def self.object_classes
|
4
|
+
@object_classes ||= {
|
5
|
+
'Depository' => Depository,
|
6
|
+
'DepositoryVersion' => DepositoryVersion,
|
7
|
+
'Dataset' => Dataset,
|
8
|
+
'DatasetField' => DatasetField,
|
9
|
+
'Sample' => Sample,
|
10
|
+
'Annotation' => Annotation,
|
11
|
+
'User' => User,
|
12
|
+
'Account' => Account,
|
13
|
+
'list' => ListObject
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.to_solve_object(resp)
|
18
|
+
case resp
|
19
|
+
when Array
|
20
|
+
resp.map { |i| to_solve_object(i) }
|
21
|
+
when Hash
|
22
|
+
object_classes.fetch(resp[:class_name], SolveObject).construct_from(resp)
|
23
|
+
else
|
24
|
+
resp
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.symbolize_names(object)
|
29
|
+
case object
|
30
|
+
when Hash
|
31
|
+
new_hash = {}
|
32
|
+
object.each do |key, value|
|
33
|
+
key = (key.to_sym rescue key) || key
|
34
|
+
new_hash[key] = symbolize_names(value)
|
35
|
+
end
|
36
|
+
new_hash
|
37
|
+
when Array
|
38
|
+
object.map { |value| symbolize_names(value) }
|
39
|
+
else
|
40
|
+
object
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
module_function
|
45
|
+
def pluralize(name)
|
46
|
+
if name.end_with?('y')
|
47
|
+
name = name[0..-2] + 'ie'
|
48
|
+
end
|
49
|
+
return name + "s"
|
50
|
+
end
|
51
|
+
|
52
|
+
def camelcase_to_underscore(name)
|
53
|
+
# Add underscore before internal uppercase letters.
|
54
|
+
# Using [[:upper:]] and [[:lower]] should help with Unicode.
|
55
|
+
s1 = name.gsub(/(.)([[:upper:]])([[:lower:]]+)/){"#{$1}_#{$2}#{$3}"}
|
56
|
+
return (s1.gsub(/([a-z0-9])([[:upper:]])/){"#{$1}_#{$2}"}).downcase
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/solvebio.gemspec
CHANGED
@@ -1,10 +1,8 @@
|
|
1
1
|
## -*- Ruby -*-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
## You can find comprehensive Gem::Specification documentation, at
|
7
|
-
## http://docs.rubygems.org/read/chapter/20
|
2
|
+
$:.unshift(File.join(File.dirname(__FILE__), 'lib'))
|
3
|
+
|
4
|
+
require 'solvebio/version'
|
5
|
+
|
8
6
|
Gem::Specification.new do |s|
|
9
7
|
s.specification_version = 2 if s.respond_to? :specification_version=
|
10
8
|
# s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
@@ -14,28 +12,27 @@ Gem::Specification.new do |s|
|
|
14
12
|
## If your rubyforge_project name is different, then edit it and comment out
|
15
13
|
## the sub! line in the Rakefile
|
16
14
|
s.name = 'solvebio'
|
17
|
-
s.version =
|
18
|
-
s.date = '2014-11-05'
|
15
|
+
s.version = SolveBio::VERSION
|
19
16
|
|
20
17
|
## Make sure your summary is short. The description may be as long
|
21
18
|
## as you like.
|
22
|
-
s.summary = "
|
23
|
-
|
19
|
+
s.summary = "Ruby bindings for the SolveBio API"
|
24
20
|
s.description = <<-EOD
|
25
21
|
SolveBio is a platform for biomedical datasets. With SolveBio you can
|
26
22
|
forget about parsing complex flat files and sifting through cryptic
|
27
23
|
datasets. Just use the Ruby Client and API to explore massive
|
28
24
|
datasets and automate just about any bioinformatics workflow.
|
29
25
|
|
30
|
-
See https://www.solvebio.com/
|
26
|
+
See https://www.solvebio.com/ for more information.
|
31
27
|
EOD
|
32
28
|
|
33
29
|
## List the primary authors. If there are a bunch of authors, it's probably
|
34
30
|
## better to set the email to an email list or something. If you don't have
|
35
31
|
## a custom homepage, consider using your GitHub URL or the like.
|
36
|
-
s.authors = ['
|
32
|
+
s.authors = ['SolveBio']
|
37
33
|
s.email = 'contact@solvebio.com'
|
38
34
|
s.homepage = 'https://www.solvebio.com'
|
35
|
+
s.license = 'MIT'
|
39
36
|
|
40
37
|
## This gets added to the $LOAD_PATH so that 'lib/NAME.rb' can be required as
|
41
38
|
## require 'NAME.rb' or'/lib/NAME/file.rb' can be as require 'NAME/file.rb'
|
@@ -59,17 +56,12 @@ EOD
|
|
59
56
|
s.add_dependency('rest_client', '>=1.8.1') # better URI handler
|
60
57
|
s.add_dependency('addressable', '>=2.3.6') # better URI parsing
|
61
58
|
|
62
|
-
# s.add_dependency('openssl', '>=1.1.0')
|
63
|
-
|
64
|
-
# There is no way to specify optional dependencies.
|
65
|
-
# s.add_optional_dependency 'launchy' # opens URL in web browser for help
|
66
|
-
# s.add_optional_dependency 'bond' # better shell command completion
|
67
|
-
|
68
59
|
## List your development dependencies here. Development dependencies are
|
69
60
|
## those that are only needed during development
|
70
61
|
# s.add_development_dependency('DEVDEPNAME', [">= 1.1.0", "< 2.0.0"])
|
71
62
|
s.add_development_dependency('rake')
|
72
63
|
s.add_development_dependency('rdoc')
|
64
|
+
s.add_development_dependency('webmock')
|
73
65
|
s.files = `git ls-files`.split($/)
|
74
66
|
|
75
67
|
## Test files will be grabbed from the file list. Make sure the path glob
|
data/test/helper.rb
CHANGED
@@ -1,10 +1,14 @@
|
|
1
|
+
require 'solvebio'
|
2
|
+
require 'solvebio/cli'
|
3
|
+
|
1
4
|
require 'test/unit'
|
5
|
+
require 'webmock/test_unit'
|
6
|
+
require 'net/http'
|
7
|
+
|
2
8
|
ENV['SOLVEBIO_API_HOST'] ||= 'https://api.solvebio.com'
|
3
|
-
require_relative '../lib/main'
|
4
9
|
|
5
10
|
TEST_DATASET_NAME = 'HGNC/1.0.0-1/HGNC'
|
6
11
|
|
7
|
-
|
8
12
|
def local_api?
|
9
13
|
ENV['SOLVEBIO_LOCAL_API']
|
10
14
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
/.solvebio
|
File without changes
|
Binary file
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.expand_path('../../helper', __FILE__)
|
2
|
+
|
3
|
+
module SolveBio
|
4
|
+
class TestAnnotation < Test::Unit::TestCase
|
5
|
+
def check_response(response, expect, msg)
|
6
|
+
expect.each do |key, val|
|
7
|
+
assert_equal(val, response[key], msg)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_annotation
|
12
|
+
if SolveBio.api_host == 'https://api.solvebio.com'
|
13
|
+
skip "Annotation testing only on local/dev environments"
|
14
|
+
end
|
15
|
+
|
16
|
+
vcf_file = File.join(File.dirname(__FILE__), "data/sample.vcf.gz")
|
17
|
+
my_sample = SolveBio::Sample
|
18
|
+
.create('GRCh37', :vcf_file => vcf_file)
|
19
|
+
assert(my_sample)
|
20
|
+
|
21
|
+
sample_id = my_sample['id']
|
22
|
+
expect = {
|
23
|
+
'class_name' => 'Annotation',
|
24
|
+
'error_message' => '',
|
25
|
+
'sample_id' => sample_id
|
26
|
+
}
|
27
|
+
|
28
|
+
response = SolveBio::Annotation.create(:sample_id => sample_id)
|
29
|
+
check_response(response, expect,
|
30
|
+
"'Annotation.create(:sample_id=>{#sample_id}")
|
31
|
+
|
32
|
+
['status', 'user_id', 'created_at', 'updated_at'].each do |field|
|
33
|
+
assert(response.respond_to?(field) ,
|
34
|
+
"response has field #{field}")
|
35
|
+
end
|
36
|
+
|
37
|
+
all = SolveBio::Annotation.all()
|
38
|
+
assert(all.total > 1,
|
39
|
+
"Annotation.all() returns more than one value")
|
40
|
+
|
41
|
+
my_sample.delete
|
42
|
+
assert my_sample.deleted
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.expand_path('../../helper', __FILE__)
|
2
|
+
|
3
|
+
module SolveBio
|
4
|
+
class TestClient < Test::Unit::TestCase
|
5
|
+
def test_get
|
6
|
+
client = Client.new(nil, 'http://google.com')
|
7
|
+
assert client, 'Should be able to create a client'
|
8
|
+
|
9
|
+
# Can we get something from google?
|
10
|
+
output = `curl --silent http://www.google.com`
|
11
|
+
if $?.success? and output
|
12
|
+
assert(client.request('get', 'http://www.google.com',
|
13
|
+
{:raw => true, :redirect => true}),
|
14
|
+
'HTTP GET, google.com')
|
15
|
+
assert(client.request('get', 'https://www.google.com',
|
16
|
+
{:raw => true}),
|
17
|
+
'HTTPS GET google.com')
|
18
|
+
assert(Client.request('get', 'http://www.google.com',
|
19
|
+
{:raw => true, :redirect => true}),
|
20
|
+
'HTTP GET, google.com')
|
21
|
+
assert(Client.request('get', 'https://www.google.com',
|
22
|
+
{:raw => true}),
|
23
|
+
'HTTPS GET google.com')
|
24
|
+
else
|
25
|
+
skip('Are you connected to the Internet? www.google.com is unavailable')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require File.expand_path('../../helper', __FILE__)
|
2
|
+
|
3
|
+
module SolveBio
|
4
|
+
class ConversionTest < Test::Unit::TestCase
|
5
|
+
def test_class_to_api_name
|
6
|
+
klass = SolveBio::Annotation
|
7
|
+
assert_equal('/v1/annotations', klass.url)
|
8
|
+
klass = SolveBio::DatasetField
|
9
|
+
assert_equal('/v1/dataset_fields', klass.url)
|
10
|
+
klass = SolveBio::Depository
|
11
|
+
assert_equal('/v1/depositories', klass.url)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require File.expand_path('../../helper', __FILE__)
|
2
|
+
|
3
|
+
def silence_output(&block)
|
4
|
+
original_stdout = $stdout
|
5
|
+
$stdout = fake = StringIO.new
|
6
|
+
begin
|
7
|
+
yield
|
8
|
+
ensure
|
9
|
+
$stdout = original_stdout
|
10
|
+
end
|
11
|
+
fake.string
|
12
|
+
end
|
13
|
+
|
14
|
+
module SolveBio
|
15
|
+
class TestNetrc < Test::Unit::TestCase
|
16
|
+
include SolveBio::CLI::Credentials
|
17
|
+
include SolveBio::CLI::Auth
|
18
|
+
|
19
|
+
def setup
|
20
|
+
@home_path_save = ENV['HOME']
|
21
|
+
home_path = ENV['HOME'] = File.join(File.dirname(__FILE__), 'data')
|
22
|
+
credentials_file = netrc_path
|
23
|
+
FileUtils.cp(File.join(home_path, 'netrc-save'), credentials_file)
|
24
|
+
File.chmod(0600, credentials_file)
|
25
|
+
@old_warn_level = $VERBOSE
|
26
|
+
@old_api_host = SolveBio.api_host
|
27
|
+
$VERBOSE = nil
|
28
|
+
SolveBio.api_host = 'https://api.solvebio.com'
|
29
|
+
$VERBOSE = @old_warn_level
|
30
|
+
end
|
31
|
+
|
32
|
+
def teardown
|
33
|
+
ENV["HOME"] = @home_path_save
|
34
|
+
$VERBOSE = nil
|
35
|
+
SolveBio.api_host = @old_api_host
|
36
|
+
$VERBOSE = @old_warn_level
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_netrc
|
40
|
+
assert(netrc_path,
|
41
|
+
"Should get a location for SolveBio's credentials")
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_get_credentials
|
45
|
+
assert_equal ['rocky@example.com', 'shhhh'], get_credentials.to_a
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_save_credentials
|
49
|
+
new_values = get_credentials.map{|x| x+"abc"}
|
50
|
+
save_credentials(*new_values)
|
51
|
+
assert_equal(new_values, get_credentials.to_a,
|
52
|
+
'Should append "abc" to creds')
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_delete_credentials
|
56
|
+
delete_credentials
|
57
|
+
assert_equal(nil, get_credentials,
|
58
|
+
'Should be able to delete credentials')
|
59
|
+
pair = ['testagain@solvebio.com', 'b00b00']
|
60
|
+
save_credentials(*pair)
|
61
|
+
auths = get_credentials()
|
62
|
+
assert_equal(pair, auths,
|
63
|
+
"Should get newly set credentials for host #{SolveBio.api_host}")
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require File.expand_path('../../helper', __FILE__)
|
2
|
+
|
3
|
+
module SolveBio
|
4
|
+
class TestDataset < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
@dataset = SolveBio::Dataset.retrieve(TEST_DATASET_NAME)
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_dataset_retrieval
|
10
|
+
assert(@dataset.id,
|
11
|
+
'Should be able to get id in dataset')
|
12
|
+
assert(@dataset[:id],
|
13
|
+
'Should be able to get id in dataset')
|
14
|
+
|
15
|
+
%w(class_name created_at data_url depository depository_id
|
16
|
+
depository_version depository_version_id description
|
17
|
+
fields_url full_name genome_builds is_genomic
|
18
|
+
name title updated_at url).each do |field|
|
19
|
+
assert(@dataset.respond_to?(field),
|
20
|
+
"Should find field #{field} in dataset #{@dataset.id}")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_dataset_fields
|
25
|
+
fields = @dataset.fields
|
26
|
+
dataset_field = fields[:data][0]
|
27
|
+
assert(dataset_field.id,
|
28
|
+
'Should be able to get id in list of dataset fields')
|
29
|
+
|
30
|
+
dataset_field2 = SolveBio::DatasetField.retrieve(dataset_field.id)
|
31
|
+
assert_equal(dataset_field.id, dataset_field2.id,
|
32
|
+
"Retrieving SolveBio::DatasetField id " +
|
33
|
+
"#{dataset_field.id} found by all()")
|
34
|
+
|
35
|
+
%w(class_name created_at dataset dataset_id description facets_url
|
36
|
+
name updated_at url).each do |field|
|
37
|
+
assert(dataset_field.respond_to?(field),
|
38
|
+
"Should find field #{field} in fields #{dataset_field.id}")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_dataset_facets
|
43
|
+
fields = @dataset.fields
|
44
|
+
dataset_field = fields[:data][0]
|
45
|
+
facets = dataset_field.facets()
|
46
|
+
|
47
|
+
# We can get small or large numbers like 0 or 4902851621.0
|
48
|
+
assert(facets['total'] >= 0,
|
49
|
+
'facets should have a numeric total field >= 0')
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.expand_path('../../helper', __FILE__)
|
2
|
+
|
3
|
+
module SolveBio
|
4
|
+
class TestDepository < Test::Unit::TestCase
|
5
|
+
def test_depositories
|
6
|
+
depos = SolveBio::Depository.all
|
7
|
+
|
8
|
+
depo = depos.data[0]
|
9
|
+
assert(depo.id,
|
10
|
+
'Should be able to get id in depository')
|
11
|
+
|
12
|
+
depo2 = SolveBio::Depository.retrieve(depo.id)
|
13
|
+
assert_equal(depo.id, depo2.id,
|
14
|
+
"Retrieving dataset id #{depo.id} found by all()")
|
15
|
+
%w(class_name created_at description external_resources
|
16
|
+
full_name id is_private is_restricted latest_version
|
17
|
+
latest_version_id name title updated_at url versions_count
|
18
|
+
versions_url).each do |field|
|
19
|
+
assert(depo.respond_to?(field),
|
20
|
+
"Should find field #{field} in depo #{depo.id}")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.expand_path('../../helper', __FILE__)
|
2
|
+
|
3
|
+
module SolveBio
|
4
|
+
class TestDepository < Test::Unit::TestCase
|
5
|
+
def test_depositoryversion
|
6
|
+
dvs = SolveBio::DepositoryVersion.all
|
7
|
+
dv = dvs.data[0]
|
8
|
+
assert(dv.respond_to?('id'),
|
9
|
+
'Should be able to get id in depositoryversion')
|
10
|
+
|
11
|
+
dv2 = SolveBio::DepositoryVersion.retrieve(dv.id)
|
12
|
+
assert_equal(dv.id, dv2.id,
|
13
|
+
"Retrieving dataset id #{dv.id} found by all()")
|
14
|
+
%w(class_name created_at datasets_url depository depository_id
|
15
|
+
description full_name id latest name is_released released_at
|
16
|
+
title updated_at url).each do |field|
|
17
|
+
assert(dv.respond_to?(field),
|
18
|
+
"Should find field #{field} in depo version")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.expand_path('../../helper', __FILE__)
|
2
|
+
|
3
|
+
$errors = []
|
4
|
+
|
5
|
+
class FakeLogger
|
6
|
+
def debug(mess)
|
7
|
+
$errors << mess
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module SolveBio
|
12
|
+
class TestError < Test::Unit::TestCase
|
13
|
+
def test_error
|
14
|
+
msg = "hi"
|
15
|
+
assert_equal msg, SolveBio::SolveError.new(nil, msg).to_s, "Error.to_s fn"
|
16
|
+
response = Net::HTTPUnauthorized.new('HTTP 1.1', '404', 'No creds')
|
17
|
+
old_logger = SolveBio.instance_variable_get('@logger')
|
18
|
+
logger = FakeLogger.new
|
19
|
+
SolveBio.instance_variable_set('@logger', logger)
|
20
|
+
old_verbose = $VERBOSE
|
21
|
+
$VERBOSE=false
|
22
|
+
SolveBio::SolveError.new(response)
|
23
|
+
$VERBOSE=old_verbose
|
24
|
+
assert_equal ["API Response (404): No content."], $errors
|
25
|
+
ensure
|
26
|
+
$VERBOSE = old_verbose if old_verbose
|
27
|
+
SolveBio.instance_variable_set('@logger', old_logger) if old_logger
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|