Specs for post_visibilities and notifications imports

This commit is contained in:
Raphael 2011-01-10 15:55:59 -08:00
parent f4465c9d32
commit f277fb3bb8
2 changed files with 82 additions and 54 deletions

View file

@ -252,6 +252,12 @@ module DataConversion
FROM mongo_people LEFT JOIN users ON (users.mongo_id = mongo_people.owner_mongo_id) FROM mongo_people LEFT JOIN users ON (users.mongo_id = mongo_people.owner_mongo_id)
SQL SQL
log "Imported #{Person.count} people." log "Imported #{Person.count} people."
end
def process_raw_post_visibilities
end
def process_raw_notifications
end end
def import_raw_users def import_raw_users
log "Loading users file..." log "Loading users file..."

View file

@ -11,6 +11,12 @@ describe DataConversion::ImportToMysql do
"#{@migrator.full_path}/#{table_name}.csv") "#{@migrator.full_path}/#{table_name}.csv")
end end
def import_and_process(table_name)
copy_fixture_for(table_name)
@migrator.send("import_raw_#{table_name}".to_sym)
@migrator.send("process_raw_#{table_name}".to_sym)
end
before do before do
@migrator = DataConversion::ImportToMysql.new @migrator = DataConversion::ImportToMysql.new
@migrator.full_path = "/tmp/data_conversion" @migrator.full_path = "/tmp/data_conversion"
@ -53,11 +59,9 @@ describe DataConversion::ImportToMysql do
describe "aspects" do describe "aspects" do
before do before do
import_and_process("users")
copy_fixture_for("aspects") copy_fixture_for("aspects")
@migrator.import_raw_aspects @migrator.import_raw_aspects
copy_fixture_for("users")
@migrator.import_raw_users
@migrator.process_raw_users
end end
it "imports data into the aspects table" do it "imports data into the aspects table" do
Mongo::Aspect.count.should == 4 Mongo::Aspect.count.should == 4
@ -81,9 +85,7 @@ describe DataConversion::ImportToMysql do
describe "services" do describe "services" do
before do before do
copy_fixture_for("users") import_and_process("users")
@migrator.import_raw_users
@migrator.process_raw_users
copy_fixture_for("services") copy_fixture_for("services")
@migrator.import_raw_services @migrator.import_raw_services
end end
@ -116,12 +118,8 @@ describe DataConversion::ImportToMysql do
describe "invitations" do describe "invitations" do
before do before do
copy_fixture_for("users") import_and_process("users")
@migrator.import_raw_users import_and_process("aspects")
@migrator.process_raw_users
copy_fixture_for("aspects")
@migrator.import_raw_aspects
@migrator.process_raw_aspects
copy_fixture_for("invitations") copy_fixture_for("invitations")
@migrator.import_raw_invitations @migrator.import_raw_invitations
end end
@ -149,15 +147,9 @@ describe DataConversion::ImportToMysql do
end end
describe "requests" do describe "requests" do
before do before do
copy_fixture_for("people") import_and_process("users")
@migrator.import_raw_people import_and_process("people")
@migrator.process_raw_people import_and_process("aspects")
copy_fixture_for("users")
@migrator.import_raw_users
@migrator.process_raw_users
copy_fixture_for("aspects")
@migrator.import_raw_aspects
@migrator.process_raw_aspects
copy_fixture_for("requests") copy_fixture_for("requests")
@migrator.import_raw_requests @migrator.import_raw_requests
end end
@ -184,9 +176,7 @@ describe DataConversion::ImportToMysql do
end end
describe "people" do describe "people" do
before do before do
copy_fixture_for("users") import_and_process("users")
@migrator.import_raw_users
@migrator.process_raw_users
copy_fixture_for("people") copy_fixture_for("people")
@migrator.import_raw_people @migrator.import_raw_people
end end
@ -232,12 +222,8 @@ describe DataConversion::ImportToMysql do
describe "contacts" do describe "contacts" do
before do before do
copy_fixture_for("users") import_and_process("users")
@migrator.import_raw_users import_and_process("people")
@migrator.process_raw_users
copy_fixture_for("people")
@migrator.import_raw_people
@migrator.process_raw_people
copy_fixture_for("contacts") copy_fixture_for("contacts")
@migrator.import_raw_contacts @migrator.import_raw_contacts
end end
@ -263,18 +249,10 @@ describe DataConversion::ImportToMysql do
describe "aspect_memberships" do describe "aspect_memberships" do
before do before do
copy_fixture_for("users") import_and_process("users")
@migrator.import_raw_users import_and_process("people")
@migrator.process_raw_users import_and_process("contacts")
copy_fixture_for("people") import_and_process("aspects")
@migrator.import_raw_people
@migrator.process_raw_people
copy_fixture_for("contacts")
@migrator.import_raw_contacts
@migrator.process_raw_contacts
copy_fixture_for("aspects")
@migrator.import_raw_aspects
@migrator.process_raw_aspects
copy_fixture_for("aspect_memberships") copy_fixture_for("aspect_memberships")
@migrator.import_raw_aspect_memberships @migrator.import_raw_aspect_memberships
end end
@ -296,12 +274,8 @@ describe DataConversion::ImportToMysql do
end end
describe "profiles" do describe "profiles" do
before do before do
copy_fixture_for("users") import_and_process("users")
@migrator.import_raw_users import_and_process("people")
@migrator.process_raw_users
copy_fixture_for("people")
@migrator.import_raw_people
@migrator.process_raw_people
copy_fixture_for("profiles") copy_fixture_for("profiles")
@migrator.import_raw_profiles @migrator.import_raw_profiles
end end
@ -336,12 +310,8 @@ describe DataConversion::ImportToMysql do
end end
describe "posts" do describe "posts" do
before do before do
copy_fixture_for("users") import_and_process("users")
@migrator.import_raw_users import_and_process("people")
@migrator.process_raw_users
copy_fixture_for("people")
@migrator.import_raw_people
@migrator.process_raw_people
copy_fixture_for("posts") copy_fixture_for("posts")
@migrator.import_raw_posts @migrator.import_raw_posts
end end
@ -398,7 +368,57 @@ describe DataConversion::ImportToMysql do
post.updated_at.to_i.should == 1294692033 post.updated_at.to_i.should == 1294692033
end end
end end
describe "notifications" do
before do
import_and_process("users")
import_and_process("people")
import_and_process("posts")
copy_fixture_for("notifications")
@migrator.import_raw_notifications
end
it "imports data into the notifications table" do
Mongo::Notification.count.should == 2
Notification.count.should == 0
@migrator.process_raw_notifications
Notification.count.should == 2
end
it "processes all the columns" do
@migrator.process_raw_notifications
notification = Notification.first
mongo_notification = Mongo::Notification.first
notification.mongo_id.should == "4d2b6eb8cc8cb43cc200001f"
notification.target.mongo_id.should == mongo_notification.target_mongo_id
notification.target_type.should == "new_request"
notification.unread.should be_true
end
end
describe "post_visibilities" do
before do
import_and_process("users")
import_and_process("people")
import_and_process("aspects")
import_and_process("posts")
copy_fixture_for("post_visibilities")
@migrator.import_raw_post_visibilities
end
it "imports data into the post_visibilities table" do
Mongo::PostVisibility.count.should == 8
PostVisibility.count.should == 0
@migrator.process_raw_post_visibilities
PostVisibility.count.should == 8
end
it "processes all the columns" do
@migrator.process_raw_post_visibilities
pv = PostVisibility.first
mongo_pv = Mongo::PostVisibility.first
pv.aspect.mongo_id.should == mongo_pv.aspect_mongo_id
pv.post.mongo_id.should == mongo_pv.post_mongo_id
end
end
end end
describe "#import_raw" do describe "#import_raw" do
describe "aspects" do describe "aspects" do
@ -537,6 +557,8 @@ describe DataConversion::ImportToMysql do
post.created_at.utc.to_i.should == 1294692030 # got 1294663230- minus 8 hours post.created_at.utc.to_i.should == 1294692030 # got 1294663230- minus 8 hours
post.updated_at.to_i.should == 1294692030 post.updated_at.to_i.should == 1294692030
end end
end end
describe "notifications" do describe "notifications" do
before do before do