fog 0.0.4 → 0.0.5

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{fog}
8
- s.version = "0.0.4"
8
+ s.version = "0.0.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Wesley Beary"]
12
- s.date = %q{2009-09-04}
12
+ s.date = %q{2009-09-08}
13
13
  s.description = %q{brings clouds to you}
14
14
  s.email = %q{me@geemus.com}
15
15
  s.extra_rdoc_files = [
@@ -36,6 +36,8 @@ Gem::Specification.new do |s|
36
36
  "lib/fog/aws/models/ec2/addresses.rb",
37
37
  "lib/fog/aws/models/ec2/key_pair.rb",
38
38
  "lib/fog/aws/models/ec2/key_pairs.rb",
39
+ "lib/fog/aws/models/ec2/snapshot.rb",
40
+ "lib/fog/aws/models/ec2/snapshots.rb",
39
41
  "lib/fog/aws/models/ec2/volume.rb",
40
42
  "lib/fog/aws/models/ec2/volumes.rb",
41
43
  "lib/fog/aws/models/s3/bucket.rb",
@@ -25,6 +25,10 @@ module Fog
25
25
  "us-east-1" << random_selection('abcd', 1)
26
26
  end
27
27
 
28
+ def self.box_usage
29
+ sprintf("%0.10f", rand / 100).to_f
30
+ end
31
+
28
32
  def self.etag
29
33
  hex(32)
30
34
  end
@@ -4,24 +4,18 @@ module Fog
4
4
 
5
5
  class Address < Fog::Model
6
6
 
7
- attr_accessor :instance_id,
8
- :public_ip
9
-
10
- def initialize(attributes = {})
11
- remap_attributes(attributes, {
12
- 'instanceId' => :instance_id,
13
- 'publicIp' => :public_ip
14
- })
15
- super
16
- end
7
+ attribute :instance_id, 'instanceId'
8
+ attribute :public_ip, 'publicIp'
17
9
 
18
10
  def delete
19
11
  connection.release_address(@public_ip)
12
+ true
20
13
  end
21
14
 
22
15
  def save
23
16
  data = connection.allocate_address
24
17
  @public_ip = data.body['publicIp']
18
+ true
25
19
  end
26
20
 
27
21
  end
@@ -10,7 +10,7 @@ module Fog
10
10
 
11
11
  def all(public_ip = [])
12
12
  data = connection.describe_addresses(public_ip).body
13
- addresses = []
13
+ addresses = Fog::AWS::EC2::Addresses.new(:connection => connection)
14
14
  data['addressesSet'].each do |address|
15
15
  addresses << Fog::AWS::EC2::Address.new({
16
16
  :connection => connection
@@ -4,28 +4,20 @@ module Fog
4
4
 
5
5
  class KeyPair < Fog::Model
6
6
 
7
- attr_accessor :fingerprint,
8
- :material,
9
- :name
10
-
11
- def initialize(attributes = {})
12
- remap_attributes(attributes, {
13
- 'keyFingerprint' => :fingerprint,
14
- 'keyMaterial' => :material,
15
- 'keyName' => :name
16
- })
17
- super
18
- end
7
+ attribute :fingerprint, 'keyFingerprint'
8
+ attribute :material, 'keyMaterial'
9
+ attribute :name, 'keyName'
19
10
 
20
11
  def delete
21
12
  connection.delete_key_pair(@name)
13
+ true
22
14
  end
23
15
 
24
16
  def save
25
17
  data = connection.create_key_pair(@name).body
26
18
  new_attributes = data.reject {|key,value| !['keyFingerprint', 'keyMaterial', 'keyName'].include?(key)}
27
19
  update_attributes(new_attributes)
28
- data
20
+ true
29
21
  end
30
22
 
31
23
  end
@@ -10,7 +10,7 @@ module Fog
10
10
 
11
11
  def all(key_name = [])
12
12
  data = connection.describe_key_pairs(key_name).body
13
- key_pairs = []
13
+ key_pairs = Fog::AWS::EC2::KeyPairs.new(:connection => connection)
14
14
  data['keySet'].each do |key|
15
15
  key_pairs << Fog::AWS::EC2::KeyPair.new({
16
16
  :connection => connection
@@ -0,0 +1,52 @@
1
+ module Fog
2
+ module AWS
3
+ class EC2
4
+
5
+ class Snapshot < Fog::Model
6
+
7
+ attribute :progress
8
+ attribute :snapshot_id, 'snapshotId'
9
+ attribute :start_time, 'startTime'
10
+ attribute :status
11
+ attribute :volumeId, 'volumeId'
12
+
13
+ def delete
14
+ connection.delete_snapshot(@snapshot_id)
15
+ true
16
+ end
17
+
18
+ def save
19
+ data = connection.create_snapshot(@volume.volume_id).body
20
+ new_attributes = data.reject {|key,value| key == 'requestId'}
21
+ update_attributes(new_attributes)
22
+ true
23
+ end
24
+
25
+ def snapshots
26
+ @snapshots ||= begin
27
+ Fog::AWS::S3::Snapshots.new(
28
+ :connection => connection,
29
+ :volume => self
30
+ )
31
+ end
32
+ end
33
+
34
+ def volume
35
+ @volume
36
+ end
37
+
38
+ private
39
+
40
+ def snapshots=(new_snapshots)
41
+ @snapshots = new_snapshots
42
+ end
43
+
44
+ def volume=(new_volume)
45
+ @volume = new_volume
46
+ end
47
+
48
+ end
49
+
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,50 @@
1
+ module Fog
2
+ module AWS
3
+ class EC2
4
+
5
+ def snapshots
6
+ Fog::AWS::EC2::Snapshots.new(:connection => self)
7
+ end
8
+
9
+ class Snapshots < Fog::Collection
10
+
11
+ def all(snapshot_id = [])
12
+ data = connection.describe_snapshots(snapshot_id)
13
+ snapshots = Fog::AWS::EC2::Snapshots.new(:connection => connection)
14
+ data['snapshotSet'].each do |volume|
15
+ snapshots << Fog::AWS::EC2::Snapshot.new({
16
+ :connection => connection
17
+ }.merge!(snapshot))
18
+ end
19
+ snapshots
20
+ end
21
+
22
+ def create(attributes = {})
23
+ volume = new(attributes)
24
+ volume.save
25
+ volume
26
+ end
27
+
28
+ def new(attributes = {})
29
+ Fog::AWS::S3::Snapshot.new({
30
+ :connection => connection,
31
+ :volume => @volume,
32
+ :snapshots => self
33
+ }.merge!(attributes))
34
+ end
35
+
36
+ def volume
37
+ @volume
38
+ end
39
+
40
+ private
41
+
42
+ def volume=(new_volume)
43
+ @volume = new_volume
44
+ end
45
+
46
+ end
47
+
48
+ end
49
+ end
50
+ end
@@ -4,40 +4,41 @@ module Fog
4
4
 
5
5
  class Volume < Fog::Model
6
6
 
7
- attr_accessor :attachment_time,
8
- :availability_zone,
9
- :device,
10
- :instance_id
11
- :size,
12
- :snapshot_id,
13
- :status,
14
- :volume_id
7
+ attribute :attachment_time, 'attachmentTime'
8
+ attribute :availability_zone, 'availabilityZone'
9
+ attribute :device, 'createTime'
10
+ attribute :instance_id, 'instanceId'
11
+ attribute :size
12
+ attribute :snapshot_id, 'snapshotId'
13
+ attribute :status, 'status'
14
+ attribute :volume_id, 'volumeId'
15
15
 
16
16
  def initialize(attributes = {})
17
17
  if attributes['attachmentSet']
18
18
  attributes.merge!(attributes.delete('attachmentSet'))
19
19
  end
20
- remap_attributes(attributes, {
21
- 'attachmentTime' => :attachment_time,
22
- 'availabilityZone' => :availability_zone,
23
- 'createTime' => :create_time,
24
- 'instanceId' => :instance_id,
25
- 'snapshotId' => :snapshot_id,
26
- 'status' => :status
27
- 'volumeId' => :volume_id
28
- })
29
20
  super
30
21
  end
31
22
 
32
23
  def delete
33
24
  connection.delete_volume(@volume_id)
25
+ true
34
26
  end
35
27
 
36
28
  def save
37
29
  data = connection.create_volume(@availability_zone, @size, @snapshot_id).body
38
30
  new_attributes = data.reject {|key,value| key == 'requestId'}
39
31
  update_attributes(new_attributes)
40
- data
32
+ true
33
+ end
34
+
35
+ def snapshots
36
+ @snapshots ||= begin
37
+ Fog::AWS::S3::Snapshots.new(
38
+ :connection => connection,
39
+ :volume => self
40
+ )
41
+ end
41
42
  end
42
43
 
43
44
  end
@@ -10,7 +10,7 @@ module Fog
10
10
 
11
11
  def all(volume_id = [])
12
12
  data = connection.describe_volumes(volume_id)
13
- volumes = []
13
+ volumes = Fog::AWS::EC2::Volumes.new(:connection => connection)
14
14
  data['volumeSet'].each do |volume|
15
15
  volumes << Fog::AWS::EC2::Volume.new({
16
16
  :connection => connection
@@ -9,10 +9,6 @@ module Fog
9
9
  attribute :name, 'Name'
10
10
  attribute :owner
11
11
 
12
- def initialize(attributes = {})
13
- super
14
- end
15
-
16
12
  def buckets
17
13
  @buckets
18
14
  end
@@ -14,10 +14,6 @@ module Fog
14
14
  attribute :size, 'Size'
15
15
  attribute :storage_class, 'StorageClass'
16
16
 
17
- def initialize(attributes = {})
18
- super
19
- end
20
-
21
17
  def bucket
22
18
  @bucket
23
19
  end
@@ -9,10 +9,6 @@ module Fog
9
9
  attribute :max_keys, 'MaxKeys'
10
10
  attribute :prefix, 'Prefix'
11
11
 
12
- def initialize(attributes = {})
13
- super
14
- end
15
-
16
12
  def all(options = {})
17
13
  merge_attributes(options)
18
14
  bucket.buckets.get(bucket.name, attributes).objects
@@ -58,7 +58,9 @@ else
58
58
  else
59
59
  bucket['LocationConstraint'] = ''
60
60
  end
61
- Fog::AWS::S3.data[:buckets][bucket_name] = bucket
61
+ unless Fog::AWS::S3.data[:buckets][bucket_name]
62
+ Fog::AWS::S3.data[:buckets][bucket_name] = bucket
63
+ end
62
64
  response
63
65
  end
64
66
 
@@ -1,31 +1,70 @@
1
- module Fog
2
- module AWS
3
- class SimpleDB
4
-
5
- # Put items attributes into a SimpleDB domain
6
- #
7
- # ==== Parameters
8
- # * domain_name<~String> - Name of domain. Must be between 3 and 255 of the
9
- # following characters: a-z, A-Z, 0-9, '_', '-' and '.'.
10
- # * items<~Hash> - Keys are the items names and may use any UTF-8
11
- # characters valid in xml. Control characters and sequences not allowed
12
- # in xml are not valid. Can be up to 1024 bytes long. Values are the
13
- # attributes to add to the given item and may use any UTF-8 characters
14
- # valid in xml. Control characters and sequences not allowed in xml are
15
- # not valid. Each name and value can be up to 1024 bytes long.
16
- #
17
- # ==== Returns
18
- # * response<~Fog::AWS::Response>:
19
- # * body<~Hash>:
20
- # * 'BoxUsage'
21
- # * 'RequestId'
22
- def batch_put_attributes(domain_name, items, replace_attributes = Hash.new([]))
23
- request({
24
- 'Action' => 'BatchPutAttributes',
25
- 'DomainName' => domain_name
26
- }.merge!(encode_batch_attributes(items, replace_attributes)), Fog::Parsers::AWS::SimpleDB::Basic.new(@nil_string))
1
+ unless Fog.mocking?
2
+
3
+ module Fog
4
+ module AWS
5
+ class SimpleDB
6
+
7
+ # Put items attributes into a SimpleDB domain
8
+ #
9
+ # ==== Parameters
10
+ # * domain_name<~String> - Name of domain. Must be between 3 and 255 of the
11
+ # following characters: a-z, A-Z, 0-9, '_', '-' and '.'.
12
+ # * items<~Hash> - Keys are the items names and may use any UTF-8
13
+ # characters valid in xml. Control characters and sequences not allowed
14
+ # in xml are not valid. Can be up to 1024 bytes long. Values are the
15
+ # attributes to add to the given item and may use any UTF-8 characters
16
+ # valid in xml. Control characters and sequences not allowed in xml are
17
+ # not valid. Each name and value can be up to 1024 bytes long.
18
+ #
19
+ # ==== Returns
20
+ # * response<~Fog::AWS::Response>:
21
+ # * body<~Hash>:
22
+ # * 'BoxUsage'
23
+ # * 'RequestId'
24
+ def batch_put_attributes(domain_name, items, replace_attributes = Hash.new([]))
25
+ request({
26
+ 'Action' => 'BatchPutAttributes',
27
+ 'DomainName' => domain_name
28
+ }.merge!(encode_batch_attributes(items, replace_attributes)), Fog::Parsers::AWS::SimpleDB::Basic.new(@nil_string))
29
+ end
30
+
27
31
  end
32
+ end
33
+ end
28
34
 
35
+ else
36
+
37
+ module Fog
38
+ module AWS
39
+ class SimpleDB
40
+
41
+ def batch_put_attributes(domain_name, items, replace_attributes = Hash.new([]))
42
+ response = Fog::Response.new
43
+ if Fog::AWS::SimpleDB.data[:domains][domain_name]
44
+ for key, value in items do
45
+ for item in value do
46
+ if replace_attributes[key] && replace_attributes[key].include?(value)
47
+ Fog::AWS::SimpleDB.data[:domains][domain_name][key] = []
48
+ else
49
+ Fog::AWS::SimpleDB.data[:domains][domain_name][key] ||= []
50
+ end
51
+ Fog::AWS::SimpleDB.data[:domains][domain_name][key] << value.to_s
52
+ end
53
+ end
54
+ response.status = 200
55
+ response.body = {
56
+ 'BoxUsage' => Fog::AWS::Mock.box_usage,
57
+ 'RequestId' => Fog::AWS::Mock.request_id
58
+ }
59
+ else
60
+ response.status = 400
61
+ raise(Fog::Errors.status_error(200, 400, response))
62
+ end
63
+ response
64
+ end
65
+
66
+ end
29
67
  end
30
68
  end
69
+
31
70
  end
@@ -1,25 +1,50 @@
1
- module Fog
2
- module AWS
3
- class SimpleDB
4
-
5
- # Create a SimpleDB domain
6
- #
7
- # ==== Parameters
8
- # * domain_name<~String>:: Name of domain. Must be between 3 and 255 of the
9
- # following characters: a-z, A-Z, 0-9, '_', '-' and '.'.
10
- #
11
- # ==== Returns
12
- # * response<~Fog::AWS::Response>:
13
- # * body<~Hash>:
14
- # * 'BoxUsage'
15
- # * 'RequestId'
16
- def create_domain(domain_name)
17
- request({
18
- 'Action' => 'CreateDomain',
19
- 'DomainName' => domain_name
20
- }, Fog::Parsers::AWS::SimpleDB::Basic.new(@nil_string))
1
+ unless Fog.mocking?
2
+
3
+ module Fog
4
+ module AWS
5
+ class SimpleDB
6
+
7
+ # Create a SimpleDB domain
8
+ #
9
+ # ==== Parameters
10
+ # * domain_name<~String>:: Name of domain. Must be between 3 and 255 of the
11
+ # following characters: a-z, A-Z, 0-9, '_', '-' and '.'.
12
+ #
13
+ # ==== Returns
14
+ # * response<~Fog::AWS::Response>:
15
+ # * body<~Hash>:
16
+ # * 'BoxUsage'
17
+ # * 'RequestId'
18
+ def create_domain(domain_name)
19
+ request({
20
+ 'Action' => 'CreateDomain',
21
+ 'DomainName' => domain_name
22
+ }, Fog::Parsers::AWS::SimpleDB::Basic.new(@nil_string))
23
+ end
24
+
21
25
  end
26
+ end
27
+ end
22
28
 
29
+ else
30
+
31
+ module Fog
32
+ module AWS
33
+ class SimpleDB
34
+
35
+ def create_domain(domain_name)
36
+ response = Fog::Response.new
37
+ Fog::AWS::SimpleDB.data[:domains][domain_name] = { :attributes => {} }
38
+ response.status = 200
39
+ response.body = {
40
+ 'BoxUsage' => Fog::AWS::Mock.box_usage,
41
+ 'RequestId' => Fog::AWS::Mock.request_id
42
+ }
43
+ response
44
+ end
45
+
46
+ end
23
47
  end
24
48
  end
49
+
25
50
  end
@@ -1,25 +1,51 @@
1
- module Fog
2
- module AWS
3
- class SimpleDB
4
-
5
- # Delete a SimpleDB domain
6
- #
7
- # ==== Parameters
8
- # * domain_name<~String>:: Name of domain. Must be between 3 and 255 of the
9
- # following characters: a-z, A-Z, 0-9, '_', '-' and '.'.
10
- #
11
- # ==== Returns
12
- # * response<~Fog::AWS::Response>:
13
- # * body<~Hash>:
14
- # * 'BoxUsage'
15
- # * 'RequestId'
16
- def delete_domain(domain_name)
17
- request({
18
- 'Action' => 'DeleteDomain',
19
- 'DomainName' => domain_name
20
- }, Fog::Parsers::AWS::SimpleDB::Basic.new(@nil_string))
1
+ unless Fog.mocking?
2
+
3
+ module Fog
4
+ module AWS
5
+ class SimpleDB
6
+
7
+ # Delete a SimpleDB domain
8
+ #
9
+ # ==== Parameters
10
+ # * domain_name<~String>:: Name of domain. Must be between 3 and 255 of the
11
+ # following characters: a-z, A-Z, 0-9, '_', '-' and '.'.
12
+ #
13
+ # ==== Returns
14
+ # * response<~Fog::AWS::Response>:
15
+ # * body<~Hash>:
16
+ # * 'BoxUsage'
17
+ # * 'RequestId'
18
+ def delete_domain(domain_name)
19
+ request({
20
+ 'Action' => 'DeleteDomain',
21
+ 'DomainName' => domain_name
22
+ }, Fog::Parsers::AWS::SimpleDB::Basic.new(@nil_string))
23
+ end
24
+
21
25
  end
26
+ end
27
+ end
22
28
 
29
+ else
30
+
31
+ module Fog
32
+ module AWS
33
+ class SimpleDB
34
+
35
+ def delete_domain(domain_name)
36
+ response = Fog::Response.new
37
+ if Fog::AWS::SimpleDB.data[:domains].delete(domain_name)
38
+ response.status = 200
39
+ response.body = {
40
+ 'BoxUsage' => Fog::AWS::Mock.box_usage,
41
+ 'RequestId' => Fog::AWS::Mock.request_id
42
+ }
43
+ end
44
+ response
45
+ end
46
+
47
+ end
23
48
  end
24
49
  end
50
+
25
51
  end
@@ -1,30 +1,63 @@
1
- module Fog
2
- module AWS
3
- class SimpleDB
4
-
5
- # List SimpleDB domains
6
- #
7
- # ==== Parameters
8
- # * options<~Hash> - options, defaults to {}
9
- # * 'MaxNumberOfDomains'<~Integer> - number of domains to return
10
- # between 1 and 100, defaults to 100
11
- # * 'NextToken'<~String> - Offset token to start listing, defaults to nil
12
- #
13
- # ==== Returns
14
- # * response<~Fog::AWS::Response>:
15
- # * body<~Hash>:
16
- # * 'BoxUsage'
17
- # * 'Domains' - array of domain names.
18
- # * 'NextToken' - offset to start with if there are are more domains to list
19
- # * 'RequestId'
20
- def list_domains(options = {})
21
- request({
22
- 'Action' => 'ListDomains',
23
- 'MaxNumberOfDomains' => options['MaxNumberOfDomains'],
24
- 'NextToken' => options['NextToken']
25
- }, Fog::Parsers::AWS::SimpleDB::ListDomains.new(@nil_string))
1
+ unless Fog.mocking?
2
+
3
+ module Fog
4
+ module AWS
5
+ class SimpleDB
6
+
7
+ # List SimpleDB domains
8
+ #
9
+ # ==== Parameters
10
+ # * options<~Hash> - options, defaults to {}
11
+ # * 'MaxNumberOfDomains'<~Integer> - number of domains to return
12
+ # between 1 and 100, defaults to 100
13
+ # * 'NextToken'<~String> - Offset token to start listing, defaults to nil
14
+ #
15
+ # ==== Returns
16
+ # * response<~Fog::AWS::Response>:
17
+ # * body<~Hash>:
18
+ # * 'BoxUsage'
19
+ # * 'Domains' - array of domain names.
20
+ # * 'NextToken' - offset to start with if there are are more domains to list
21
+ # * 'RequestId'
22
+ def list_domains(options = {})
23
+ request({
24
+ 'Action' => 'ListDomains'
25
+ }.merge!(options), Fog::Parsers::AWS::SimpleDB::ListDomains.new(@nil_string))
26
+ end
27
+
26
28
  end
29
+ end
30
+ end
27
31
 
32
+ else
33
+
34
+ module Fog
35
+ module AWS
36
+ class SimpleDB
37
+
38
+ def list_domains(options = {})
39
+ response = Fog::Response.new
40
+ keys = Fog::AWS::SimpleDB.data[:domains].keys
41
+ max = options['MaxNumberOfDomains'] || keys.size
42
+ offset = options['NextToken'] || 0
43
+ domains = []
44
+ for key, value in Fog::AWS::SimpleDB.data[:domains].keys[offset...max]
45
+ domains << key
46
+ end
47
+ response.status = 200
48
+ response.body = {
49
+ 'BoxUsage' => Fog::AWS::Mock.box_usage,
50
+ 'Domains' => domains,
51
+ 'RequestId' => Fog::AWS::Mock.request_id
52
+ }
53
+ if max < keys.size
54
+ response.body['NextToken'] = max + 1
55
+ end
56
+ response
57
+ end
58
+
59
+ end
28
60
  end
29
61
  end
62
+
30
63
  end
@@ -2,6 +2,15 @@ module Fog
2
2
  module AWS
3
3
  class SimpleDB
4
4
 
5
+ if Fog.mocking?
6
+ def self.reset_data
7
+ @data = { :domains => {} }
8
+ end
9
+ def self.data
10
+ @data
11
+ end
12
+ end
13
+
5
14
  def self.reload
6
15
  current_directory = File.dirname(__FILE__)
7
16
  load "#{current_directory}/../connection.rb"
@@ -25,6 +34,10 @@ module Fog
25
34
  load "#{requests_directory}/list_domains.rb"
26
35
  load "#{requests_directory}/put_attributes.rb"
27
36
  load "#{requests_directory}/select.rb"
37
+
38
+ if Fog.mocking?
39
+ reset_data
40
+ end
28
41
  end
29
42
 
30
43
  # Initialize connection to SimpleDB
@@ -19,4 +19,13 @@ describe 'SimpleDB.batch_put_attributes' do
19
19
  end
20
20
 
21
21
  end
22
+ describe 'failure' do
23
+
24
+ it 'should raise a BadRequest error if the domain does not exist' do
25
+ lambda {
26
+ sdb.batch_put_attributes('notadomain', { 'a' => { 'b' => 'c' }, 'x' => { 'y' => 'z' } })
27
+ }.should raise_error(Fog::Errors::BadRequest)
28
+ end
29
+
30
+ end
22
31
  end
@@ -1,15 +1,15 @@
1
1
  require File.dirname(__FILE__) + '/../../../spec_helper'
2
2
 
3
3
  describe 'SimpleDB.create_domain' do
4
- describe 'success' do
4
+ before(:each) do
5
+ @domain_name = "fog_domain_#{Time.now.to_i}"
6
+ end
5
7
 
6
- before(:each) do
7
- @domain_name = "fog_domain_#{Time.now.to_i}"
8
- end
8
+ after(:each) do
9
+ sdb.delete_domain(@domain_name)
10
+ end
9
11
 
10
- after(:each) do
11
- sdb.delete_domain(@domain_name)
12
- end
12
+ describe 'success' do
13
13
 
14
14
  it 'should return proper attributes' do
15
15
  actual = sdb.create_domain(@domain_name)
@@ -18,4 +18,12 @@ describe 'SimpleDB.create_domain' do
18
18
  end
19
19
 
20
20
  end
21
+ describe 'failure' do
22
+
23
+ it 'should not raise an error if the domain already exists' do
24
+ sdb.create_domain(@domain_name)
25
+ sdb.create_domain(@domain_name)
26
+ end
27
+
28
+ end
21
29
  end
@@ -4,19 +4,36 @@ describe 'SimpleDB.delete_attributes' do
4
4
  describe 'success' do
5
5
 
6
6
  before(:each) do
7
- sdb.create_domain('delete_attributes')
8
- sdb.put_attributes('delete_attributes', 'foo', { :bar => :baz })
7
+ @domain_name = "fog_domain_#{Time.now.to_i}"
8
+ sdb.create_domain(@domain_name)
9
+ sdb.put_attributes(@domain_name, 'foo', { :bar => :baz })
9
10
  end
10
11
 
11
12
  after(:each) do
12
- sdb.delete_domain('delete_attributes')
13
+ sdb.delete_domain(@domain_name)
13
14
  end
14
15
 
15
16
  it 'should return proper attributes from delete_attributes' do
16
- actual = sdb.delete_attributes('delete_attributes', 'foo')
17
+ actual = sdb.delete_attributes(@domain_name, 'foo')
17
18
  actual.body['RequestId'].should be_a(String)
18
19
  actual.body['BoxUsage'].should be_a(Float)
19
20
  end
20
21
 
21
22
  end
23
+ describe 'failure' do
24
+
25
+ it 'shouild raise a BadRequest error if the domain does not exist' do
26
+ lambda {
27
+ sdb.delete_attributes('notadomain', 'notanattribute')
28
+ }.should raise_error(Fog::Errors::BadRequest)
29
+ end
30
+
31
+ it 'should not raise an error if the attribute does not exist' do
32
+ @domain_name = "fog_domain_#{Time.now.to_i}"
33
+ sdb.create_domain(@domain_name)
34
+ sdb.delete_attributes(@domain_name, 'notanattribute')
35
+ sdb.delete_domain(@domain_name)
36
+ end
37
+
38
+ end
22
39
  end
@@ -18,4 +18,11 @@ describe 'SimpleDB.delete_domain' do
18
18
  end
19
19
 
20
20
  end
21
+ describe 'failure' do
22
+
23
+ it 'should not raise an error if the domain does not exist' do
24
+ sdb.delete_domain('notadomain')
25
+ end
26
+
27
+ end
21
28
  end
@@ -40,4 +40,13 @@ describe 'SimpleDB.domain_metadata' do
40
40
  end
41
41
 
42
42
  end
43
+ describe 'failure' do
44
+
45
+ it 'should raise a BadRequest error if the domain does not exist' do
46
+ lambda {
47
+ sdb.domain_metadata('notadomain')
48
+ }.should raise_error(Fog::Errors::BadRequest)
49
+ end
50
+
51
+ end
43
52
  end
@@ -28,4 +28,20 @@ describe 'SimpleDB.get_attributes' do
28
28
  end
29
29
 
30
30
  end
31
+ describe 'failure' do
32
+
33
+ it 'should raise a BadRequest error if the domain does not exist' do
34
+ lambda {
35
+ sdb.get_attributes('notadomain', 'notanattribute')
36
+ }.should raise_error(Fog::Errors::BadRequest)
37
+ end
38
+
39
+ it 'should not raise an error if the attribute does not exist' do
40
+ @domain_name = "fog_domain_#{Time.now.to_i}"
41
+ sdb.create_domain(@domain_name)
42
+ sdb.get_attributes(@domain_name, 'notanattribute')
43
+ sdb.delete_domain(@domain_name)
44
+ end
45
+
46
+ end
31
47
  end
@@ -19,4 +19,13 @@ describe 'SimpleDB.put_attributes' do
19
19
  end
20
20
 
21
21
  end
22
+ describe 'failure' do
23
+
24
+ it 'should raise a BadRequest error if the domain does not exist' do
25
+ lambda {
26
+ sdb.put_attributes(@domain_name, 'notadomain', { 'notanattribute' => 'value' })
27
+ }.should raise_error(Fog::Errors::BadRequest)
28
+ end
29
+
30
+ end
22
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wesley Beary
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-04 00:00:00 -07:00
12
+ date: 2009-09-08 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -71,6 +71,8 @@ files:
71
71
  - lib/fog/aws/models/ec2/addresses.rb
72
72
  - lib/fog/aws/models/ec2/key_pair.rb
73
73
  - lib/fog/aws/models/ec2/key_pairs.rb
74
+ - lib/fog/aws/models/ec2/snapshot.rb
75
+ - lib/fog/aws/models/ec2/snapshots.rb
74
76
  - lib/fog/aws/models/ec2/volume.rb
75
77
  - lib/fog/aws/models/ec2/volumes.rb
76
78
  - lib/fog/aws/models/s3/bucket.rb