duracloud-client 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,140 @@
1
1
  module Duracloud
2
2
  RSpec.describe Space do
3
- # TODO
3
+
4
+ describe "listings" do
5
+ let(:body) { <<-EOS
6
+ <?xml version="1.0" encoding="UTF-8"?>
7
+ <spaces>
8
+ <space id="space1" />
9
+ <space id="space2" />
10
+ </spaces>
11
+ EOS
12
+ }
13
+ before {
14
+ stub_request(:get, "https://example.com/durastore/spaces")
15
+ .to_return(body: body)
16
+ }
17
+ describe ".all" do
18
+ specify {
19
+ expect(Space.all.map(&:id)).to eq(["space1", "space2"])
20
+ }
21
+ end
22
+ describe ".ids" do
23
+ specify {
24
+ expect(Space.ids).to eq(["space1", "space2"])
25
+ }
26
+ end
27
+ end
28
+
29
+ describe ".create" do
30
+ describe "invalid space ID" do
31
+ before {
32
+ stub_request(:put, "https://example.com/durastore/INVALID")
33
+ .to_return(status: 400)
34
+ }
35
+ specify {
36
+ expect { Space.create("INVALID") }.to raise_error(BadRequestError)
37
+ }
38
+ end
39
+ describe "valid space ID" do
40
+ subject { Space.create("valid") }
41
+ before {
42
+ stub_request(:put, "https://example.com/durastore/valid")
43
+ }
44
+ it { is_expected.to be_a(Space) }
45
+ its(:space_id) { is_expected.to eq("valid") }
46
+ end
47
+ end
48
+
49
+ describe ".find" do
50
+ let(:url) { "https://example.com/durastore/foo" }
51
+ subject { Space.find("foo") }
52
+ describe "when found" do
53
+ before {
54
+ stub_request(:head, url)
55
+ }
56
+ it { is_expected.to be_a(Space) }
57
+ its(:space_id) { is_expected.to eq("foo") }
58
+ end
59
+ describe "when not found" do
60
+ before {
61
+ stub_request(:head, url).to_return(status: 404)
62
+ }
63
+ specify {
64
+ expect { subject }.to raise_error(NotFoundError)
65
+ }
66
+ end
67
+ end
68
+
69
+ describe ".exist?" do
70
+ let(:url) { "https://example.com/durastore/foo" }
71
+ subject { Space.exist?("foo") }
72
+ describe "when found" do
73
+ before {
74
+ stub_request(:head, url)
75
+ }
76
+ it { is_expected.to be true }
77
+ end
78
+ describe "when not found" do
79
+ before {
80
+ stub_request(:head, url).to_return(status: 404)
81
+ }
82
+ it { is_expected.to be false }
83
+ end
84
+ end
85
+
86
+ describe "#save"
87
+
88
+ describe "#delete"
89
+
90
+ describe "#acls"
91
+
92
+ describe "contents" do
93
+ let(:body) { <<-EOS
94
+ <?xml version="1.0" encoding="UTF-8"?>
95
+ <space id="rest-api-testing">
96
+ <item>foo1</item>
97
+ <item>foo2</item>
98
+ <item>foo3</item>
99
+ </space>
100
+ EOS
101
+ }
102
+ let(:url) { "https://example.com/durastore/foo" }
103
+ before {
104
+ stub_request(:head, url)
105
+ .to_return(headers: {
106
+ 'x-dura-meta-space-count'=>'3',
107
+ 'x-dura-meta-space-created'=>'2016-04-05T17:59:11'
108
+ })
109
+ stub_request(:get, url).to_return(body: body)
110
+ }
111
+ describe ".content_ids", pending: "Correcting the stub request" do
112
+ subject { Space.content_ids("foo") }
113
+ its(:to_a) { is_expected.to eq(["foo1", "foo2", "foo3"]) }
114
+ end
115
+ describe "#content_ids" do
116
+ subject { Space.find("foo") }
117
+ specify {
118
+ pending "Correcting the stub request"
119
+ expect(subject.content_ids.to_a).to eq(["foo1", "foo2", "foo3"])
120
+ }
121
+ end
122
+
123
+ describe ".items"
124
+ describe "#items"
125
+
126
+ describe ".count"
127
+ describe "#count"
128
+ end
129
+
130
+ describe ".audit_log"
131
+ describe "#audit_log"
132
+
133
+ describe ".bit_integrity_report"
134
+ describe "#bit_integrity_report"
135
+
136
+ describe ".manifest"
137
+ describe "#manifest"
138
+
4
139
  end
5
140
  end
@@ -1,5 +1,40 @@
1
1
  module Duracloud
2
2
  RSpec.describe Store do
3
- # TODO
3
+
4
+ let(:url) { "https://example.com/durastore/stores" }
5
+
6
+ let(:body) { <<-EOS
7
+ <?xml version="1.0" encoding="UTF-8"?>
8
+ <storageProviderAccounts>
9
+ <storageAcct ownerId="0" isPrimary="0">
10
+ <id>1</id>
11
+ <storageProviderType>AMAZON_GLACIER</storageProviderType>
12
+ </storageAcct>
13
+ <storageAcct ownerId="0" isPrimary="1">
14
+ <id>2</id>
15
+ <storageProviderType>AMAZON_S3</storageProviderType>
16
+ </storageAcct>
17
+ </storageProviderAccounts>
18
+ EOS
19
+ }
20
+
21
+ before {
22
+ stub_request(:get, url).to_return(body: body)
23
+ }
24
+
25
+ describe ".all" do
26
+ subject { Store.all }
27
+ specify {
28
+ expect(subject.map(&:provider_type)).to contain_exactly("AMAZON_GLACIER", "AMAZON_S3")
29
+ }
30
+ end
31
+
32
+ describe ".primary" do
33
+ subject { Store.primary }
34
+ specify {
35
+ expect(subject.id).to eq("2")
36
+ }
37
+ end
38
+
4
39
  end
5
40
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: duracloud-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Chandek-Stark
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-28 00:00:00.000000000 Z
11
+ date: 2016-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.6'
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rspec
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -139,12 +153,14 @@ files:
139
153
  - duracloud.gemspec
140
154
  - lib/duracloud-client.rb
141
155
  - lib/duracloud.rb
156
+ - lib/duracloud/audit_log.rb
142
157
  - lib/duracloud/bit_integrity_report.rb
143
158
  - lib/duracloud/client.rb
144
159
  - lib/duracloud/configuration.rb
145
160
  - lib/duracloud/connection.rb
146
161
  - lib/duracloud/content.rb
147
162
  - lib/duracloud/content_properties.rb
163
+ - lib/duracloud/csv_reader.rb
148
164
  - lib/duracloud/durastore_request.rb
149
165
  - lib/duracloud/error.rb
150
166
  - lib/duracloud/error_handler.rb
@@ -160,12 +176,12 @@ files:
160
176
  - lib/duracloud/space_properties.rb
161
177
  - lib/duracloud/store.rb
162
178
  - lib/duracloud/version.rb
163
- - spec/fixtures/responses/GetManifest.tsv
164
- - spec/fixtures/responses/GetSpaces.xml
165
- - spec/fixtures/responses/GetStores.xml
166
179
  - spec/spec_helper.rb
180
+ - spec/unit/audit_log_spec.rb
181
+ - spec/unit/bit_integrity_report_spec.rb
167
182
  - spec/unit/client_spec.rb
168
183
  - spec/unit/content_spec.rb
184
+ - spec/unit/manifest_spec.rb
169
185
  - spec/unit/properties_spec.rb
170
186
  - spec/unit/space_spec.rb
171
187
  - spec/unit/store_spec.rb
@@ -194,12 +210,12 @@ signing_key:
194
210
  specification_version: 4
195
211
  summary: Ruby client for communicating with DuraCloud
196
212
  test_files:
197
- - spec/fixtures/responses/GetManifest.tsv
198
- - spec/fixtures/responses/GetSpaces.xml
199
- - spec/fixtures/responses/GetStores.xml
200
213
  - spec/spec_helper.rb
214
+ - spec/unit/audit_log_spec.rb
215
+ - spec/unit/bit_integrity_report_spec.rb
201
216
  - spec/unit/client_spec.rb
202
217
  - spec/unit/content_spec.rb
218
+ - spec/unit/manifest_spec.rb
203
219
  - spec/unit/properties_spec.rb
204
220
  - spec/unit/space_spec.rb
205
221
  - spec/unit/store_spec.rb
@@ -1,5 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <spaces>
3
- <space id="space1" />
4
- <space id="space2" />
5
- </spaces>
@@ -1,11 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <storageProviderAccounts>
3
- <storageAcct ownerId="0" isPrimary="0">
4
- <id>1</id>
5
- <storageProviderType>AMAZON_GLACIER</storageProviderType>
6
- </storageAcct>
7
- <storageAcct ownerId="0" isPrimary="1">
8
- <id>2</id>
9
- <storageProviderType>AMAZON_S3</storageProviderType>
10
- </storageAcct>
11
- </storageProviderAccounts>