<< | Index | >>
Experiment
Then 'SL' flag is shown, but 'SO' flag goes away.
Experiment
Default
Run update_bsv (first run)
masa@masa ~/ywesee/oddb.org $ bin/admin ch.oddb> Updater.new(self).update_bsv
Result
Run update_bsv again (second run)
masa@masa ~/ywesee/oddb.org $ bin/admin ch.oddb> Updater.new(self).update_bsv
Result
SL-Eintrag
Note
Experiment
Preparation
~/ywesee/oddb.org $ sudo -u postgres dropdb oddb.org ~/ywesee/oddb.org $ sudo -u postgres createdb -E UTF8 -T template0 oddb.org ~/ywesee/oddb.org $ zcat data/sql/oddb.org.20110106.sql.gz |psql -U postgres oddb.org
ch.oddb> Updater.new(self).update_bsv -> mhatakeyama@ywesee.com ch.oddb> Updater.new(self).update_bsv -> mhatakeyama@ywesee.com
Result
Note
Summary
Check the current test-cases
masa@masa ~/ywesee/oddb.org $ ruby test/test_plugin/bsv_xml.rb Loaded suite test/test_plugin/bsv_xml Started ......... Finished in 0.154731 seconds. 9 tests, 71 assertions, 0 failures, 0 errors
After this updating of bsv_xml.rb (http://dev.ywesee.com/wiki.php/Masa/20110107-debug-bag-list#Sum)
# update 'SB' flag elsif @pack if @pack.deductible != @pac_data[:deductible] @app.update @pack.pointer, @data, :bag end
Test
masa@masa ~/ywesee/oddb.org $ ruby test/test_plugin/bsv_xml.rb Loaded suite test/test_plugin/bsv_xml Started ...F..... Finished in 0.153695 seconds. 1) Failure: test_update_preparation__conflicted_package(ODDB::TestBsvXmlPlugin) [test/test_plugin/bsv_xml.rb:1014:in `test_update_preparation__conflicted_package' /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/expectation.rb:78:in `call' /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/expectation.rb:78:in `return_value' /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/expectation.rb:59:in `verify_call' /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/expectation_director.rb:42:in `call' /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/core.rb:101:in `method_missing' /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/core.rb:191:in `flexmock_wrap' /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/core.rb:98:in `method_missing' /home/masa/ywesee/oddb.org/src/plugin/bsv_xml.rb:370:in `tag_end' /usr/lib64/ruby/1.8/rexml/parsers/streamparser.rb:26:in `parse' /usr/lib64/ruby/1.8/rexml/document.rb:201:in `parse_stream' /home/masa/ywesee/oddb.org/src/plugin/bsv_xml.rb:989:in `update_preparations' test/test_plugin/bsv_xml.rb:1016:in `test_update_preparation__conflicted_package']: in mock 'app': <nil> expected but was <{:sl_generic_type=>:original, :ikscat=>"B", :deductible=>:deductible_g, :price_exfactory=> #<ODDB::Util::Money:0x7f513077a7d0 @amount=2.9, @authority=:sl, @country="CH", @credits=290, @mutation_code="NORMAL", @origin= "http://bag.e-mediat.net/SL2007.Web.External/File.axd?file=XMLPublications.zip (10.01.2011)", @type="exfactory", @valid_from=Tue Aug 01 00:00:00 +0200 2006>, :pharmacode=>"703279", :narcotic=>false, :price_public=> #<ODDB::Util::Money:0x7f5130761cd0 @amount=7.5, @authority=:sl, @country="CH", @credits=750, @mutation_code="NORMAL", @origin= "http://bag.e-mediat.net/SL2007.Web.External/File.axd?file=XMLPublications.zip (10.01.2011)", @type="public", @valid_from=Tue Aug 01 00:00:00 +0200 2006>}>. @report: {:name_descr=>"Filmtabs 500 mg ", :atc_class=>"M01AG01", :swissmedic_no5_bag=>"12345", :deductible=>:deductible_g, :swissmedic_no8_bag=>"39271028", :generic_type=>:original, :pharmacode_bag=>"703279", :pharmacode_oddb=>"987654", :name_base=>"Ponstan"} 9 tests, 65 assertions, 1 failures, 0 errors
Note
def test_update_preparation__conflicted_package package = setup_package :pharmacode => "987654", :steps => %w{39271 02 028}, :price_public => Util::Money.new(17.65), :price_exfactory => Util::Money.new(11.22) reg = setup_registration :iksnr => '39271', :package => package reg.should_receive(:packages).and_return [] package.should_receive(:registration).and_return reg flexmock(Package).should_receive(:find_by_pharmacode). times(1).and_return nil setup_meddata_server :ean13 => '7680392710281' @app.should_receive(:registration).and_return reg @app.should_receive(:each_package) expected_updates = {} ptr = Persistence::Pointer.new [:registration, '39271'] expected_updates.store ptr, { :generic_type => :original, :index_therapeuticus => '07.10.10.' } ptr += [:sequence, '02'] pac_pointer = ptr += [:package, '028'] @app.should_receive(:update).and_return do |ptr, data| assert_equal expected_updates.delete(ptr), data # HERE end
Note
Memo
def test_update_preparation__conflicted_package package = setup_package :pharmacode => "987654", :steps => %w{39271 02 028}, :price_public => Util::Money.new(17.65), :price_exfactory => Util::Money.new(11.22) reg = setup_registration :iksnr => '39271', :package => package reg.should_receive(:packages).and_return [] package.should_receive(:registration).and_return reg flexmock(Package).should_receive(:find_by_pharmacode). times(1).and_return nil setup_meddata_server :ean13 => '7680392710281' @app.should_receive(:registration).and_return reg @app.should_receive(:each_package) expected_updates = {} ptr = Persistence::Pointer.new [:registration, '39271'] expected_updates.store ptr, { :generic_type => :original, :index_therapeuticus => '07.10.10.' } ptr += [:sequence, '02'] pac_pointer = ptr += [:package, '028']
Notes
@app.should_receive(:update).and_return do |ptr, data| assert_equal expected_updates.delete(ptr), data # HERE end
Note
'ptr' and 'data' are arguments of '@app.update' method somewhere in the code
This is unclear because 'ptr' and 'data' are placed after 'and_return' method
@plugin.update_preparations StringIO.new(@conflicted_src)
Note
Experiment (without updating)
def test_update_preparation__conflicted_package package = setup_package :pharmacode => "987654", :steps => %w{39271 02 028}, :price_public => Util::Money.new(17.65), :price_exfactory => Util::Money.new(11.22) reg = setup_registration :iksnr => '39271', :package => package reg.should_receive(:packages).and_return [] package.should_receive(:registration).and_return reg flexmock(Package).should_receive(:find_by_pharmacode). times(1).and_return nil setup_meddata_server :ean13 => '7680392710281' @app.should_receive(:registration).and_return reg @app.should_receive(:each_package) expected_updates = {} ptr = Persistence::Pointer.new [:registration, '39271'] expected_updates.store ptr, { :generic_type => :original, :index_therapeuticus => '07.10.10.' } ptr += [:sequence, '02'] pac_pointer = ptr += [:package, '028'] @app.should_receive(:update).and_return do |ptr, data| print "ptr=" pp ptr print "data=" pp data assert_equal expected_updates.delete(ptr), data # HERE end
Result
masa@masa ~/ywesee/oddb.org $ ruby test/test_plugin/bsv_xml.rb Loaded suite test/test_plugin/bsv_xml Started ptr=#<ODDB::Persistence::Pointer:0x7f04168491f0 @directions=[[:registration, "39271"]]> data={:generic_type=>:original, :index_therapeuticus=>"07.10.10."} . Finished in 0.029529 seconds. 1 tests, 2 assertions, 0 failures, 0 errors
Note
ptr = Persistence::Pointer.new [:registration, '39271'] expected_updates.store ptr, { :generic_type => :original, :index_therapeuticus => '07.10.10.' } expected_pointer = ptr #@app.should_receive(:update).and_return do |ptr, data| @app.should_receive(:update).and_return do |pointer, update_data| assert_equal expected_pointer, pointer assert_equal expected_updates[pointer], update_data end @plugin.update_preparations StringIO.new(@conflicted_src)
Result
masa@masa ~/ywesee/oddb.org $ ruby test/test_plugin/bsv_xml.rb Loaded suite test/test_plugin/bsv_xml Started . Finished in 0.029847 seconds. 1 tests, 3 assertions, 0 failures, 0 errors
Note
Experiment
ptr = Persistence::Pointer.new [:registration, '39271'] expected_updates.store ptr, { :generic_type => :original, :index_therapeuticus => '07.10.10.' } expected_pointer = ptr #@app.should_receive(:update).and_return do |ptr, data| =begin @app.should_receive(:update).and_return do |pointer, update_data| assert_equal expected_pointer, pointer assert_equal expected_updates[pointer], update_data end =end @plugin.update_preparations StringIO.new(@conflicted_src)
Result
masa@masa ~/ywesee/oddb.org $ ruby test/test_plugin/bsv_xml.rb Loaded suite test/test_plugin/bsv_xml Started E Finished in 0.028686 seconds. 1) Error: test_update_preparation__conflicted_package(ODDB::TestBsvXmlPlugin): NoMethodError: undefined method `update' for <FlexMock:app>:FlexMock @report: {:name_base=>"Ponstan", :swissmedic_no8_bag=>"39271028", :generic_type=>:original, :atc_class=>"M01AG01", :deductible=>:deductible_g, :pharmacode_oddb=>"987654", :name_descr=>"Filmtabs 500 mg ", :swissmedic_no5_bag=>"12345", :pharmacode_bag=>"703279"} /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/core.rb:105:in `method_missing' /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/core.rb:191:in `flexmock_wrap' /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/core.rb:98:in `method_missing' /home/masa/ywesee/oddb.org/src/plugin/bsv_xml.rb:444:in `tag_end' /usr/lib64/ruby/1.8/rexml/parsers/streamparser.rb:26:in `parse' /usr/lib64/ruby/1.8/rexml/document.rb:201:in `parse_stream' /home/masa/ywesee/oddb.org/src/plugin/bsv_xml.rb:990:in `update_preparations' test/test_plugin/bsv_xml.rb:1030:in `test_update_preparation__conflicted_package' 1 tests, 1 assertions, 0 failures, 1 errors
Note
if @registration @app.update @registration.pointer, @reg_data, :bag #<= here elsif @refdata_registration @unknown_registrations.push @report_data end
So, let's go back to the new updating part
@data.delete :ikscat if @pack.ikscat @app.update @pack.pointer, @data, :bag @sl_entries.store @pack.pointer, @sl_data @lim_texts.store @pack.pointer, @lim_data #=begin # update 'SB' flag elsif @pack if @pack.deductible != @pac_data[:deductible] @app.update @pack.pointer, @data, :bag end #=end end @pcode, @pack, @sl_data, @lim_data, @out_of_trade, @ikscd, @data, @size = nil
Next
Consideration
Experiment
test/test_plugin/bsv_xml.rb#test_update__conflicted_registration
def test_update_preparation__conflicted_package package = setup_package :pharmacode => "987654", :steps => %w{39271 02 028}, :price_public => Util::Money.new(17.65), :price_exfactory => Util::Money.new(11.22) package.should_receive(:deductible).and_return(:deductible_g) reg = setup_registration :iksnr => '39271', :package => package reg.should_receive(:packages).and_return [] package.should_receive(:registration).and_return reg flexmock(Package).should_receive(:find_by_pharmacode). times(1).and_return nil setup_meddata_server :ean13 => '7680392710281' @app.should_receive(:registration).and_return reg @app.should_receive(:each_package) expected_updates = {} ptr = Persistence::Pointer.new [:registration, '39271'] expected_updates.store ptr, { :generic_type => :original, :index_therapeuticus => '07.10.10.' } expected_pointer = ptr ptr += [:sequence, '02'] pac_pointer = ptr += [:package, '028'] #@app.should_receive(:update).and_return do |ptr, data| @app.should_receive(:update).and_return do |pointer, update_data| #assert_equal expected_updates.delete(ptr), data assert_equal expected_pointer, pointer assert_equal expected_updates[pointer], update_data end @plugin.update_preparations StringIO.new(@conflicted_src) #assert_equal({}, expected_updates) assert_equal({}, @plugin.change_flags) listener = @plugin.preparations_listener expected = [ { :name_base => "Ponstan", :name_descr => "Filmtabs 500 mg ", :swissmedic_no5_bag => "12345", :swissmedic_no8_bag => "39271028", :pharmacode_bag => "703279", :pharmacode_oddb => "987654", :generic_type => :original, :deductible => :deductible_g, :atc_class => "M01AG01", } ] assert_equal expected, listener.conflicted_packages assert_equal [], listener.conflicted_registrations assert_equal [], listener.unknown_packages expected = [] assert_equal [], listener.unknown_registrations end
Result
masa@masa ~/ywesee/oddb.org $ ruby test/test_plugin/bsv_xml.rb Loaded suite test/test_plugin/bsv_xml Started . Finished in 0.029053 seconds. 1 tests, 8 assertions, 0 failures, 0 errors
Note
Check all the tests
masa@masa ~/ywesee/oddb.org $ ruby test/test_plugin/bsv_xml.rb Loaded suite test/test_plugin/bsv_xml Started ......... Finished in 0.147585 seconds. 9 tests, 71 assertions, 0 failures, 0 errors
Note
Then
Design
Preparation
Confirm
masa@masa ~/ywesee/oddb.org $ ruby test/test_plugin/bsv_xml.rb Loaded suite test/test_plugin/bsv_xml Started . Finished in 0.03303 seconds. 1 tests, 10 assertions, 0 failures, 0 errors
suspend
Tempate
def test_update_preparation__change_only_SB_flag assert(true) end
Check it passes
masa@masa ~/ywesee/oddb.org $ ruby test/test_plugin/bsv_xml.rb Loaded suite test/test_plugin/bsv_xml Started . Finished in 0.00025 seconds. 1 tests, 1 assertions, 0 failures, 0 errors