opentox-client 0.0.2pre → 1.0.0pre1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +0,0 @@
1
- SMILES, Hamster Carcinogenicity, numeric feature, classification, mixed, string
2
- c1ccccc1NN , 1, 1, true , true , "test"
3
- C12C3=C(C=CC=C3)CC1=CC(=CC=2)NC(C)=O , 1, 2, false, 7.5 , "test"
4
- O=C(N)\C(C2=CC=CO2)=C/C1=CC=C([N+]([O-])=O)O1, 1, 3, true , 5 , "test"
5
- C1(N=CNN=1)N , 0, 4, false, false, "test"
@@ -1,99 +0,0 @@
1
- require 'test/unit'
2
- $LOAD_PATH << File.join(File.dirname(__FILE__),'..','lib')
3
- require File.join File.dirname(__FILE__),'..','lib','opentox-client.rb'
4
- DATASET = "http://ot-dev.in-silico.ch/dataset"
5
- AA ||= "https://opensso.in-silico.ch"
6
- AA_USER = "guest"
7
- AA_PASS = "guest"
8
- @@subjectid = OpenTox::Authorization.authenticate(AA_USER,AA_PASS)
9
-
10
- DATA_DIR = File.join(File.dirname(__FILE__),"data")
11
- # TODO: add subjectids
12
-
13
-
14
- class DatasetTest < Test::Unit::TestCase
15
-
16
- def test_all
17
- puts @@subjectid
18
- datasets = OpenTox::Dataset.all(DATASET, @@subjectid)
19
- assert_equal OpenTox::Dataset, datasets.first.class
20
- end
21
-
22
- def test_create_empty
23
- d = OpenTox::Dataset.create(DATASET, @@subjectid)
24
- assert_equal OpenTox::Dataset, d.class
25
- assert_match /#{DATASET}/, d.uri.to_s
26
- d.delete
27
- end
28
-
29
- def test_create_from_file
30
- d = OpenTox::Dataset.from_file DATASET, File.join(DATA_DIR,"EPAFHM.mini.csv"), @@subjectid
31
- assert_equal OpenTox::Dataset, d.class
32
- assert_equal d.uri, d[RDF::XSD.anyURI]
33
- assert_equal "EPAFHM.mini", d.metadata[RDF::URI("http://purl.org/dc/elements/1.1/title")].first.to_s # DC.title is http://purl.org/dc/terms/title
34
- assert_equal "EPAFHM.mini", d[RDF::URI("http://purl.org/dc/elements/1.1/title")]
35
- d.delete
36
- assert_raise OpenTox::NotFoundError do
37
- d.get
38
- end
39
- end
40
-
41
- def test_from_yaml
42
- @dataset = OpenTox::Dataset.from_file DATASET, File.join(DATA_DIR,"hamster_carcinogenicity.yaml"), @@subjectid
43
- assert_equal OpenTox::Dataset, @dataset.class
44
- assert_equal "hamster_carcinogenicity", @dataset[RDF::URI("http://purl.org/dc/elements/1.1/title")]
45
- hamster_carc?
46
- @dataset.delete
47
- end
48
-
49
- =begin
50
- # TODO: fix (mime type??0 and add Egons example
51
- def test_sdf_with_multiple_features
52
- @dataset = OpenTox::Dataset.from_file DATASET, "#{DATA_DIR}/CPDBAS_v5c_1547_29Apr2008part.sdf"
53
- assert_equal OpenTox::Dataset, @dataset.class
54
- puts @dataset.features.size
55
- puts @dataset.compounds.size
56
- @dataset.delete
57
- end
58
- =end
59
-
60
- def test_multicolumn_csv
61
- @dataset = OpenTox::Dataset.from_file DATASET, "#{DATA_DIR}/multicolumn.csv", @@subjectid
62
- assert_equal 5, @dataset.features.size
63
- assert_equal 4, @dataset.compounds.size
64
- @dataset.delete
65
- end
66
-
67
- def test_from_csv
68
- @dataset = OpenTox::Dataset.from_file DATASET, "#{DATA_DIR}/hamster_carcinogenicity.csv", @@subjectid
69
- assert_equal OpenTox::Dataset, @dataset.class
70
- hamster_carc?
71
- @dataset.delete
72
- end
73
-
74
- =begin
75
- def test_save
76
- d = OpenTox::Dataset.create DATASET
77
- d.metadata
78
- d.metadata[RDF::DC.title] = "test"
79
- d.save
80
- # TODO: save does not work with datasets
81
- #puts d.response.code.inspect
82
- #assert_equal "test", d.metadata[RDF::DC.title] # should reload metadata
83
- d.delete
84
- end
85
- =end
86
- =begin
87
- =end
88
-
89
-
90
- def hamster_carc?
91
- assert_kind_of OpenTox::Dataset, @dataset
92
- #require 'yaml'
93
- #puts @dataset.data_entries.to_yaml
94
- assert_equal 85, @dataset.data_entries.size
95
- assert_equal 85, @dataset.compounds.size
96
- assert_equal 1, @dataset.features.size
97
- assert_equal @dataset.uri, @dataset[RDF::XSD.anyURI]
98
- end
99
- end
@@ -1,35 +0,0 @@
1
- require 'test/unit'
2
- $LOAD_PATH << File.join(File.dirname(__FILE__),'..','lib')
3
- require File.join File.dirname(__FILE__),'..','lib','opentox-client.rb'
4
-
5
- class ErrorTest < Test::Unit::TestCase
6
-
7
- def test_bad_request
8
- object = OpenTox::Feature.new "http://this-is-a/fantasy/url"
9
- assert_raise OpenTox::NotFoundError do
10
- response = object.get
11
- end
12
- end
13
-
14
- def test_error_methods
15
- assert_raise OpenTox::NotFoundError do
16
- not_found_error "This is a test"
17
- end
18
- end
19
-
20
- def test_exception
21
- assert_raise Exception do
22
- raise Exception.new "Basic Exception"
23
- end
24
- end
25
-
26
- def test_backtick
27
- assert_raise OpenTox::InternalServerError do
28
- `this call will not work`
29
- end
30
- assert_raise OpenTox::InternalServerError do
31
- `ls inexisting_directory`
32
- end
33
- end
34
-
35
- end
@@ -1,36 +0,0 @@
1
- require 'test/unit'
2
- $LOAD_PATH << File.join(File.dirname(__FILE__),'..','lib')
3
- require File.join File.dirname(__FILE__),'..','lib','opentox-client.rb'
4
-
5
- class FeatureTest < Test::Unit::TestCase
6
-
7
- def setup
8
- @features = [
9
- #@@classification_training_dataset.features.keys.first,
10
- "http://apps.ideaconsult.net:8080/ambit2/feature/35796",
11
- #File.join(OpenTox::Model::Lazar.all.last,"predicted","value")
12
-
13
- ]
14
- end
15
-
16
- def test_feature
17
- @features.each do |uri|
18
- f = OpenTox::Feature.new(uri)
19
- assert_equal RDF::OT1.TUM_CDK_nAtom, f[RDF::OWL.sameAs]
20
- assert_equal RDF::OT1.TUM_CDK_nAtom, f.metadata[RDF::OWL.sameAs].first.to_s
21
- assert_equal [RDF::OT1.Feature,RDF::OT1.NumericFeature].sort, f[RDF.type].sort
22
- end
23
- end
24
-
25
- =begin
26
- def test_owl
27
- #@features.each do |uri|
28
- validate_owl @features.first, @@subjectid unless CONFIG[:services]["opentox-dataset"].match(/localhost/)
29
- validate_owl @features.last, @@subjectid unless CONFIG[:services]["opentox-dataset"].match(/localhost/)
30
- # Ambit does not validate
31
- #end
32
- end
33
- =end
34
-
35
-
36
- end
@@ -1,120 +0,0 @@
1
- require 'test/unit'
2
- $LOAD_PATH << File.join(File.dirname(__FILE__),'..','lib')
3
- require File.expand_path(File.join(File.dirname(__FILE__),'..','lib','opentox-client.rb'))
4
-
5
- TEST_URI = "http://only_a_test/test/" + rand(1000000).to_s
6
- USER_TYPE = "LDAPUsers"
7
- USER_VALUE = "uid=guest,ou=people,dc=opentox,dc=org"
8
- USER_GROUP = "member"
9
- GROUP_TYPE = "LDAPGroups"
10
- GROUP_VALUE = "cn=member,ou=groups,dc=opentox,dc=org"
11
- POLICY_NAME = "test_policy_#{rand(100000)}"
12
- RULE_NAME = "test_rule_#{rand(100000)}"
13
- SUBJECT_NAME = "test_subject_#{rand(100000)}"
14
-
15
- AA ||= "https://opensso.in-silico.ch"
16
- AA_USER = "guest"
17
- AA_PASS = "guest"
18
-
19
- @@subjectid = OpenTox::Authorization.authenticate(AA_USER,AA_PASS)
20
-
21
- class PolicyTest < Test::Unit::TestCase
22
-
23
- def test_01_class
24
- policies = OpenTox::Policies.new()
25
- assert_equal(policies.class, OpenTox::Policies)
26
- assert_kind_of Array, policies.names
27
- assert_kind_of Array, policies.uris
28
- assert_kind_of Array, policies.names
29
- end
30
-
31
- def test_02_subclasses
32
- policies = OpenTox::Policies.new()
33
- policies.new_policy(POLICY_NAME)
34
- assert_equal(policies.names[0], POLICY_NAME)
35
- assert_equal(policies.policies[policies.names[0]].class, OpenTox::Policy)
36
- policy = policies.policies[policies.names[0]]
37
- policy.rule.name = RULE_NAME
38
- policy.uri = TEST_URI
39
- assert_equal(policy.rule.class, OpenTox::Policy::Rule)
40
- assert_equal(policy.rule.name, RULE_NAME)
41
- assert_equal(policy.rule.uri, TEST_URI)
42
- assert_equal(policy.uri, TEST_URI)
43
- policy.subject.name = SUBJECT_NAME
44
- policy.type = USER_TYPE
45
- policy.value = USER_VALUE
46
- assert_equal(policy.subject.class, OpenTox::Policy::Subject)
47
- assert_equal(policy.subject.name, SUBJECT_NAME)
48
- assert_equal(policy.subject.type, USER_TYPE)
49
- assert_equal(policy.type, USER_TYPE)
50
- assert_equal(policy.subject.value, USER_VALUE)
51
- assert_equal(policy.value, USER_VALUE)
52
- end
53
-
54
- def test_03_read_readwrite
55
- policies = OpenTox::Policies.new()
56
- policies.new_policy(POLICY_NAME)
57
- policy = policies.policies[policies.names[0]]
58
- policy.rule.name = RULE_NAME
59
- policy.uri = TEST_URI
60
- policy.rule.get = "allow"
61
- assert policy.rule.read
62
- assert !policy.rule.readwrite
63
- policy.rule.post = "allow"
64
- policy.rule.put = "allow"
65
- assert !policy.rule.read
66
- assert policy.rule.readwrite
67
- end
68
-
69
- def test_04_group_user
70
- policies = OpenTox::Policies.new()
71
- policies.load_default_policy(AA_USER, TEST_URI, "member")
72
- assert_equal "member", policies.policies["policy_group"].group
73
- assert_equal AA_USER, policies.policies["policy_user"].user
74
- end
75
-
76
- def test_05_DN
77
- policies = OpenTox::Policies.new()
78
- policies.new_policy(POLICY_NAME)
79
- policy = policies.policies[policies.names[0]]
80
- policy.set_ot_user(AA_USER)
81
- assert_equal USER_VALUE, policy.value
82
- assert_equal USER_TYPE, policy.type
83
- policy.set_ot_group(USER_GROUP)
84
- assert_equal GROUP_VALUE, policy.value
85
- assert_equal GROUP_TYPE, policy.type
86
- end
87
-
88
- def test_06_load_xml_and_check_defaults
89
- policies = OpenTox::Policies.new()
90
- xml = File.read(File.join(File.dirname(__FILE__), "../lib/templates/default_policy.xml"))
91
- policies.load_xml(xml)
92
- # check user policy
93
- policy = policies.policies["policy_user"]
94
- assert policy.name == "policy_user"
95
- assert policy.rule.name == "rule_user"
96
- assert policy.rule.uri == "uri"
97
- assert policy.rule.get == "allow"
98
- assert policy.rule.post == "allow"
99
- assert policy.rule.delete == "allow"
100
- assert policy.rule.put == "allow"
101
- assert policy.subject_group == "subjects_user"
102
- assert policy.subject.name == "subject_user"
103
- assert policy.subject.type == USER_TYPE
104
- assert policy.subject.value == USER_VALUE
105
- # check group policy
106
- policy = policies.policies["policy_group"]
107
- assert policy.name == "policy_group"
108
- assert policy.rule.name == "rule_group"
109
- assert policy.rule.uri == "uri"
110
- assert policy.rule.get == "allow"
111
- assert !policy.rule.post
112
- assert !policy.rule.delete
113
- assert !policy.rule.put
114
- assert policy.subject_group == "subjects_group"
115
- assert policy.subject.name == "subject_group"
116
- assert policy.subject.type == GROUP_TYPE
117
- assert policy.subject.value == GROUP_VALUE
118
- end
119
-
120
- end
@@ -1,85 +0,0 @@
1
- require 'test/unit'
2
- $LOAD_PATH << File.join(File.dirname(__FILE__),'..','lib')
3
- require File.join File.dirname(__FILE__),'..','lib','opentox-client.rb'
4
- #require "./validate-owl.rb"
5
-
6
- TASK_SERVICE_URI = "http://ot-dev.in-silico.ch/task"
7
- #TASK_SERVICE_URI = "http://ot-test.in-silico.ch/task"
8
- #TASK_SERVICE_URI = "https://ambit.uni-plovdiv.bg:8443/ambit2/task" #not compatible
9
-
10
- class TaskTest < Test::Unit::TestCase
11
-
12
-
13
- =begin
14
- =end
15
- def test_all
16
- all = OpenTox::Task.all(TASK_SERVICE_URI)
17
- assert_equal Array, all.class
18
- t = all.last
19
- assert_equal OpenTox::Task, t.class
20
- assert_equal RDF::OT1.Task, t[RDF.type]
21
- end
22
-
23
- def test_create_and_complete
24
- task = OpenTox::Task.create TASK_SERVICE_URI, :description => "test" do
25
- sleep 1
26
- TASK_SERVICE_URI
27
- end
28
- assert task.running?
29
- assert_equal "Running", task.hasStatus
30
- task.wait
31
- assert task.completed?
32
- assert_equal "Completed", task.hasStatus
33
- assert_equal TASK_SERVICE_URI, task.resultURI
34
- end
35
-
36
-
37
- def test_create_and_cancel
38
- task = OpenTox::Task.create TASK_SERVICE_URI do
39
- sleep 2
40
- TASK_SERVICE_URI
41
- end
42
- assert task.running?
43
- task.cancel
44
- assert task.cancelled?
45
- end
46
-
47
- def test_create_and_fail
48
- task = OpenTox::Task.create TASK_SERVICE_URI, :description => "test failure", :creator => "http://test.org/fake_creator" do
49
- sleep 1
50
- raise "A runtime error occured"
51
- end
52
- assert task.running?
53
- assert_equal "Running", task.hasStatus
54
- task.wait
55
- assert task.error?
56
- assert_equal "Error", task.hasStatus
57
- end
58
-
59
- def test_create_and_fail_with_opentox_error
60
- task = OpenTox::Task.create TASK_SERVICE_URI, :description => "test failure", :creator => "http://test.org/fake_creator" do
61
- sleep 1
62
- raise OpenTox::Error.new 500, "An OpenTox::Error occured"
63
- end
64
- assert task.running?
65
- assert_equal "Running", task.hasStatus
66
- task.wait
67
- assert task.error?
68
- assert_equal "Error", task.hasStatus
69
- end
70
-
71
- =begin
72
- def test_wrong_result_uri
73
- task = OpenTox::Task.create TASK_SERVICE_URI, :description => "test wrong result uri", :creator => "http://test.org/fake_creator" do
74
- sleep 1
75
- "Asasadasd"
76
- end
77
- assert task.running?
78
- assert_equal "Running", task.hasStatus
79
- task.wait
80
- assert task.error?
81
- assert_equal "Error", task.hasStatus
82
- end
83
- =end
84
-
85
- end