This repository has been archived by the owner on Jul 7, 2019. It is now read-only.
forked from edward/dm-adapter-simpledb
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
many improvements to right_aws SDB adapter... now uses the SDB.select…
… method opposed to depricated query and query with attrs
- Loading branch information
Dan Mayer
committed
Jun 15, 2009
1 parent
8f38022
commit d6f181b
Showing
11 changed files
with
438 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
1_YOUR_ACCESS_KEY_2 | ||
I_YOUR_SECRET_KEY_0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
require 'pathname' | ||
require Pathname(__FILE__).dirname.expand_path + 'spec_helper' | ||
require 'ruby-debug' | ||
|
||
describe 'associations' do | ||
it 'should work with belongs_to associations' | ||
it 'should work with has n associations' | ||
end | ||
|
||
describe 'STI' do | ||
it 'should override default type' | ||
it 'should load descendents on parent.all' | ||
it 'should raise an error if you have a column named couchdb_type' | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
require 'pathname' | ||
require Pathname(__FILE__).dirname.expand_path + 'spec_helper' | ||
|
||
class Professor | ||
include DataMapper::Resource | ||
|
||
property :id, String, :key => true | ||
property :name, String, :key => true | ||
property :age, Integer | ||
property :wealth, Float | ||
property :birthday, Date | ||
property :created_at, DateTime | ||
|
||
end | ||
|
||
describe 'with multiple records saved' do | ||
before(:each) do | ||
@person_attrs = { :id => "person-#{Time.now.to_f.to_s}", :name => 'Jeremy Boles', :age => 25, :wealth => 25.00, :birthday => Date.today } | ||
@jeremy = Professor.create(@person_attrs.merge(:id => Time.now.to_f.to_s, :name => "Jeremy Boles", :age => 25)) | ||
@danielle = Professor.create(@person_attrs.merge(:id => Time.now.to_f.to_s, :name => "Danille Boles", :age => 26)) | ||
@keegan = Professor.create(@person_attrs.merge(:id => Time.now.to_f.to_s, :name => "Keegan Jones", :age => 20)) | ||
sleep(0.4) #or the get calls might not have these created yet | ||
end | ||
|
||
after(:each) do | ||
@jeremy.destroy | ||
@danielle.destroy | ||
@keegan.destroy | ||
sleep(0.4) #or might not be destroyed by the next test | ||
end | ||
|
||
it 'should handle DateTime' do | ||
pending 'Need to figure out how to coerce DateTime' | ||
time = Time.now | ||
@jeremy.created_at = time | ||
@jeremy.save | ||
sleep(0.2) | ||
person = Professor.get!(@jeremy.id, @jeremy.name) | ||
person.created_at.should == time | ||
end | ||
|
||
it 'should handle Date' do | ||
person = Professor.get!(@jeremy.id, @jeremy.name) | ||
person.birthday.should == @jeremy.birthday | ||
end | ||
|
||
it 'should match with Data' do | ||
people = Professor.all(:birthday => Date.today) | ||
people.length.should == 3 | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
require 'pathname' | ||
require Pathname(__FILE__).dirname.expand_path + 'spec_helper' | ||
|
||
class Hero | ||
include DataMapper::Resource | ||
|
||
property :id, String, :key => true | ||
property :name, String, :key => true | ||
property :age, Integer | ||
property :wealth, Float | ||
property :birthday, Date | ||
property :created_at, DateTime | ||
|
||
belongs_to :company | ||
end | ||
|
||
describe 'with multiple records saved' do | ||
before(:each) do | ||
@person_attrs = { :id => "person-#{Time.now.to_f.to_s}", :name => 'Jeremy Boles', :age => 25, :wealth => 25.00, :birthday => Date.today } | ||
@jeremy = Hero.create(@person_attrs.merge(:id => Time.now.to_f.to_s, :name => "Jeremy Boles", :age => 25)) | ||
@danielle = Hero.create(@person_attrs.merge(:id => Time.now.to_f.to_s, :name => "Danille Boles", :age => 26)) | ||
@keegan = Hero.create(@person_attrs.merge(:id => Time.now.to_f.to_s, :name => "Keegan Jones", :age => 20, :wealth => 15.00)) | ||
sleep(0.4) #or the get calls might not have these created yet | ||
end | ||
|
||
after(:each) do | ||
@jeremy.destroy | ||
@danielle.destroy | ||
@keegan.destroy | ||
sleep(0.4) #or might not be destroyed by the next test | ||
end | ||
|
||
it 'should handle limit one case' do | ||
persons = Hero.all(:limit => 1) | ||
persons.length.should ==1 | ||
end | ||
|
||
it 'should handle max item limit case' do | ||
persons = Hero.all(:limit => 3) | ||
persons.length.should ==3 | ||
end | ||
|
||
it 'should handle max item if limit is large case' do | ||
persons = Hero.all(:limit => 150) | ||
persons.length.should ==3 | ||
end | ||
|
||
#it would be really slow to create over 100 entires to test this until we have batch creation | ||
it 'should handle limits over the default SDB 100 results limit' | ||
|
||
#it would be really slow to create over 100 entires to test this until we have batch creation | ||
it 'should get all results over the default SDB 100 results limit' | ||
|
||
it 'should handle ordering asc results with a limit' do | ||
persons = Hero.all(:order => [:age.asc], :limit => 2) | ||
persons.inspect #can't access via array until loaded? Weird | ||
persons.length.should ==2 | ||
persons[0].should == @keegan | ||
persons[1].should == @jeremy | ||
end | ||
|
||
it 'should handle ordering asc results' do | ||
persons = Hero.all(:order => [:age.asc]) | ||
persons.inspect #can't access via array until loaded? Weird | ||
persons[0].should == @keegan | ||
persons[1].should == @jeremy | ||
persons[2].should == @danielle | ||
end | ||
|
||
it 'should handle ordering desc results' do | ||
persons = Hero.all(:order => [:age.desc]) | ||
persons.inspect #can't access via array until loaded? Weird | ||
persons[0].should == @danielle | ||
persons[1].should == @jeremy | ||
persons[2].should == @keegan | ||
end | ||
|
||
it 'should handle ordering results with multiple conditionss' do | ||
persons = Hero.all(:age.gt => 20, :wealth.gt => 20, :order => [:age.desc]) | ||
persons.inspect #can't access via array until loaded? Weird | ||
persons.length.should ==2 | ||
persons[0].should == @danielle | ||
persons[1].should == @jeremy | ||
end | ||
|
||
it 'should handle ordering results with ordered by conditions' do | ||
persons = Hero.all(:age.gt => 20, :order => [:age.desc]) | ||
persons.inspect #can't access via array until loaded? Weird | ||
persons.length.should ==2 | ||
persons[0].should == @danielle | ||
persons[1].should == @jeremy | ||
end | ||
|
||
it 'should handle ordering results with unorder by conditions' do | ||
persons = Hero.all(:wealth.gt => 20.00, :order => [:age.desc]) | ||
persons.inspect #can't access via array until loaded? Weird | ||
persons.length.should ==2 | ||
persons[0].should == @danielle | ||
persons[1].should == @jeremy | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
require 'pathname' | ||
require Pathname(__FILE__).dirname.expand_path + 'spec_helper' | ||
require 'ruby-debug' | ||
|
||
describe 'support migrations' do | ||
|
||
#TODO do this on different storage | ||
class Person | ||
include DataMapper::Resource | ||
|
||
property :id, String, :key => true | ||
property :name, String, :key => true | ||
property :age, Integer | ||
property :wealth, Float | ||
property :birthday, Date | ||
property :created_at, DateTime | ||
|
||
belongs_to :company | ||
end | ||
|
||
before do | ||
@adapter = repository(:default).adapter | ||
end | ||
|
||
# test can't be run simultanious make it delete a throwawaable storage model | ||
# instead of the one used by all the tests | ||
# it "should destroy model storage" do | ||
# ENV['destroy']='true' | ||
# @adapter.destroy_model_storage(repository(:default), Person) | ||
# @adapter.storage_exists?("missionaries").should == false | ||
# ENV['destroy']='false' | ||
# @adapter.create_model_storage(repository(:default), Person) | ||
# @adapter.storage_exists?("missionaries").should == true | ||
# end | ||
|
||
it "should create model storage" do | ||
Person.auto_migrate! | ||
@adapter.storage_exists?("missionaries").should == true | ||
end | ||
|
||
end | ||
|
Oops, something went wrong.