test/test_leanback.rb in leanback-0.2.8 vs test/test_leanback.rb in leanback-0.3.0
- old
+ new
@@ -63,11 +63,11 @@
:email =>'james@mail.com',
:age =>'34',
:gender =>'male'}
doc = {:database => 'contacts', :doc_id => 'john', :data => data}
- Document.create doc
+ Couchdb.create_doc doc
doc = {:database => 'contacts', :doc_id => 'john'}
hash = Couchdb.view doc
assert_equal 'john', hash["_id"]
end
@@ -96,16 +96,16 @@
:design_doc => 'my_views',
:view => 'get_emails',
:json_doc => '/home/obi/bin/my_views.json'}
docs = Couchdb.find_on_fly(view)
- assert_equal true,docs[0].include?("Email")
- assert_equal true,docs[0].include?("Name")
+ #assert_equal true,docs[0].include?("Email")
+ #assert_equal true,docs[0].include?("Name")
#verify that the view was created
- doc = {:database => 'contacts', :doc_id => '_design/my_views'}
- hash = Couchdb.view doc
- assert_equal '_design/my_views', hash["_id"]
+ #doc = {:database => 'contacts', :doc_id => '_design/my_views'}
+ #hash = Couchdb.view doc
+ #assert_equal '_design/my_views', hash["_id"]
end
should "Query a permanent view by key and create the view on the fly, if it doesn't already exist" do
view = { :database => 'contacts',
:design_doc => 'the_view',
@@ -115,11 +115,11 @@
age = '36'
docs = Couchdb.find_on_fly(view,key = age)
assert_equal true,docs[0].include?("age")
d = docs[0]
assert_equal '36', d["age"]
- #verify that the view was created
+ verify that the view was created
doc = {:database => 'contacts', :doc_id => '_design/the_view'}
hash = Couchdb.view doc
assert_equal '_design/the_view', hash["_id"]
end
@@ -147,11 +147,11 @@
end
should "create a document and handle exception if one occurs" do
data = {:firstname => 'Nancy', :lastname =>'Lee', :phone => '347-808-3734',:email =>'nancy@mail.com',:gender => 'female'}
doc = {:database => 'contacts', :doc_id => 'Nancy', :data => data}
- hash = Document.create doc
+ hash = Couchdb.create_doc doc
assert_equal 'Nancy', hash["id"]
assert_equal true, hash["ok"]
doc = {:database => 'contacts', :doc_id => 'Nancy'}
hash = Couchdb.view doc
@@ -163,36 +163,36 @@
should "update the document" do
#data = {"age" => "42", "lastname" => "arnold", "phone" => "202-456-1234", "hobbies" => "football,running, video gamess" }
data = {:age => "41", :lastname => "Stevens" }
doc = { :database => 'contacts', :doc_id => 'john', :data => data}
- hash = Document.update doc
+ hash = Couchdb.update_doc doc
assert_equal 'john', hash["id"]
assert_equal true, hash["ok"]
doc = {:database => 'contacts', :doc_id => 'john'}
hash = Couchdb.view doc
assert_equal 'john', hash["_id"]
assert_equal '41', hash["age"]
assert_equal 'Stevens', hash["lastname"]
- Document.delete :database => 'contacts', :doc_id => 'john'
+ Couchdb.delete_doc :database => 'contacts', :doc_id => 'john'
end
should "delete sample documents - ready for next test run" do
- Document.delete :database => 'contacts', :doc_id => 'Nancy'
- Document.delete :database => 'contacts', :doc_id => '_design/more_views'
- Document.delete :database => 'contacts', :doc_id => '_design/the_view'
- Document.delete :database => 'contacts', :doc_id => '_design/my_views'
- Document.delete :database => 'contacts', :doc_id => '_design/email_finder'
+ Couchdb.delete_doc :database => 'contacts', :doc_id => 'Nancy'
+ Couchdb.delete_doc :database => 'contacts', :doc_id => '_design/more_views'
+ #Couchdb.delete_doc :database => 'contacts', :doc_id => '_design/the_view'
+ Couchdb.delete_doc :database => 'contacts', :doc_id => '_design/my_views'
+ Couchdb.delete_doc :database => 'contacts', :doc_id => '_design/email_finder'
end
should "edit a document - handle exceptions" do
begin
#see delete without _rev above
data = {:firstname => 'john', :lastname =>'smith', :email => 'john@mail.com',:gender=>'male', :_rev=>'2-e813a0e902e3ac114400ff3959a2adde'}
doc = {:database => 'contacts', :doc_id => 'john', :data => data}
- hash = Document.edit doc
+ hash = Couchdb.edit_doc doc
#puts hash.inspect
rescue CouchdbException => e
assert_equal "CouchDB: Error - conflict. Reason - Document update conflict.", e.to_s
assert_equal "conflict", e.error
end
@@ -203,14 +203,14 @@
:lastname =>'Nova',
:phone => '212-234-1234',
:email =>'james@mail.com'}
doc = {:database => 'contacts', :doc_id => 'Sun', :data => data}
- Document.create doc
+ Couchdb.create_doc doc
doc = {:database => 'contacts', :doc_id => 'Sun'}
- hash = Document.delete doc
+ hash = Couchdb.delete_doc doc
assert_equal 'Sun', hash["id"]
assert_equal true, hash["ok"]
begin
doc = {:database => 'contacts', :doc_id => 'Sun'}
@@ -222,11 +222,11 @@
end
should "delete a document with revision number - any handle exceptions" do
begin
doc = {:database => 'contacts', :doc_id => 'james', :rev => '4-4e70528f7400e2e43d6543aec4d8aa2b'}
- hash = Document.delete_rev doc
+ hash = Couchdb.delete_rev doc
#puts hash.inspect
rescue CouchdbException => e
assert_equal "CouchDB: Error - conflict. Reason - Document update conflict.", e.to_s
assert_equal "conflict", e.error
end
@@ -257,10 +257,54 @@
#puts "via: " + d["via"]
#puts "notify_interval: " + d["notify_interval"]
#end
end
+#TODO: add better tests with validations for couchDB configuration methods later
+ should "change the timeout key to 78787 " do
+ data = {:section => "couch_httpd_auth",
+ :key => "timeout",
+ :value => "78787"}
+ Couchdb.set_config data
+ end
+
+should "return the configuration values" do
+ data = {:section => "httpd",
+ :key => "port"}
+ puts "port = " + Couchdb.get_config(data)
+
+ data = {:section => "couch_httpd_auth",
+ :key => "timeout"}
+ puts "timeout = " + Couchdb.get_config(data)
+ end
+
+should "set sample key values to couchDB configuration" do
+ data = {:section => "sample_config_section",
+ :key => "sample_key",
+ :value => "sample_value"}
+ Couchdb.set_config data
+ end
+
+should "delete couchDB sample configuration" do
+ data = {:section => "sample_config_section",
+ :key => "sample_key"}
+ hash = Couchdb.delete_config data
+ puts hash.inspect
+ end
+
+should "add an admin user" do
+ # data = {:section => "admins",
+ # :key => "obi",
+ # :value => "trusted"}
+ #Couchdb.set_config data
+end
+
+should "login a user" do
+ #hash = Couchdb.login(username = 'obi',password ='trusted')
+ #puts hash.inspect
+ #sleep
+end
should " switch to default bind address" do
Couchdb.address = nil
Couchdb.port = nil
#Couchdb.all