[BioRuby-cvs] bioruby/test/unit/bio test_command.rb,1.3,1.4

Katayama Toshiaki k at dev.open-bio.org
Thu Mar 29 12:14:48 UTC 2007


Update of /home/repository/bioruby/bioruby/test/unit/bio
In directory dev.open-bio.org:/tmp/cvs-serv10963/test/unit/bio

Modified Files:
	test_command.rb 
Log Message:
* routine for generating CGI arguments is separated from post_form to make_cgi_params


Index: test_command.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/test/unit/bio/test_command.rb,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** test_command.rb	27 Jul 2006 03:50:36 -0000	1.3
--- test_command.rb	29 Mar 2007 12:14:46 -0000	1.4
***************
*** 131,134 ****
--- 131,288 ----
      end
  
+     def test_make_cgi_params_by_hash_in_symbol
+       ary = [
+              "type1=bp",
+              "type2=bp",
+              "downstream=",
+              "upstream=",
+              "format=fasta",
+              "options=similarity",
+              "options=gene",
+              "action=export",
+              "_format=Text",
+              "output=txt",
+              "submit=Continue%20%3E%3E",
+             ]
+       hash = {
+         :type1 => 'bp',
+         :type2 => 'bp',
+         :downstream => '',
+         :upstream => '',
+         :format => 'fasta',
+         :options => ['similarity', 'gene'],
+         :action => 'export',
+         :_format => 'Text',
+         :output => 'txt',
+         :submit => 'Continue >>',
+       }
+       result = Bio::Command.make_cgi_params(hash)
+       ary.each do |str|
+         assert_match(str, result)
+       end
+     end
+ 
+     def test_make_cgi_params_by_hash_in_string
+       ary = [
+              "type1=bp",
+              "type2=bp",
+              "downstream=",
+              "upstream=",
+              "format=fasta",
+              "options=similarity",
+              "options=gene",
+              "action=export",
+              "_format=Text",
+              "output=txt",
+              "submit=Continue%20%3E%3E",
+             ]
+       hash = {
+         "type1" => 'bp',
+         "type2" => 'bp',
+         "downstream" => '',
+         "upstream" => '',
+         "format" => 'fasta',
+         "options" => ['similarity', 'gene'],
+         "action" => 'export',
+         "_format" => 'Text',
+         "output" => 'txt',
+         "submit" => 'Continue >>',
+       }
+       result = Bio::Command.make_cgi_params(hash)
+       ary.each do |str|
+         assert_match(str, result)
+       end
+     end
+ 
+     def test_make_cgi_params_by_array_of_array
+       ary = [
+              "type1=bp",
+              "type2=bp",
+              "downstream=",
+              "upstream=",
+              "format=fasta",
+              "options=similarity",
+              "options=gene",
+              "action=export",
+              "_format=Text",
+              "output=txt",
+              "submit=Continue%20%3E%3E",
+             ]
+       array_of_array = [
+         ["type1", 'bp'],
+         ["type2", 'bp'], 
+         ["downstream", ''],
+         ["upstream", ''],
+         ["format", 'fasta'],
+         ["options", ['similarity', 'gene']],
+         ["action", 'export'],
+         ["_format", 'Text'],
+         ["output", 'txt'],
+         ["submit", 'Continue >>'],
+       ]
+       result = Bio::Command.make_cgi_params(array_of_array)
+       ary.each do |str|
+         assert_match(str, result)
+       end
+     end
+ 
+     def test_make_cgi_params_by_array_of_hash
+       ary = [
+              "type1=bp",
+              "type2=bp",
+              "downstream=",
+              "upstream=",
+              "format=fasta",
+              "options=similarity",
+              "options=gene",
+              "action=export",
+              "_format=Text",
+              "output=txt",
+              "submit=Continue%20%3E%3E",
+             ]
+       array_of_hash = [
+                        {"type1" => 'bp'},
+                        {"type2" => 'bp'},
+                        {"downstream" => ''},
+                        {"upstream" => ''},
+                        {"format" => 'fasta'},
+                        {"options" => ['similarity', 'gene']},
+                        {"action" => 'export'},
+                        {"_format" => 'Text'},
+                        {"output" => 'txt'},
+                        {"submit" => 'Continue >>'},
+                       ]
+       result = Bio::Command.make_cgi_params(array_of_hash)
+       ary.each do |str|
+         assert_match(str, result)
+       end
+     end
+ 
+     def test_make_cgi_params_by_array_of_string
+       str = "type1=bp&type2=bp&downstream=&upstream=&format=fasta&options=similarity&options=gene&action=export&_format=Text&output=txt&submit=Continue%20%3E%3E"
+       array_of_string = [
+                          "type1=bp",
+                          "type2=bp",
+                          "downstream=",
+                          "upstream=",
+                          "format=fasta",
+                          "options=similarity",
+                          "options=gene",
+                          "action=export",
+                          "_format=Text",
+                          "output=txt",
+                          "submit=Continue >>",
+                         ]
+       result = Bio::Command.make_cgi_params(array_of_string)
+       assert_equal(str, result)
+     end
+ 
+     def test_make_cgi_params_by_string
+       string = "type1=bp&type2=bp&downstream=&upstream=&format=fasta&options=similarity&options=gene&action=export&_format=Text&output=txt&submit=Continue%20%3E%3E"
+       query = " type1=bp&type2=bp&downstream=&upstream=&format=fasta&options=similarity&options=gene&action=export&_format=Text&output=txt&submit=Continue >> "
+       result = Bio::Command.make_cgi_params(query)
+       assert_equal(string, result)
+     end
+ 
    end
  end




More information about the bioruby-cvs mailing list