class TestActModulobe
Public Instance Methods
nu_test_metadata_model_xml()
click to toggle source
# File vendor/qwik/lib/qwik/act-mdlb.rb, line 563 def nu_test_metadata_model_xml setup_models res = session('/test/model.xml') ok_eq([[:'?xml', '1.0', 'utf-8'], [:rss, {:'xmlns:creativeCommons'=> 'http://backend.userland.com/creativeCommonsRssModule', :version=>'2.0'}, [:channel, [:title, 'Modulobe model gallery'], [:link, 'http://example.com/'], [:description, 'This is a model list of Modulobe Wiki.'], [:language, 'ja'], [:managingEditor, 'modulobe@qwik.jp'], [:webMaster, 'modulobe@qwik.jp'], [:lastBuildDate, 'Thu, 01 Jan 1970 09:00:02 GMT'], [:ttl, '60'], [:item, [:title, 't1 model'], [:link, 'http://example.com/test/a.files/test1.mdlb'], [:description, "<p><img src=\"http://example.com/test/a.files/.thumb/test1.gif\" alt=\"t1 model\" width=\"100\" height=\"75\"/><p>This is a comment.</p>"], [:author, 'Alice'], [:pubDate, 'Thu, 01 Jan 1970 09:00:00 GMT'], [:enclosure, {:url=>'http://example.com/test/a.files/test1.mdlb', :length=>563, :type=>'application/xml'}], [:'creativeCommons:license', 'http://creativecommons.org/licenses/by/2.1/jp/']], [:item, [:title, 't2 model'], [:link, 'http://example.com/test/b.files/test2.mdlb'], [:description, "<p><img src=\"http://example.com/test/b.files/.thumb/test2.gif\" alt=\"t2 model\" width=\"100\" height=\"75\"/><p>This is a comment, too.</p>"], [:author, 'Bob'], [:pubDate, 'Thu, 01 Jan 1970 09:00:02 GMT'], [:enclosure, {:url=>'http://example.com/test/b.files/test2.mdlb', :length=>1395, :type=>'application/xml'}], [:'creativeCommons:license', 'http://creativecommons.org/licenses/by/2.1/jp/']]]]], res.body) end
prepare(con, im)
click to toggle source
setup_models()
click to toggle source
rss¶ ↑
# File vendor/qwik/lib/qwik/act-mdlb.rb, line 507 def setup_models t_add_user # Prepare a page. page = @site.create('a') page.store("* a * t1 model {{modulobe_model(test1.mdlb) :title: t1 model :author: Alice :comment: This is a comment.\n }} {{hcomment}} ") files = @site.files('a') files.put('test1.mdlb', MODULOBE_TEST_MODEL1, nil, 0) files.put('test1.gif', TEST_PNG_DATA, nil, 1) # Prepare another page. page = @site.create('b') page.store("* b * t2 model {{modulobe_model(test2.mdlb) :title: t2 model :author: Bob :comment: This is a comment, too.\n }} {{hcomment}} ") files = @site.files('b') files.put('test2.mdlb', MODULOBE_TEST_MODEL2, nil, 2) files.put('test2.gif', TEST_PNG_DATA, nil, 3) end
test_ext_mdlbrss()
click to toggle source
# File vendor/qwik/lib/qwik/act-mdlb.rb, line 541 def test_ext_mdlbrss setup_models res = session('/test/nosuch.mdlbrss') ok_xp([:title, 'moved'], '//title') res = session('/test/a.mdlbrss') ok_eq([[:'?xml', '1.0', 'utf-8'], [:rss, {:version=>'2.0'}, [:channel, [:title, 'moved'], [:link, 'http://example.com/model.xml'], [:description, 'moved.'], [:lastBuildDate, 'Thu, 01 Jan 1970 09:00:00 GMT'], [:ttl, '60'], [:item, [:title, 'moved'], [:link, 'http://example.com/model.xml'], [:description, 'moved'], [:pubDate, 'Thu, 01 Jan 1970 09:00:00 GMT']]]]], res.body) end
test_model()
click to toggle source
model¶ ↑
# File vendor/qwik/lib/qwik/act-mdlb.rb, line 415 def test_model t_add_user # test_modulobe_model page = @site.create('c') page.store('{{modulobe_model(test1.mdlb) :author: Modulobe Project :title: Test1 Model :comment: This is a sample model by Modulobe Project. http://www.modulobe.com/ }} {{hcomment}} ') model = MODULOBE_TEST_MODEL @site.files('c').put('test1.mdlb', model, nil, 0) image = TEST_PNG_DATA @site.files('c').put('test1.gif', image, nil, 1) res = session('/test/c.html') ok_xp([:table, [:tr, [:td, {:class=>'img'}, [:a, {:href=>'c.files/test1.mdlb'}, [:img, {:src=>'c.files/.thumb/test1.gif'}]]], [:td, {:class=>'desc'}, [[:h3, [:a, {:href=>'c.files/test1.mdlb'}, 'Test1 Model']], [:p, 'Author', ': ', [:strong, 'Modulobe Project']], [:p, [[:p, 'This is a sample model by Modulobe Project.']]]]]]], "//div[@class='modulobe_model']/table") end
test_modulobe_list()
click to toggle source
list¶ ↑
# File vendor/qwik/lib/qwik/act-mdlb.rb, line 482 def test_modulobe_list t_add_user # test_modulobe_model_list page = @site.create('c') model = MODULOBE_TEST_MODEL1 @site.files('c').put('test1.mdlb', model, nil, 0) image = TEST_PNG_DATA @site.files('c').put('test1.gif', image, nil, 1) page.store("{{modulobe_model_list}}") res = session('/test/c.html') list = res.body.get_path("//div[@class='files']") ok_xp([:tr, {:class=>'model'}, [:td, [:a, {:href=>'c.files/test1.mdlb'}, [:img, {:src=>'c.files/.thumb/test1.gif'}]]], [:td, [:div, {:class=>'author'}, 'Alice'], [:div, {:class=>'name'}, [:a, {:href=>'c.files/test1.mdlb'}, 't1 model']], [:pre, {:class=>'comment'}, "This is a comment.\n"]]], "//div[@class='files']/table/tr[2]") end
test_upload()
click to toggle source
# File vendor/qwik/lib/qwik/act-mdlb.rb, line 615 def test_upload t_add_user # test_modulobe_files_form page = @site.create('c') page.store('{{modulobe_files_form}}') res = session('/test/c.html') # See the form. form = @res.body.get_path("//div[@class='section']/form") ok_eq({:method=>'POST', :action=>'c.modulobe_files_upload', :enctype=>'multipart/form-data'}, form[1]) ok_eq([:form, {:enctype=>'multipart/form-data', :method=>'POST', :action=>'c.modulobe_files_upload'}, [:table, [:tr, [:th, 'Model file', ' : '], [:td, [:input, {:size=>'30', :type=>'file', :name=>'content'}]]], [:tr, [:th, 'Image file', ' : '], [:td, [:input, {:size=>'30', :type=>'file', :name=>'image'}]]], [:tr, [:td, ''], [:td, [:input, {:value=>'Attach', :type=>'submit'}]]]]], form) # test_upload content, image = prepare('test1.mdlb', 'test1.gif') session('POST /test/c.modulobe_files_upload') {|req| # Put a file. req.query.update({'content'=>content, 'image'=>image}) } ok_title('File attachment completed') sitelog = @site.sitelog # Check log. ok_eq(",0.000000,user@e.com,modulobe file attach,c\n", @site['_SiteLog'].load) # The model is attached. ok_eq("{{modulobe_files_form}} * {{modulobe_model(test1.mdlb) :title:\t\t :author:\t :comment:\t }} {{mcomment}} ", page.load) # Get the file. res = session('/test/c.files/test1.mdlb') assert_match(/\A<\?xml version="1\.0" encoding="utf-8"\?>/, res.body) ok_eq('application/x-modulobe', res['Content-Type']) # Get the image file. res = session('/test/c.files/test1.gif') ok_eq('image/gif', res['Content-Type']) end
test_with_invalid_character()
click to toggle source
# File vendor/qwik/lib/qwik/act-mdlb.rb, line 674 def test_with_invalid_character t_add_user page = @site.create('c') content, image = prepare('test 2.mdlb', 'test 2.gif') res = session('POST /test/c.modulobe_files_upload') {|req| # Put a file. req.query.update({'content'=>content, 'image'=>image}) } ok_title('File attachment completed') ok_xp([:p, [:strong, 'test 2.mdlb'], ' : ', 'The file is saved.'], "//div[@class='body_main']/p") # test_modulobe_files_upload_with_invalid_character content, image = prepare('test+2.mdlb', 'test 2.gif') res = session('POST /test/c.modulobe_files_upload') {|req| req.query.update({'content'=>content, 'image'=>image}) } ok_title('File attachment completed') ok_xp([:p, [:strong, 'test+2.mdlb'], ' : ', 'The file is saved.'], "//div[@class='body_main']/p") # Get the file. res = session('/test/c.files/test+2.mdlb') assert_match(/\A<\?xml version="1\.0" encoding="utf-8"\?>/, res.body) ok_eq('application/x-modulobe', res['Content-Type']) # Get the image file. res = session('/test/c.files/test+2.gif') ok_eq('image/gif', res['Content-Type']) end
test_with_japanese_character()
click to toggle source
# File vendor/qwik/lib/qwik/act-mdlb.rb, line 706 def test_with_japanese_character t_add_user page = @site.create('c') # Put files. content, image = prepare('c:\い\あ.mdlb', 'c:\い\あ.gif') res = session('POST /test/c.modulobe_files_upload') {|req| req.query.update({'content'=>content, 'image'=>image}) } ok_title('File attachment completed') ok_xp([:p, [:strong, 'あ.mdlb'], ' : ', 'The file is saved.'], "//div[@class='body_main']/p") # Get the file. res = session('/test/c.files/=E3=81=82.mdlb') assert_match(/\A<\?xml version="1\.0" encoding="utf-8"\?>/, res.body) ok_eq('application/x-modulobe', res['Content-Type']) # Put files again. # content and image are same. res = session('POST /test/c.modulobe_files_upload') {|req| req.query.update({'content'=>content, 'image'=>image}) } ok_title('File attachment completed') ok_xp([:p, [:strong, 'あ.mdlb'], ' -> ', [:strong, '1-あ.mdlb'], ' : ', 'The file is saved with this filename.'], "//div[@class='body_main']/p") # Get the file. res = session('/test/c.files/1-=E3=81=82.mdlb') assert_match(/\A<\?xml version="1\.0" encoding="utf-8"\?>/, res.body) ok_eq('application/x-modulobe', res['Content-Type']) end
test_with_minus()
click to toggle source
# File vendor/qwik/lib/qwik/act-mdlb.rb, line 450 def test_with_minus t_add_user page = @site.create('c') page.store('{{modulobe_model(test-2.mdlb) :author: Modulobe Project :title: Test-2 Model :comment: This is a sample. }} {{hcomment}} ') model = MODULOBE_TEST_MODEL @site.files('c').put('test-2.mdlb', model, nil, 0) image = TEST_PNG_DATA @site.files('c').put('test-2.gif', image, nil, 1) res = session('/test/c.html') ok_xp([:table, [:tr, [:td, {:class=>'img'}, [:a, {:href=>'c.files/test-2.mdlb'}, [:img, {:src=>'c.files/.thumb/test-2.gif'}]]], [:td, {:class=>'desc'}, [[:h3, [:a, {:href=>'c.files/test-2.mdlb'}, 'Test-2 Model']], [:p, 'Author', ': ', [:strong, 'Modulobe Project']], [:p, [[:p, 'This is a sample.']]]]]]], "//div[@class='modulobe_model']/table") end