pho 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README +56 -0
- data/Rakefile +63 -0
- data/lib/pho.rb +21 -0
- data/lib/pho/etags.rb +54 -0
- data/lib/pho/rdf_collection.rb +107 -0
- data/lib/pho/store.rb +389 -0
- data/lib/test.rb +29 -0
- data/tests/tc_contentbox.rb +96 -0
- data/tests/tc_etags.rb +38 -0
- data/tests/tc_jobcontrol.rb +59 -0
- data/tests/tc_metabox.rb +124 -0
- data/tests/tc_rdf_collection.rb +127 -0
- data/tests/tc_search.rb +54 -0
- data/tests/tc_sparql.rb +76 -0
- data/tests/tc_store_util.rb +14 -0
- data/tests/ts_pho.rb +10 -0
- metadata +102 -0
data/lib/test.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'pho'
|
2
|
+
|
3
|
+
store = Pho::Store.new("http://api.talis.local/stores/space", "ldodds", "gwpjmv7z")
|
4
|
+
|
5
|
+
state = store.status()
|
6
|
+
puts state.inspect
|
7
|
+
|
8
|
+
resp = store.store_file("/home/ldodds/data/space/nssdc/n3/1969-059A.rdf")
|
9
|
+
puts resp
|
10
|
+
puts resp.status
|
11
|
+
|
12
|
+
resp = store.store_file(File.new("/home/ldodds/data/space/nssdc/n3/1969-059B.rdf") )
|
13
|
+
puts resp.status
|
14
|
+
|
15
|
+
resp = store.store_url("http://api.talis.local/stores/space/meta?about=http://purl.org/net/schemas/space/spacecraft/1969-059A")
|
16
|
+
puts resp.status
|
17
|
+
|
18
|
+
resp = store.store_url( URI.parse("http://api.talis.local/stores/space/meta?about=http://purl.org/net/schemas/space/spacecraft/1969-059A") )
|
19
|
+
puts resp.status
|
20
|
+
|
21
|
+
resp = store.describe("http://purl.org/net/schemas/space/spacecraft/1969-059A")
|
22
|
+
puts resp
|
23
|
+
|
24
|
+
resp = store.describe("http://purl.org/net/schemas/space/spacecraft/1969-059A", "application/json")
|
25
|
+
puts resp
|
26
|
+
|
27
|
+
store.snapshot
|
28
|
+
store.reindex
|
29
|
+
store.reset
|
@@ -0,0 +1,96 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
2
|
+
require 'pho'
|
3
|
+
require 'test/unit'
|
4
|
+
require 'mocha'
|
5
|
+
|
6
|
+
class ContentboxTest < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def test_upload_item
|
9
|
+
mc = mock()
|
10
|
+
mc.expects(:set_auth)
|
11
|
+
mc.expects(:post).with("http://api.talis.com/stores/testing/items", "data", {"Content-Type" => "text/plain"})
|
12
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
|
13
|
+
f = StringIO.new("data")
|
14
|
+
resp = store.upload_item(f, "text/plain")
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_upload_item_to_uri
|
18
|
+
mc = mock()
|
19
|
+
mc.expects(:set_auth)
|
20
|
+
mc.expects(:put).with("http://api.talis.com/stores/testing/items/1/2/3", "data", {"Content-Type" => "text/plain"})
|
21
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
|
22
|
+
f = StringIO.new("data")
|
23
|
+
resp = store.upload_item(f, "text/plain", "http://api.talis.com/stores/testing/items/1/2/3")
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_delete
|
28
|
+
mc = mock()
|
29
|
+
mc.expects(:set_auth)
|
30
|
+
mc.expects(:delete).with("http://api.talis.com/stores/testing/items/1/2/3")
|
31
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
|
32
|
+
store.delete_item("http://api.talis.com/stores/testing/items/1/2/3")
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_delete_with_relative_uri
|
36
|
+
mc = mock()
|
37
|
+
mc.expects(:set_auth)
|
38
|
+
mc.expects(:delete).with("http://api.talis.com/stores/testing/items/1/2/3")
|
39
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
|
40
|
+
store.delete_item("/items/1/2/3")
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_get_item
|
44
|
+
mc = mock()
|
45
|
+
mc.expects(:set_auth)
|
46
|
+
mc.expects(:get).with("http://api.talis.com/stores/testing/items/1/2/3", anything, anything).returns( HTTP::Message.new_response("data") )
|
47
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
|
48
|
+
resp = store.get_item("/items/1/2/3")
|
49
|
+
assert_equal(true, resp != nil)
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_get_item_with_conditional_get
|
53
|
+
mc = mock()
|
54
|
+
mc.expects(:set_auth)
|
55
|
+
mc.expects(:get).with("http://api.talis.com/stores/testing/items/1/2/3", nil, {"If-None-Match" => "abcdef"}).returns( HTTP::Message.new_response("data") )
|
56
|
+
|
57
|
+
etags = Pho::Etags.new
|
58
|
+
etags.add("http://api.talis.com/stores/testing/items/1/2/3", "abcdef")
|
59
|
+
|
60
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
|
61
|
+
resp = store.get_item("/items/1/2/3", etags)
|
62
|
+
assert_equal(true, resp != nil)
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_get_item_with_if_match
|
66
|
+
mc = mock()
|
67
|
+
mc.expects(:set_auth)
|
68
|
+
mc.expects(:get).with("http://api.talis.com/stores/testing/items/1/2/3", nil, {"If-Match" => "abcdef"}).returns( HTTP::Message.new_response("data") )
|
69
|
+
|
70
|
+
etags = Pho::Etags.new
|
71
|
+
etags.add("http://api.talis.com/stores/testing/items/1/2/3", "abcdef")
|
72
|
+
|
73
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
|
74
|
+
resp = store.get_item("/items/1/2/3", etags, :ifmatch)
|
75
|
+
assert_equal(true, resp != nil)
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_get_item_with_if_none_match_and_modified
|
80
|
+
r = HTTP::Message.new_response("data")
|
81
|
+
r.header["ETag"] = "zebra"
|
82
|
+
|
83
|
+
mc = mock()
|
84
|
+
mc.expects(:set_auth)
|
85
|
+
mc.expects(:get).with("http://api.talis.com/stores/testing/items/1/2/3", nil, {"If-None-Match" => "abcdef"}).returns( r )
|
86
|
+
|
87
|
+
etags = Pho::Etags.new
|
88
|
+
etags.add("http://api.talis.com/stores/testing/items/1/2/3", "abcdef")
|
89
|
+
|
90
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
|
91
|
+
resp = store.get_item("/items/1/2/3", etags)
|
92
|
+
assert_equal(true, resp != nil)
|
93
|
+
assert_equal("zebra", etags.get("http://api.talis.com/stores/testing/items/1/2/3"))
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
data/tests/tc_etags.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
2
|
+
require 'pho'
|
3
|
+
require 'test/unit'
|
4
|
+
require 'yaml'
|
5
|
+
class EtagsTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def test_it()
|
8
|
+
|
9
|
+
io = StringIO.new("---\n- http://www.example.org : '12345'")
|
10
|
+
etags = Pho::Etags.new(io)
|
11
|
+
|
12
|
+
assert_equal(true, etags.has_tag?("http://www.example.org") )
|
13
|
+
assert_equal("12345", etags.get("http://www.example.org") )
|
14
|
+
|
15
|
+
etags.add("http://www.example.com/foo", "abc")
|
16
|
+
assert_equal(false, etags.saved)
|
17
|
+
|
18
|
+
etags.save()
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_overwrite()
|
23
|
+
etags = Pho::Etags.new()
|
24
|
+
etags.add("http://www.example.org", "etag")
|
25
|
+
assert_equal("etag", etags.get("http://www.example.org") )
|
26
|
+
etags.add("http://www.example.org", "etag_updated")
|
27
|
+
assert_equal("etag_updated", etags.get("http://www.example.org") )
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_add_from_response()
|
31
|
+
response = HTTP::Message.new_response("description")
|
32
|
+
response.header["ETag"] = "abcdef"
|
33
|
+
etags = Pho::Etags.new()
|
34
|
+
etags.add_from_response("http://www.example.org", response)
|
35
|
+
assert_equal("abcdef", etags.get("http://www.example.org") )
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
2
|
+
require 'pho'
|
3
|
+
require 'test/unit'
|
4
|
+
require 'mocha'
|
5
|
+
|
6
|
+
class JobControlTest < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def test_build_job_request
|
9
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass")
|
10
|
+
job_req = store.build_job_request(Time.now, "http://www.example.org/ns/jobtype", "test label")
|
11
|
+
|
12
|
+
assert_equal(true, job_req.index( "<rdfs:label>test label</rdfs:label>") != nil )
|
13
|
+
assert_equal(true, job_req.index( "rdf:resource=\"""http://www.example.org/ns/jobtype\"""/>") != nil )
|
14
|
+
end
|
15
|
+
|
16
|
+
def set_expectations(url, mc, jobtype, label)
|
17
|
+
mc.expects(:set_auth)
|
18
|
+
mc.expects(:post).with() { |passedurl, data, headers|
|
19
|
+
assert_equal("#{url}/jobs", passedurl)
|
20
|
+
assert_equal("application/rdf+xml", headers["Content-Type"])
|
21
|
+
|
22
|
+
assert_equal(true, data.index( "<rdfs:label>#{label}</rdfs:label>") != nil )
|
23
|
+
assert_equal(true, data.index( "rdf:resource=\"""#{jobtype}\"""/>") != nil )
|
24
|
+
true
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_submit_job
|
29
|
+
mc = mock()
|
30
|
+
set_expectations("http://api.talis.com/stores/testing", mc, "http://www.example.org/ns/jobtype", "test label" )
|
31
|
+
|
32
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
|
33
|
+
job_req = store.submit_job("http://www.example.org/ns/jobtype", "test label")
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_reset
|
38
|
+
mc = mock()
|
39
|
+
set_expectations("http://api.talis.com/stores/testing", mc, Pho::JOB_RESET, "Reset my store" )
|
40
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
|
41
|
+
job_req = store.reset()
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_reindex
|
45
|
+
mc = mock()
|
46
|
+
set_expectations("http://api.talis.com/stores/testing", mc, Pho::JOB_REINDEX, "Reindex my store" )
|
47
|
+
|
48
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
|
49
|
+
job_req = store.reindex()
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_snapshot
|
53
|
+
mc = mock()
|
54
|
+
set_expectations("http://api.talis.com/stores/testing", mc, Pho::JOB_SNAPSHOT, "Snapshot my store" )
|
55
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
|
56
|
+
job_req = store.snapshot()
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
data/tests/tc_metabox.rb
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
2
|
+
require 'pho'
|
3
|
+
require 'test/unit'
|
4
|
+
require 'mocha'
|
5
|
+
|
6
|
+
class MetaboxTest < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def test_constructor
|
9
|
+
mc = mock()
|
10
|
+
mc.expects(:set_auth).with("http://api.talis.com/stores/testing", "user", "pass")
|
11
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
|
12
|
+
assert_equal(mc, store.client)
|
13
|
+
assert_equal("http://api.talis.com/stores/testing", store.storeuri)
|
14
|
+
assert_equal("user", store.username)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_store_data
|
18
|
+
mc = mock()
|
19
|
+
mc.expects(:set_auth)
|
20
|
+
mc.expects(:post).with("http://api.talis.com/stores/testing/meta", "data", {"Content-Type" => "application/rdf+xml"} )
|
21
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
|
22
|
+
store.store_data("data")
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_store_file
|
26
|
+
mc = mock()
|
27
|
+
mc.expects(:set_auth)
|
28
|
+
mc.expects(:post).with("http://api.talis.com/stores/testing/meta", "data", {"Content-Type" => "application/rdf+xml"} )
|
29
|
+
|
30
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
|
31
|
+
io = StringIO.new("data")
|
32
|
+
store.store_file( io )
|
33
|
+
assert_equal(true, io.closed?)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_store_url
|
37
|
+
mc = mock()
|
38
|
+
mc.expects(:set_auth)
|
39
|
+
mc.expects(:get).with("http://www.example.org", nil, {"Accept" => "application/rdf+xml"}).returns( HTTP::Message.new_response("data") )
|
40
|
+
mc.expects(:post).with("http://api.talis.com/stores/testing/meta", "data", {"Content-Type" => "application/rdf+xml"} )
|
41
|
+
|
42
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
|
43
|
+
store.store_url( "http://www.example.org" )
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_describe_with_default_mimetype
|
47
|
+
mc = mock()
|
48
|
+
mc.expects(:set_auth)
|
49
|
+
mc.expects(:get).with("http://api.talis.com/stores/testing/meta", {"about" => "http://www.example.org"}, {"Accept" => "application/rdf+xml"}).returns(
|
50
|
+
HTTP::Message.new_response("description") )
|
51
|
+
|
52
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
|
53
|
+
response = store.describe("http://www.example.org")
|
54
|
+
assert_equal("description", response.content)
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_describe_with_json
|
58
|
+
mc = mock()
|
59
|
+
mc.expects(:set_auth)
|
60
|
+
mc.expects(:get).with("http://api.talis.com/stores/testing/meta", {"about" => "http://www.example.org"}, {"Accept" => "application/json"}).returns(
|
61
|
+
HTTP::Message.new_response("description"))
|
62
|
+
|
63
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
|
64
|
+
response = store.describe("http://www.example.org", "application/json")
|
65
|
+
assert_equal("description", response.content)
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_describe_with_conditional_get
|
69
|
+
mc = mock()
|
70
|
+
mc.expects(:set_auth)
|
71
|
+
mc.expects(:get).with("http://api.talis.com/stores/testing/meta", {"about" => "http://www.example.org"},
|
72
|
+
{"Accept" => "application/rdf+xml", "If-None-Match" => "1234"}).returns( HTTP::Message.new_response("description") )
|
73
|
+
|
74
|
+
etags = Pho::Etags.new()
|
75
|
+
etags.add("http://api.talis.com/stores/testing/meta?about=http://www.example.org", "1234")
|
76
|
+
|
77
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
|
78
|
+
response = store.describe("http://www.example.org", "application/rdf+xml", etags)
|
79
|
+
assert_equal("description", response.content)
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_describe_with_if_match
|
84
|
+
mc = mock()
|
85
|
+
mc.expects(:set_auth)
|
86
|
+
mc.expects(:get).with("http://api.talis.com/stores/testing/meta", {"about" => "http://www.example.org"},
|
87
|
+
{"Accept" => "application/rdf+xml", "If-Match" => "1234"}).returns( HTTP::Message.new_response("description") )
|
88
|
+
|
89
|
+
etags = Pho::Etags.new()
|
90
|
+
etags.add("http://api.talis.com/stores/testing/meta?about=http://www.example.org", "1234")
|
91
|
+
|
92
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
|
93
|
+
response = store.describe("http://www.example.org", "application/rdf+xml", etags, :ifmatch)
|
94
|
+
assert_equal("description", response.content)
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_describe_with_if_none_match_and_changed
|
99
|
+
r = HTTP::Message.new_response("description")
|
100
|
+
r.header["ETag"] = "abcdef"
|
101
|
+
|
102
|
+
mc = mock()
|
103
|
+
mc.expects(:set_auth)
|
104
|
+
mc.expects(:get).with("http://api.talis.com/stores/testing/meta", {"about" => "http://www.example.org"},
|
105
|
+
{"Accept" => "application/rdf+xml", "If-None-Match" => "1234"}).returns( r )
|
106
|
+
|
107
|
+
etags = Pho::Etags.new
|
108
|
+
etags.add("http://api.talis.com/stores/testing/meta?about=http://www.example.org", "1234")
|
109
|
+
|
110
|
+
#etags = mock()
|
111
|
+
#etags.stub_everything
|
112
|
+
#etags.expects(:has_tag?).with("http://api.talis.com/stores/testing/meta?about=http://www.example.org").returns(true)
|
113
|
+
#etags.expects(:get).with("http://api.talis.com/stores/testing/meta?about=http://www.example.org").returns("1234")
|
114
|
+
#etags.expects(:add).with("http://api.talis.com/stores/testing/meta?about=http://www.example.org", "abcdef")
|
115
|
+
|
116
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
|
117
|
+
response = store.describe("http://www.example.org", "application/rdf+xml", etags)
|
118
|
+
|
119
|
+
assert_equal("description", response.content)
|
120
|
+
assert_equal("abcdef", etags.get("http://api.talis.com/stores/testing/meta?about=http://www.example.org"))
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
2
|
+
require 'pho'
|
3
|
+
require 'test/unit'
|
4
|
+
require 'mocha'
|
5
|
+
|
6
|
+
class RDFCollectionTest < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def setup()
|
9
|
+
10.times do |i|
|
10
|
+
file = File.new( File.join("/tmp", "#{i}.rdf"), "w" )
|
11
|
+
file.write("RDF#{i}")
|
12
|
+
file.close()
|
13
|
+
end
|
14
|
+
4.times do |i|
|
15
|
+
file = File.new( File.join("/tmp", "#{i}.ok"), "w" )
|
16
|
+
file.write("OK")
|
17
|
+
file.close()
|
18
|
+
end
|
19
|
+
3.times do |i|
|
20
|
+
num = 4 + i
|
21
|
+
file = File.new( File.join("/tmp", "#{num}.fail"), "w" )
|
22
|
+
file.write("FAIL")
|
23
|
+
file.close()
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def teardown()
|
28
|
+
Dir.glob("/tmp/*.rdf") do |file|
|
29
|
+
File.delete(file)
|
30
|
+
end
|
31
|
+
Dir.glob("/tmp/*.ok") do |file|
|
32
|
+
File.delete(file)
|
33
|
+
end
|
34
|
+
Dir.glob("/tmp/*.fail") do |file|
|
35
|
+
File.delete(file)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_get_fail_file_for()
|
40
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass")
|
41
|
+
collection = Pho::RDFCollection.new(store, "/tmp")
|
42
|
+
|
43
|
+
assert_equal("foo.fail", collection.get_fail_file_for("foo.rdf") )
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_get_ok_file_for()
|
47
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass")
|
48
|
+
collection = Pho::RDFCollection.new(store, "/tmp")
|
49
|
+
|
50
|
+
assert_equal("foo.ok", collection.get_ok_file_for("foo.rdf") )
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_successes()
|
54
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass")
|
55
|
+
collection = Pho::RDFCollection.new(store, "/tmp")
|
56
|
+
|
57
|
+
success = collection.successes()
|
58
|
+
success.sort!
|
59
|
+
assert_equal(4, success.size)
|
60
|
+
assert_equal("/tmp/0.rdf", success[0])
|
61
|
+
assert_equal("/tmp/1.rdf", success[1])
|
62
|
+
assert_equal("/tmp/2.rdf", success[2])
|
63
|
+
assert_equal("/tmp/3.rdf", success[3])
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_failures()
|
67
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass")
|
68
|
+
collection = Pho::RDFCollection.new(store, "/tmp")
|
69
|
+
|
70
|
+
fails = collection.failures()
|
71
|
+
fails.sort!
|
72
|
+
assert_equal(3, fails.size)
|
73
|
+
assert_equal("/tmp/4.rdf", fails[0])
|
74
|
+
assert_equal("/tmp/5.rdf", fails[1])
|
75
|
+
assert_equal("/tmp/6.rdf", fails[2])
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_new_files()
|
79
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass")
|
80
|
+
collection = Pho::RDFCollection.new(store, "/tmp")
|
81
|
+
|
82
|
+
newfiles = collection.new_files()
|
83
|
+
newfiles.sort!
|
84
|
+
assert_equal(3, newfiles.size)
|
85
|
+
assert_equal("/tmp/7.rdf", newfiles[0])
|
86
|
+
assert_equal("/tmp/8.rdf", newfiles[1])
|
87
|
+
assert_equal("/tmp/9.rdf", newfiles[2])
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_store()
|
92
|
+
mc = mock()
|
93
|
+
mc.stub_everything()
|
94
|
+
mc.expects(:post).with("http://api.talis.com/stores/testing/meta", "RDF7", {"Content-Type" => "application/rdf+xml"})
|
95
|
+
mc.expects(:post).with("http://api.talis.com/stores/testing/meta", "RDF8", {"Content-Type" => "application/rdf+xml"})
|
96
|
+
mc.expects(:post).with("http://api.talis.com/stores/testing/meta", "RDF9", {"Content-Type" => "application/rdf+xml"})
|
97
|
+
|
98
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
|
99
|
+
collection = Pho::RDFCollection.new(store, "/tmp")
|
100
|
+
collection.store()
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_reset()
|
104
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass")
|
105
|
+
collection = Pho::RDFCollection.new(store, "/tmp")
|
106
|
+
|
107
|
+
collection.reset()
|
108
|
+
newfiles = collection.new_files()
|
109
|
+
assert_equal(10, newfiles.size)
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_list()
|
113
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass")
|
114
|
+
collection = Pho::RDFCollection.new(store, "/tmp")
|
115
|
+
|
116
|
+
files = collection.list()
|
117
|
+
assert_equal(10, files.size)
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_summary()
|
121
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass")
|
122
|
+
collection = Pho::RDFCollection.new(store, "/tmp")
|
123
|
+
|
124
|
+
collection.summary()
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|