kasabi 0.0.1

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.
@@ -0,0 +1,21 @@
1
+ module Kasabi
2
+
3
+ class Dataset
4
+
5
+ attr_reader :uri
6
+ attr_reader :client
7
+ attr_reader :apikey
8
+
9
+ #Initialize the client to work with a specific endpoint
10
+ #
11
+ # The _options_ hash can contain the following values:
12
+ # * *:apikey*: required. apikey authorized to use the API
13
+ # * *:client*: HTTPClient object instance
14
+ def initialize(uri, options={})
15
+ @uri = uri
16
+ @client = options[:client] || HTTPClient.new()
17
+ @apikey = options[:apikey] || nil
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,28 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
2
+ require 'kasabi'
3
+ require 'test/unit'
4
+ require 'mocha'
5
+
6
+ class AugmentTest < Test::Unit::TestCase
7
+
8
+ def test_augment_uri
9
+ mc = mock()
10
+ mc.expects(:get).with("http://api.kasabi.com/api/test-augment-api", {:apikey=>"test-key", "data-uri" => "http://www.example.org/index.rss"}).returns(
11
+ HTTP::Message.new_response("OK") )
12
+
13
+ client = Kasabi::Augment::Client.new( "http://api.kasabi.com/api/test-augment-api", :apikey=>"test-key", :client=>mc)
14
+ response = client.augment_uri("http://www.example.org/index.rss")
15
+ assert_equal("OK", response)
16
+ end
17
+
18
+ def test_augment
19
+ mc = mock()
20
+ mc.expects(:post).with("http://api.kasabi.com/api/test-augment-api?apikey=test-key", "data", anything).returns(
21
+ HTTP::Message.new_response("OK") )
22
+
23
+ client = Kasabi::Augment::Client.new( "http://api.kasabi.com/api/test-augment-api", :apikey=>"test-key", :client=>mc)
24
+ response = client.augment("data")
25
+ assert_equal("OK", response)
26
+ end
27
+
28
+ end
@@ -0,0 +1,89 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
2
+ require 'test/unit'
3
+ require 'mocha'
4
+ require 'rexml/document'
5
+
6
+ class FacetTest < Test::Unit::TestCase
7
+
8
+ RESULTS = <<-EOL
9
+ <facet-results xmlns="http://schemas.talis.com/2007/facet-results#">
10
+ <head>
11
+ <query>austen</query>
12
+ <fields>title,author,publisher</fields>
13
+ </head>
14
+ <fields>
15
+ <field name="title">
16
+ <term number="19" search-uri="http://api.kasabi.com/api/test-facet-api/facet?query=austen+title:%22Pride+and+prejudice%22">Pride and prejudice</term>
17
+ <term number="12" search-uri="http://api.kasabi.com/api/test-facet-api/facet?query=austen+title:%22Emma%22">Emma</term>
18
+ <term number="9" search-uri="http://api.kasabi.com/api/test-facet-api/facet?query=austen+title:%22Northanger+Abbey%22">Northanger Abbey</term>
19
+ <term number="8" search-uri="http://api.kasabi.com/api/test-facet-api/facet?query=austen+title:%22Mansfield+Park%22">Mansfield Park</term>
20
+ </field>
21
+ <field name="publisher"/>
22
+
23
+ <field name="author">
24
+ <term number="91" search-uri="http://api.kasabi.com/api/test-facet-api/facet?query=austen+author:%22Austen,+Jane%22">Austen, Jane</term>
25
+ <term number="6" search-uri="http://api.kasabi.com/api/test-facet-api/facet?query=austen+author:%22Jane+Austen+Society.%22">Jane Austen Society.</term>
26
+ <term number="3" search-uri="http://api.kasabi.com/api/test-facet-api/facet?query=austen+author:%22Evans,+J.+M.+(Jessie+Maud)%22">Evans, J. M. (Jessie Maud)</term>
27
+ <term number="3" search-uri="http://api.kasabi.com/api/test-facet-api/facet?query=austen+author:%22Chapman,+R.+W.+(Robert+William)%22">Chapman, R. W. (Robert William)</term>
28
+ </field>
29
+
30
+ </fields>
31
+
32
+ </facet-results>
33
+ EOL
34
+
35
+ def test_parse
36
+
37
+ results = Kasabi::Search::Facet::Results.parse(RESULTS)
38
+
39
+ assert_equal("austen", results.query)
40
+ assert_equal("title,author,publisher", results.fields)
41
+ assert_equal(3, results.facets.size)
42
+
43
+ assert_equal(4, results.facets["title"].length)
44
+ assert_expected_term(results.facets["title"][0],
45
+ 19, "http://api.kasabi.com/api/test-facet-api/facet?query=austen+title:%22Pride+and+prejudice%22", "Pride and prejudice")
46
+ assert_expected_term(results.facets["title"][1],
47
+ 12, "http://api.kasabi.com/api/test-facet-api/facet?query=austen+title:%22Emma%22", "Emma")
48
+ assert_expected_term(results.facets["title"][2],
49
+ 9, "http://api.kasabi.com/api/test-facet-api/facet?query=austen+title:%22Northanger+Abbey%22", "Northanger Abbey")
50
+ assert_expected_term(results.facets["title"][3],
51
+ 8, "http://api.kasabi.com/api/test-facet-api/facet?query=austen+title:%22Mansfield+Park%22", "Mansfield Park")
52
+
53
+ assert_equal(0, results.facets["publisher"].length)
54
+
55
+ assert_equal(4, results.facets["author"].length)
56
+ assert_expected_term(results.facets["author"][0],
57
+ 91, "http://api.kasabi.com/api/test-facet-api/facet?query=austen+author:%22Austen,+Jane%22", "Austen, Jane")
58
+ assert_expected_term(results.facets["author"][1],
59
+ 6, "http://api.kasabi.com/api/test-facet-api/facet?query=austen+author:%22Jane+Austen+Society.%22", "Jane Austen Society.")
60
+ assert_expected_term(results.facets["author"][2],
61
+ 3, "http://api.kasabi.com/api/test-facet-api/facet?query=austen+author:%22Evans,+J.+M.+(Jessie+Maud)%22", "Evans, J. M. (Jessie Maud)")
62
+ assert_expected_term(results.facets["author"][3],
63
+ 3, "http://api.kasabi.com/api/test-facet-api/facet?query=austen+author:%22Chapman,+R.+W.+(Robert+William)%22", "Chapman, R. W. (Robert William)")
64
+
65
+ end
66
+
67
+ def test_query
68
+ mc = mock()
69
+ mc.expects(:get).with("http://api.kasabi.com/api/test-facet-api/facet",
70
+ {:query => "austen", :fields => "title,author,publisher", :apikey => "test-key"}, nil).returns(
71
+ HTTP::Message.new_response(RESULTS) )
72
+
73
+ client = Kasabi::Search::Client.new("http://api.kasabi.com/api/test-facet-api", :apikey => "test-key", :client=>mc)
74
+
75
+ results = client.facet( "austen", ["title", "author", "publisher"])
76
+
77
+ assert_not_nil(results)
78
+ assert_equal("austen", results.query)
79
+ assert_equal("title,author,publisher", results.fields)
80
+ assert_equal(3, results.facets.size)
81
+
82
+ end
83
+
84
+ def assert_expected_term(term, hits, search_uri, value)
85
+ assert_equal(hits, term.hits)
86
+ assert_equal(search_uri, term.search_uri)
87
+ assert_equal(value, term.value)
88
+ end
89
+ end
@@ -0,0 +1,21 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
2
+ require 'kasabi'
3
+ require 'test/unit'
4
+ require 'mocha'
5
+
6
+ class LookupTest < Test::Unit::TestCase
7
+
8
+ def test_describe_with_json
9
+ mc = mock()
10
+ mc.expects(:get).with("http://api.kasabi.com/api/test-lookup",
11
+ {:apikey=>"test-key", :about => "http://www.example.org", :output=>"json"} ).returns(
12
+ HTTP::Message.new_response("{}"))
13
+
14
+ client = Kasabi::Lookup::Client.new("http://api.kasabi.com/api/test-lookup",
15
+ :apikey=>"test-key", :client=>mc)
16
+
17
+ response = client.lookup("http://www.example.org")
18
+ assert_not_nil( response )
19
+ end
20
+
21
+ end
@@ -0,0 +1,178 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
2
+ require 'rubygems'
3
+
4
+ require 'test/unit'
5
+ require 'kasabi'
6
+ require 'mocha'
7
+
8
+ class ClientTest < Test::Unit::TestCase
9
+
10
+ def test_make_query_basic()
11
+
12
+ query = Kasabi::Reconcile::Client.make_query("train")
13
+
14
+ assert_equal("train", query[:query])
15
+ assert_equal(3, query[:limit])
16
+ assert_equal(:any, query[:type_strict])
17
+ assert_equal(nil, query[:type])
18
+ assert_equal(nil, query[:properties])
19
+ end
20
+
21
+ def test_make_queries()
22
+ queries = Kasabi::Reconcile::Client.make_queries( ["train", "car", "boat"] )
23
+ assert_equal(3, queries.size)
24
+
25
+ ["train", "car", "boat"].each_with_index do |label, i|
26
+ assert_equal(label, queries[i][:query])
27
+ assert_equal(3, queries[i][:limit])
28
+ assert_equal(:any, queries[i][:type_strict])
29
+ assert_equal(nil, queries[i][:type])
30
+ assert_equal(nil, queries[i][:properties])
31
+ end
32
+
33
+ end
34
+
35
+ def test_make_query_with_limit()
36
+
37
+ query = Kasabi::Reconcile::Client.make_query("train", 10)
38
+
39
+ assert_equal("train", query[:query])
40
+ assert_equal(10, query[:limit])
41
+ end
42
+
43
+ def test_make_query_with_type()
44
+
45
+ query = Kasabi::Reconcile::Client.make_query("train", 3, :any, "http://example.org/type")
46
+
47
+ assert_equal("train", query[:query])
48
+ assert_equal(3, query[:limit])
49
+ assert_equal(:any, query[:type_strict])
50
+ assert_equal("http://example.org/type", query[:type])
51
+ end
52
+
53
+ def test_make_query_with_type_array()
54
+
55
+ query = Kasabi::Reconcile::Client.make_query("train", 3, :any,
56
+ ["http://example.org/type"])
57
+
58
+ assert_equal("train", query[:query])
59
+ assert_equal(3, query[:limit])
60
+ assert_equal(:any, query[:type_strict])
61
+ assert_equal(["http://example.org/type"], query[:type])
62
+ end
63
+
64
+ def test_make_property_filter()
65
+ assert_raises RuntimeError do
66
+ filter = Kasabi::Reconcile::Client.make_property_filter("Ivor")
67
+ end
68
+ end
69
+
70
+ def test_make_property_filter_with_name()
71
+ filter = Kasabi::Reconcile::Client.make_property_filter("Ivor", "name")
72
+ assert_not_nil(filter)
73
+ assert_equal("Ivor", filter[:v])
74
+ assert_equal("name", filter[:p])
75
+ assert_equal(nil, filter[:pid])
76
+ end
77
+
78
+ def test_make_property_filter_with_id()
79
+ filter = Kasabi::Reconcile::Client.make_property_filter("Ivor", nil, "http://xmlns.com/foaf/0.1/name")
80
+ assert_not_nil(filter)
81
+ assert_equal("Ivor", filter[:v])
82
+ assert_equal(nil, filter[:p])
83
+ assert_equal("http://xmlns.com/foaf/0.1/name", filter[:pid])
84
+ end
85
+
86
+ def test_reconcile_label()
87
+
88
+ mc = mock();
89
+ mc.expects(:get).with("http://api.kasabi.com/api/test-reconcile",
90
+ {:apikey=>"test-key", "query" => {:query => "test", :limit => 3, :type_strict => :any}.to_json }
91
+ ).returns( HTTP::Message.new_response("{}") )
92
+
93
+ reconciler = Kasabi::Reconcile::Client.new("http://api.kasabi.com/api/test-reconcile", :apikey=>"test-key", :client=>mc)
94
+ result = reconciler.reconcile_label("test")
95
+ assert_equal(nil, result)
96
+ end
97
+
98
+ def test_reconcile_label_with_result()
99
+
100
+ resp = { "result" => [
101
+ {
102
+ "id" => "123",
103
+ "score" => 1.0,
104
+ "match" => true,
105
+ "label" => "test"
106
+ }
107
+ ] }
108
+
109
+ mc = mock();
110
+ mc.expects(:get).with("http://api.kasabi.com/api/test-reconcile",
111
+ {:apikey=>"test-key", "query" => {:query => "test", :limit => 3, :type_strict => :any}.to_json }
112
+ ).returns( HTTP::Message.new_response( resp.to_json ) )
113
+
114
+ reconciler = Kasabi::Reconcile::Client.new("http://api.kasabi.com/api/test-reconcile", :apikey=>"test-key", :client=>mc)
115
+ result = reconciler.reconcile_label("test")
116
+ assert_not_nil(result)
117
+ assert_equal(1, result.size)
118
+ assert_equal("123", result[0]["id"])
119
+ end
120
+
121
+ def test_reconcile_label_with_block()
122
+
123
+ resp = { "result" => [
124
+ {
125
+ "id" => "123",
126
+ "score" => 1.0,
127
+ "match" => true,
128
+ "label" => "test"
129
+ }
130
+ ] }
131
+
132
+ mc = mock();
133
+ mc.expects(:get).with("http://api.kasabi.com/api/test-reconcile",
134
+ {:apikey=>"test-key", "query" => {:query => "test", :limit => 3, :type_strict => :any}.to_json }
135
+ ).returns( HTTP::Message.new_response( resp.to_json ) )
136
+
137
+ reconciler = Kasabi::Reconcile::Client.new("http://api.kasabi.com/api/test-reconcile", :apikey=>"test-key", :client=>mc)
138
+ count = 0
139
+ result = reconciler.reconcile_label("test") do |r, index|
140
+ count = count + 1
141
+ end
142
+
143
+ assert_equal(1, count)
144
+ assert_not_nil(result)
145
+ assert_equal(1, result.size)
146
+ end
147
+
148
+ def test_reconcile_all_with_block()
149
+
150
+ resp = { "q0" => { "result" => [
151
+ {
152
+ "id" => "123",
153
+ "score" => 1.0,
154
+ "match" => true,
155
+ "label" => "test"
156
+ }
157
+ ]
158
+ }
159
+ }
160
+
161
+ mc = mock();
162
+ expected_query = { "q0" => { :query => "test", :limit => 3, :type_strict => :any} }
163
+ mc.expects(:get).with("http://api.kasabi.com/api/test-reconcile",
164
+ {:apikey=>"test-key", "queries" => expected_query.to_json }
165
+ ).returns( HTTP::Message.new_response( resp.to_json ) )
166
+
167
+ reconciler = Kasabi::Reconcile::Client.new("http://api.kasabi.com/api/test-reconcile", :apikey=>"test-key", :client=>mc)
168
+ count = 0
169
+ queries = Kasabi::Reconcile::Client.make_queries(["test"])
170
+ result = reconciler.reconcile_all(queries) do |r, index, query|
171
+ count = count + 1
172
+ end
173
+
174
+ assert_equal(1, count)
175
+ assert_not_nil(result)
176
+ assert_equal(1, result.size)
177
+ end
178
+ end
@@ -0,0 +1,30 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
2
+ require 'kasabi'
3
+ require 'test/unit'
4
+ require 'mocha'
5
+
6
+ class SearchTest < Test::Unit::TestCase
7
+
8
+ def test_simple_search
9
+ mc = mock()
10
+ mc.expects(:get).with("http://api.kasabi.com/api/test-search/search", {:apikey=>"test-key", :query => "lunar", :output=>"json"}).returns(
11
+ HTTP::Message.new_response("{}") )
12
+
13
+ client = Kasabi::Search::Client.new("http://api.kasabi.com/api/test-search", :apikey=>"test-key", :client=>mc)
14
+ response = client.search("lunar")
15
+ assert_not_nil(response)
16
+ end
17
+
18
+ def test_parameter_search
19
+ mc = mock()
20
+ mc.expects(:get).with("http://api.kasabi.com/api/test-search/search",
21
+ {:apikey=>"test-key", :query => "lunar", :max => "50", :offset => "10", :output=>"json"}).returns(
22
+ HTTP::Message.new_response("{}") )
23
+
24
+
25
+ client = Kasabi::Search::Client.new("http://api.kasabi.com/api/test-search", :apikey=>"test-key", :client=>mc)
26
+ response = client.search("lunar", {:max => "50", :offset => "10"})
27
+ assert_not_nil(response)
28
+ end
29
+
30
+ end
@@ -0,0 +1,177 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
2
+ require 'kasabi'
3
+ require 'test/unit'
4
+ require 'mocha'
5
+
6
+ class SparqlTest < Test::Unit::TestCase
7
+
8
+ def test_simple_query
9
+
10
+ mc = mock()
11
+ mc.expects(:get).with("http://www.example.org/sparql", {"query" => "SPARQL"}, {})
12
+
13
+ sparql_client = Kasabi::Sparql::Client.new("http://www.example.org/sparql",
14
+ {:client => mc})
15
+ sparql_client.query("SPARQL")
16
+
17
+ end
18
+
19
+ def test_query_with_default_graph
20
+
21
+ mc = mock()
22
+ mc.expects(:get).with("http://www.example.org/sparql", {"query" => "SPARQL", "default-graph-uri" => ["http://www.example.com"]}, {})
23
+
24
+ sparql_client = Kasabi::Sparql::Client.new("http://www.example.org/sparql", {:client => mc})
25
+ sparql_client.add_default_graph("http://www.example.com")
26
+ sparql_client.query("SPARQL")
27
+
28
+ end
29
+
30
+ def test_query_with_named_graph
31
+
32
+ mc = mock()
33
+ mc.expects(:get).with("http://www.example.org/sparql", {"query" => "SPARQL", "named-graph-uri" => ["http://www.example.com"]}, {})
34
+
35
+ sparql_client = Kasabi::Sparql::Client.new("http://www.example.org/sparql", {:client => mc})
36
+ sparql_client.add_named_graph("http://www.example.com")
37
+ sparql_client.query("SPARQL")
38
+
39
+ end
40
+
41
+ def test_query_with_both_graphs
42
+
43
+ mc = mock()
44
+ mc.expects(:get).with("http://www.example.org/sparql", {"query" => "SPARQL", "named-graph-uri" => ["http://www.example.com"], "default-graph-uri" => ["http://www.example.org"]}, {})
45
+
46
+ sparql_client = Kasabi::Sparql::Client.new("http://www.example.org/sparql", {:client => mc})
47
+ sparql_client.add_named_graph("http://www.example.com")
48
+ sparql_client.add_default_graph("http://www.example.org")
49
+ sparql_client.query("SPARQL")
50
+
51
+ end
52
+
53
+ def test_sparql_with_mimetype
54
+ mc = mock()
55
+ mc.expects(:get).with("http://www.example.org/sparql", {"query" => "SPARQL"}, {"Accept" => "application/sparql-results+xml"})
56
+
57
+ sparql_client = Kasabi::Sparql::Client.new("http://www.example.org/sparql", {:client => mc})
58
+ sparql_client.query("SPARQL", "application/sparql-results+xml")
59
+
60
+ end
61
+
62
+ def test_ask
63
+ mc = mock()
64
+ mc.expects(:get).with("http://api.talis.com/stores/testing/services/sparql", {"query" => "SPARQL"}, {"Accept" => "application/sparql-results+json"} ).returns(
65
+ HTTP::Message.new_response("RESULTS"))
66
+
67
+ client = Kasabi::Sparql::Client.new("http://api.talis.com/stores/testing/services/sparql", {:client => mc})
68
+ response = client.ask("SPARQL")
69
+ assert_equal("RESULTS", response.content)
70
+ end
71
+
72
+ def test_store_sparql_select
73
+ mc = mock()
74
+ mc.expects(:get).with("http://api.talis.com/stores/testing/services/sparql", {"query" => "SPARQL"}, {"Accept" => "application/sparql-results+json"} ).returns(
75
+ HTTP::Message.new_response("RESULTS"))
76
+
77
+ client = Kasabi::Sparql::Client.new("http://api.talis.com/stores/testing/services/sparql", {:client => mc})
78
+ response = client.select("SPARQL")
79
+ assert_equal("RESULTS", response.content)
80
+ end
81
+
82
+ def test_construct
83
+ mc = mock()
84
+ mc.expects(:get).with("http://api.talis.com/stores/testing/services/sparql", {"query" => "SPARQL"}, {"Accept" => "application/rdf+xml"} ).returns(
85
+ HTTP::Message.new_response("RESULTS"))
86
+
87
+ client = Kasabi::Sparql::Client.new("http://api.talis.com/stores/testing/services/sparql", {:client => mc})
88
+ response = client.construct("SPARQL")
89
+ assert_equal("RESULTS", response.content)
90
+ end
91
+
92
+ def test_describe
93
+ mc = mock()
94
+ mc.expects(:get).with("http://api.talis.com/stores/testing/services/sparql", {"query" => "SPARQL"}, {"Accept" => "application/rdf+xml"} ).returns(
95
+ HTTP::Message.new_response("RESULTS"))
96
+
97
+ client = Kasabi::Sparql::Client.new("http://api.talis.com/stores/testing/services/sparql", {:client => mc})
98
+ response = client.describe("SPARQL")
99
+ assert_equal("RESULTS", response.content)
100
+ end
101
+
102
+ def test_multi_describe
103
+ mc = mock()
104
+ mc.expects(:get).with("http://api.talis.com/stores/testing/services/sparql",
105
+ {"query" => "DESCRIBE <http://www.example.org> <http://www.example.com>"},
106
+ {"Accept" => "application/rdf+xml"} ).returns( HTTP::Message.new_response("RESULTS"))
107
+
108
+ client = Kasabi::Sparql::Client.new("http://api.talis.com/stores/testing/services/sparql", {:client => mc})
109
+ uris = []
110
+ uris << "http://www.example.org"
111
+ uris << "http://www.example.com"
112
+ response = client.multi_describe(uris)
113
+ assert_equal("RESULTS", response.content)
114
+
115
+ end
116
+
117
+ def test_describe_uri
118
+ mc = mock()
119
+ mc.expects(:get).with("http://api.talis.com/stores/testing/services/sparql", {"query" => "DESCRIBE <http://www.example.org>"}, {"Accept" => "application/rdf+xml"} ).returns(
120
+ HTTP::Message.new_response("RESULTS"))
121
+
122
+ client = Kasabi::Sparql::Client.new("http://api.talis.com/stores/testing/services/sparql", {:client => mc})
123
+ response = client.describe_uri("http://www.example.org")
124
+ assert_equal("RESULTS", response.content)
125
+ end
126
+
127
+ def test_describe_uri_using_cbd
128
+ mc = mock()
129
+ mc.expects(:get).with("http://api.talis.com/stores/testing/services/sparql", {"query" => "DESCRIBE <http://www.example.org>"}, {"Accept" => "application/rdf+xml"} ).returns(
130
+ HTTP::Message.new_response("RESULTS"))
131
+
132
+ client = Kasabi::Sparql::Client.new("http://api.talis.com/stores/testing/services/sparql", {:client => mc})
133
+ response = client.describe_uri("http://www.example.org", "application/rdf+xml", :cbd)
134
+ assert_equal("RESULTS", response.content)
135
+ end
136
+
137
+ def test_describe_uri_using_lcbd
138
+ mc = mock()
139
+ mc.expects(:get).with("http://api.talis.com/stores/testing/services/sparql", anything, {"Accept" => "application/rdf+xml"} ).returns(
140
+ HTTP::Message.new_response("RESULTS"))
141
+
142
+ client = Kasabi::Sparql::Client.new("http://api.talis.com/stores/testing/services/sparql", {:client => mc})
143
+ response = client.describe_uri("http://www.example.org", "application/rdf+xml", :lcbd)
144
+ assert_equal("RESULTS", response.content)
145
+ end
146
+
147
+ def test_describe_uri_using_scbd
148
+ mc = mock()
149
+ mc.expects(:get).with("http://api.talis.com/stores/testing/services/sparql", anything, {"Accept" => "application/rdf+xml"} ).returns(
150
+ HTTP::Message.new_response("RESULTS"))
151
+
152
+ client = Kasabi::Sparql::Client.new("http://api.talis.com/stores/testing/services/sparql", {:client => mc})
153
+ response = client.describe_uri("http://www.example.org", "application/rdf+xml", :scbd)
154
+ assert_equal("RESULTS", response.content)
155
+ end
156
+
157
+ def test_describe_uri_using_slcbd
158
+ mc = mock()
159
+ mc.expects(:get).with("http://api.talis.com/stores/testing/services/sparql", anything, {"Accept" => "application/rdf+xml"} ).returns(
160
+ HTTP::Message.new_response("RESULTS"))
161
+
162
+ client = Kasabi::Sparql::Client.new("http://api.talis.com/stores/testing/services/sparql", {:client => mc})
163
+ response = client.describe_uri("http://www.example.org", "application/rdf+xml", :slcbd)
164
+ assert_equal("RESULTS", response.content)
165
+ end
166
+
167
+ def test_describe_uri_using_unknown
168
+ mc = mock()
169
+
170
+ client = Kasabi::Sparql::Client.new("http://api.talis.com/stores/testing/services/sparql", {:client => mc})
171
+ assert_raises RuntimeError do
172
+ response = client.describe_uri("http://www.example.org", "application/rdf+xml", :unknown)
173
+ end
174
+
175
+ end
176
+
177
+ end