test/test_biomart.rb in dazoakley-biomart-0.0.1 vs test/test_biomart.rb in dazoakley-biomart-0.1

- old
+ new

@@ -91,6 +91,55 @@ assert( search2.is_a?( Array ), "Biomart::Dataset.search (filters and attributes defined with processing) is not returning an array." ) assert( search2.first.is_a?( Hash ), "Biomart::Dataset.search (filters and attributes defined with processing) is not returning an array of hashes." ) assert( search2.first["marker_symbol"] == "Cbx1", "Biomart::Dataset.search (filters and attributes defined with processing) is not returning the correct info." ) end end + + context "The Biomart module" do + setup do + @not_biomart = Biomart::Server.new('http://www.sanger.ac.uk') + @htgt_targ = @htgt.datasets["htgt_targ"] + @bad_dataset = Biomart::Dataset.new( "http://www.sanger.ac.uk/htgt/biomart", { :name => "wibble" } ) + end + + should "handle user/configuration errors (i.e. incorrect URLs etc)" do + begin + @not_biomart.list_databases + rescue Biomart::HTTPError => e + http_error = e + end + + assert( http_error.is_a?( Biomart::HTTPError ), "Biomart.request is not processing HTTP errors correctly." ) + end + + should "handle biomart server errors gracefully" do + begin + @htgt_targ.count( :filters => { "wibbleblibbleblip" => "1" } ) + rescue Biomart::FilterError => e + filter_error = e + end + + begin + @htgt_targ.search( :attributes => ["wibbleblibbleblip"] ) + rescue Biomart::AttributeError => e + attribute_error = e + end + + begin + @bad_dataset.count() + rescue Biomart::DatasetError => e + dataset_error = e + end + + begin + @bad_dataset.count() + rescue Biomart::BiomartError => e + general_error = e + end + + assert( filter_error.is_a?( Biomart::FilterError ), "Biomart.request is not handling Biomart filter errors correctly." ) + assert( attribute_error.is_a?( Biomart::AttributeError ), "Biomart.request is not handling Biomart attribute errors correctly." ) + assert( dataset_error.is_a?( Biomart::DatasetError ), "Biomart.request is not handling Biomart dataset errors correctly." ) + assert( general_error.is_a?( Biomart::BiomartError ), "Biomart.request is not handling general Biomart errors correctly." ) + end + end end