<< Masa.20101223-testcase-ch_oddb_org-generics_xls | 2010 | Masa.20101221-update-ch_oddb_org-generics_xls >>
I have ran the jobs (update_bsv and export_generics) yesterday
Result
Success
Hypothesis
ToDo
Run
Result
Plugin: ODDB::XlsExportPlugin Error: NoMethodError Message: undefined method `[]' for nil:NilClass Backtrace: (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/generics_xls.rb:185:in `_remarks' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/generics_xls.rb:176:in `remarks' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/generics_xls.rb:168:in `format_row' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/generics_xls.rb:71:in `export_comparable' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/generics_xls.rb:78:in `export_comparables' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/generics_xls.rb:76:in `each' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/generics_xls.rb:76:in `export_comparables' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/generics_xls.rb:130:in `export_generics' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/generics_xls.rb:130:in `each' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/generics_xls.rb:130:in `export_generics' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/odba_exporter.rb:98:in `export_generics_xls' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/odba_exporter.rb:255:in `call' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/odba_exporter.rb:255:in `safe_export' (druby://localhost:10005) /usr/lib64/ruby/1.8/tempfile.rb:172:in `open' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/odba_exporter.rb:254:in `safe_export' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/odba_exporter.rb:96:in `export_generics_xls' /home/masa/ywesee/oddb.org/src/plugin/xls_export.rb:23:in `export_generics' /home/masa/ywesee/oddb.org/src/util/updater.rb:101:in `export_generics_xls' /home/masa/ywesee/oddb.org/src/util/updater.rb:453:in `call' /home/masa/ywesee/oddb.org/src/util/updater.rb:453:in `wrap_update' /home/masa/ywesee/oddb.org/src/util/updater.rb:99:in `export_generics_xls' (eval):1:in `_admin' /home/masa/ywesee/oddb.org/src/util/failsafe.rb:9:in `call' /home/masa/ywesee/oddb.org/src/util/failsafe.rb:9:in `failsafe' /home/masa/ywesee/oddb.org/src/util/oddbapp.rb:1399:in `_admin' /home/masa/ywesee/oddb.org/src/util/oddbapp.rb:1397:in `initialize' /home/masa/ywesee/oddb.org/src/util/oddbapp.rb:1397:in `new' /home/masa/ywesee/oddb.org/src/util/oddbapp.rb:1397:in `_admin' /usr/lib64/ruby/1.8/drb/drb.rb:1556:in `__send__' /usr/lib64/ruby/1.8/drb/drb.rb:1556:in `perform_without_block' /usr/lib64/ruby/1.8/drb/drb.rb:1516:in `perform' /usr/lib64/ruby/1.8/drb/drb.rb:1590:in `main_loop' /usr/lib64/ruby/1.8/drb/drb.rb:1586:in `loop' /usr/lib64/ruby/1.8/drb/drb.rb:1586:in `main_loop' /usr/lib64/ruby/1.8/drb/drb.rb:1582:in `start' /usr/lib64/ruby/1.8/drb/drb.rb:1582:in `main_loop' /usr/lib64/ruby/1.8/drb/drb.rb:1431:in `run' /usr/lib64/ruby/1.8/drb/drb.rb:1428:in `start' /usr/lib64/ruby/1.8/drb/drb.rb:1428:in `run' /usr/lib64/ruby/1.8/drb/drb.rb:1348:in `initialize' /usr/lib64/ruby/1.8/drb/drb.rb:1628:in `new' /usr/lib64/ruby/1.8/drb/drb.rb:1628:in `start_service' bin/oddbd:38
Note
def run logfile_stats =begin if(update_swissmedic) update_swissmedic_followers end update_swissmedicjournal update_vaccines =end return_value_update_bsv = update_bsv LogFile.append('oddb/debug', " return_value_update_bsv=" + return_value_update_bsv.inspect.to_s, Time.now) #if(update_bsv) if(return_value_update_bsv) update_bsv_followers end =begin update_narcotics run_on_monthday(1) { update_interactions } =end end ... def update_bsv_followers LogFile.append('oddb/debug', " getin update_bsv_followers", Time.now) =begin update_trade_status update_medwin_packages update_lppv update_price_feeds export_oddb_csv # export_oddb2_csv # Disabled 4.1.2010 export_ouwerkerk =end export_generics_xls # export_competition_xlss end
Run
Result
Check new files
masa@masa ~/ywesee/oddb.org $ git status # On branch master # Changed but not updated: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: src/util/updater.rb # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # data/downloads/ # data/xml/ # log/ masa@masa ~/ywesee/oddb.org $ ls -al data/downloads/ insgesamt 4396 drwxr-xr-x 2 masa masa 88 22. Dez 08:23 . drwxr-xr-x 9 masa masa 56 22. Dez 07:55 .. -rw-r--r-- 1 masa masa 3093504 22. Dez 08:23 generics.xls -rw-r--r-- 1 masa masa 699700 22. Dez 08:23 generics.xls.gz -rw-r--r-- 1 masa masa 699805 22. Dez 08:23 generics.xls.zip masa@masa ~/ywesee/oddb.org $ ls -al data/xml/ insgesamt 6176 drwxr-xr-x 2 masa masa 16 22. Dez 07:55 . drwxr-xr-x 9 masa masa 56 22. Dez 07:55 .. -rw-r--r-- 1 masa masa 3160927 22. Dez 07:55 XMLPublications-2010.12.22.zip -rw-r--r-- 1 masa masa 3160927 22. Dez 07:55 XMLPublications-latest.zip masa@masa ~/ywesee/oddb.org $ ls -al log/oddb/debug/2010/ insgesamt 8 drwxr-xr-x 2 masa masa 32 22. Dez 08:24 . drwxr-xr-x 3 masa masa 8 22. Dez 07:55 .. -rw-r--r-- 1 masa masa 4345 22. Dez 08:23 12.log
Conclusion
Experiment
Result
Experiment
Result
Experiment
Result
Notes
Check the current test cases
masa@masa ~/ywesee/oddb.org $ ruby test/test_model/package.rb Loaded suite test/test_model/package Started .........F.F...................................... Finished in 0.039492 seconds. 1) Failure: test_comparables1(ODDB::TestPackage) [test/test_model/package.rb:179]: <[#<ODDB::Package:0x7f18218038c0 @feedbacks=[], @ikscd="098", @narcotics=[], @odba_id=11, @oid=11, @parts= [#<ODDB::Part:0x7f1821803898 @addition=0, @comform="Tabletten", @comparable_size=Quanty(12.0,''), @count=12, @measure=Quanty(1,''), @multi=Quanty(1,''), @odba_id=12, @oid=12, @revision=Wed Dec 22 09:04:17 +0100 2010, @scale=Quanty(1,'')>], @revision=Wed Dec 22 09:04:17 +0100 2010>]> expected but was <[]>. 2) Failure: test_comparables3(ODDB::TestPackage) [test/test_model/package.rb:210]: <[#<ODDB::Package:0x7f1821a16270 @feedbacks=[], @ikscd="098", @narcotics=[], @odba_id=21, @oid=21, @parts= [#<ODDB::Part:0x7f1821a0f4e8 @addition=0, @comform="Tabletten", @comparable_size=Quanty(12.0,''), @count=12, @measure=Quanty(1,''), @multi=Quanty(1,''), @odba_id=22, @oid=22, @revision=Wed Dec 22 09:04:17 +0100 2010, @scale=Quanty(1,'')>], @revision=Wed Dec 22 09:04:17 +0100 2010>, #<ODDB::Package:0x7f1821a4b998 @feedbacks=[], @ikscd="097", @narcotics=[], @odba_id=19, @oid=19, @parts= [#<ODDB::Part:0x7f1821a4b948 @addition=0, @comform="Tabletten", @comparable_size=Quanty(12.0,''), @count=12, @measure=Quanty(1,''), @multi=Quanty(1,''), @odba_id=20, @oid=20, @revision=Wed Dec 22 09:04:17 +0100 2010, @scale=Quanty(1,'')>], @revision=Wed Dec 22 09:04:17 +0100 2010>]> expected but was <[]>. 50 tests, 126 assertions, 2 failures, 0 errors
Note
Experiment
def comparable?(bottom, top, pack) begin pack != self \ && (other = pack.comparable_size) \ && bottom < other \ && top > other # && top > other \ # && !pack.basename.nil? rescue RuntimeError => e false end end
Check test
masa@masa ~/ywesee/oddb.org $ ruby test/test_model/package.rb Loaded suite test/test_model/package Started .................................................. Finished in 0.019958 seconds. 50 tests, 126 assertions, 0 failures, 0 errors
Notes
Next
without update Package#comparables?
src/model/package.rb#comparable?
def comparable?(bottom, top, pack) begin pack != self \ && (other = pack.comparable_size) \ && bottom < other \ && top > other # && top > other \ # && !pack.basename.nil? rescue RuntimeError => e false end end
Check testcases
masa@masa ~/ywesee/oddb.org $ ruby test/test_model/suite.rb /home/masa/ywesee/oddb.org/src/view/drugs/resultlist.rb:21: warning: already initialized constant BACKGROUND_SUFFIX /usr/lib64/ruby/site_ruby/1.8/rpdf2txt-rockit/sourcecode_dumpable.rb:73: warning: redefining constant Struct::MethodNamed /usr/lib64/ruby/site_ruby/1.8/rpdf2txt-rockit/sourcecode_dumpable.rb:73: warning: already initialized constant MethodNamed /usr/lib64/ruby/site_ruby/1.8/rpdf2txt-rockit/sourcecode_dumpable.rb:74: warning: redefining constant Struct::ModuleMethodNamed /usr/lib64/ruby/site_ruby/1.8/rpdf2txt-rockit/sourcecode_dumpable.rb:74: warning: already initialized constant ModuleMethodNamed /usr/lib64/ruby/site_ruby/1.8/rpdf2txt-rockit/glr_parser.rb:275: warning: redefining constant Struct::Link /usr/lib64/ruby/site_ruby/1.8/rpdf2txt-rockit/glr_parser.rb:275: warning: already initialized constant Link /usr/lib64/ruby/site_ruby/1.8/rpdf2txt-rockit/conflict_resolution.rb:18: warning: redefining constant Struct::Relation /usr/lib64/ruby/site_ruby/1.8/rpdf2txt-rockit/conflict_resolution.rb:18: warning: already initialized constant Relation /usr/lib64/ruby/site_ruby/1.8/rpdf2txt-rockit/grammar.rb:591: warning: already initialized constant EpsilonToken /usr/lib64/ruby/site_ruby/1.8/rpdf2txt-rockit/graphviz_dot.rb:52: warning: redefining constant Struct::DotGraph /usr/lib64/ruby/site_ruby/1.8/rpdf2txt-rockit/graphviz_dot.rb:52: warning: already initialized constant DotGraph /usr/lib64/ruby/site_ruby/1.8/rpdf2txt-rockit/directed_graph.rb:16: warning: redefining constant Struct::GraphLink /usr/lib64/ruby/site_ruby/1.8/rpdf2txt-rockit/directed_graph.rb:16: warning: already initialized constant GraphLink /usr/lib64/ruby/site_ruby/1.8/rpdf2txt-rockit/reduce_actions_generator.rb:273: warning: redefining constant Struct::LaLrPair /usr/lib64/ruby/site_ruby/1.8/rpdf2txt-rockit/reduce_actions_generator.rb:273: warning: already initialized constant LaLrPair [DEPRECATED] By requiring 'spreadsheet/excel' you are loading a Compatibility layer which provides a drop-in replacement for Spreadsheet::Excel versions <= 0.3.5.1. This code will be removed in Spreadsheet version 1.0.0 /home/masa/ywesee/oddb.org/src/view/changelog.rb:26: warning: already initialized constant SORT_DEFAULT /home/masa/ywesee/oddb.org/test/test_model/text.rb:273: warning: parenthesize argument(s) for future version /home/masa/ywesee/oddb.org/test/test_model/user.rb:15: warning: already initialized constant YUS_SERVER Loaded suite test/test_model/suite Started ..........................................................................................................................................................................................................................................................................................................................................................................................................Substance.merge: no active agent, only removing sequence ............................................................................................................................................................................ Finished in 0.216205 seconds. 566 tests, 1376 assertions, 0 failures, 0 errors
Note
without update Package#comparables?
Check testcases
masa@masa ~/ywesee/oddb.org $ ruby test/suite.rb ... 1005 tests, 2415 assertions, 7 failures, 36 errors
Note
with update Package#comparables? src/model/package.rb#comparable?
def comparable?(bottom, top, pack) begin pack != self \ && (other = pack.comparable_size) \ && bottom < other \ && top > other \ && !pack.basename.nil? # && top > other rescue RuntimeError => e false end end
Check testcases
masa@masa ~/ywesee/oddb.org $ ruby test/test_model/suite.rb ... 1) Failure: test_comparables1(ODDB::TestPackage) [/home/masa/ywesee/oddb.org/test/test_model/package.rb:179]: <[#<ODDB::Package:0x7fbe31626000 @feedbacks=[], @ikscd="098", @narcotics=[], @odba_id=62, @oid=62, @parts= [#<ODDB::Part:0x7fbe31625fd8 @addition=0, @comform="Tabletten", @comparable_size=Quanty(12.0,''), @count=12, @measure=Quanty(1,''), @multi=Quanty(1,''), @odba_id=63, @oid=63, @revision=Wed Dec 22 09:23:05 +0100 2010, @scale=Quanty(1,'')>], @revision=Wed Dec 22 09:23:05 +0100 2010>]> expected but was <[]>. 2) Failure: test_comparables3(ODDB::TestPackage) [/home/masa/ywesee/oddb.org/test/test_model/package.rb:210]: <[#<ODDB::Package:0x7fbe316012c8 @feedbacks=[], @ikscd="098", @narcotics=[], @odba_id=72, @oid=72, @parts= [#<ODDB::Part:0x7fbe31600b20 @addition=0, @comform="Tabletten", @comparable_size=Quanty(12.0,''), @count=12, @measure=Quanty(1,''), @multi=Quanty(1,''), @odba_id=73, @oid=73, @revision=Wed Dec 22 09:23:05 +0100 2010, @scale=Quanty(1,'')>], @revision=Wed Dec 22 09:23:05 +0100 2010>, #<ODDB::Package:0x7fbe31604248 @feedbacks=[], @ikscd="097", @narcotics=[], @odba_id=70, @oid=70, @parts= [#<ODDB::Part:0x7fbe31604220 @addition=0, @comform="Tabletten", @comparable_size=Quanty(12.0,''), @count=12, @measure=Quanty(1,''), @multi=Quanty(1,''), @odba_id=71, @oid=71, @revision=Wed Dec 22 09:23:05 +0100 2010, @scale=Quanty(1,'')>], @revision=Wed Dec 22 09:23:05 +0100 2010>]> expected but was <[]>. 566 tests, 1376 assertions, 2 failures, 0 errors
Note
with update Package#comparables?
masa@masa ~/ywesee/oddb.org $ ruby test/suite.rb ... 1005 tests, 2415 assertions, 9 failures, 36 errors
Note
Anyway,
Memo
test/test_model/package.rb
def test_comparable? part1 = flexmock :comparable_size => Dose.new(5, 'ml') part2 = flexmock :comparable_size => Dose.new(10, 'ml') @package.parts.push part1, part2 pack = ODDB::Package.new('98') seq = StubPackageSequence.new seq.basename = "masa" pack.parts.push part1, part2 pack.sequence = seq top = @package.comparable_size * 1.25 bottom = @package.comparable_size * 0.75 assert(@package.comparable?(bottom, top, pack)) end def test_comparable_failcase part1 = flexmock :comparable_size => Dose.new(5, 'ml') part2 = flexmock :comparable_size => Dose.new(10, 'ml') @package.parts.push part1, part2 pack = ODDB::Package.new('98') pack.parts.push part1, part2 # pack.basename == nil top = @package.comparable_size * 1.25 bottom = @package.comparable_size * 0.75 assert_equal(false, @package.comparable?(bottom, top, pack)) end
Result
masa@masa ~/ywesee/oddb.org $ ruby test/test_model/package.rb Loaded suite test/test_model/package Started .. Finished in 0.002655 seconds. 2 tests, 2 assertions, 0 failures, 0 errors
Note
def test_comparables1 seq = StubPackageSequence.new seq.basename = "abc" pack = ODDB::Package.new('98') pack.sequence = seq part = ODDB::Part.new part.size = '12 Tabletten' pack.parts.push part seq.active_packages = [pack] @package.sequence.comparables = [seq] part = ODDB::Part.new part.size = '15 Tabletten' @package.parts.push part assert_equal([pack], @package.comparables) end
Result
masa@masa ~/ywesee/oddb.org $ ruby test/test_model/package.rb Loaded suite test/test_model/package Started ... Finished in 0.004064 seconds. 3 tests, 3 assertions, 0 failures, 0 errors
def test_comparables3 seq = StubPackageSequence.new seq.basename = "abc" seqpack = ODDB::Package.new('97') seqpack.sequence = seq part = ODDB::Part.new part.size = '12 Tabletten' seqpack.parts.push part pack = ODDB::Package.new('98') pack.sequence = seq part = ODDB::Part.new part.size = '12 Tabletten' pack.parts.push part seq.active_packages = [pack] @package.sequence.comparables = [seq] @package.sequence.active_packages = [seqpack, @package] part = ODDB::Part.new part.size = '15 Tabletten' @package.parts.push part assert_equal([pack, seqpack], @package.comparables) end
Result
masa@masa ~/ywesee/oddb.org $ ruby test/test_model/package.rb Loaded suite test/test_model/package Started .... Finished in 0.006047 seconds. 4 tests, 4 assertions, 0 failures, 0 errors
Check all the test cases
masa@masa ~/ywesee/oddb.org $ ruby test/test_model/suite.rb ... 568 tests, 1378 assertions, 0 failures, 0 errors
Note
Commit
Check the current test-case
masa@masa ~/ywesee/oddb.org/ext/export $ ls -al test insgesamt 4 drwxr-xr-x 2 masa masa 8 22. Dez 07:28 . drwxr-xr-x 5 masa masa 24 22. Dez 07:28 .. -rw-r--r-- 1 masa masa 3293 22. Dez 07:28 test_csv_exporter.rb
Note
Strategy
Check test_csv_exporter.rb
masa@masa ~/ywesee/oddb.org/ext/export $ ruby test/test_csv_exporter.rb Loaded suite test/test_csv_exporter Started FF"8600;00;9300.00;Test de;Teste fr;Fussnote;FRussnote;Taxen;Taxes;Limit;LimitFR;Titel;Titre;C,I;30;n;{teiliste}:{spital},{list1}:{blabla};{list1}:{blabla}\n" . Finished in 0.001627 seconds. 1) Failure: test_dump_1(ODDB::OdbaExporter::TestCsvExporter) [test/test_csv_exporter.rb:72]: <"7601000616715;1998;Herrn;Dr. med;Fabrice;Dami;false;at_work;;;Foobodenstrasse 1;1234;Neuch\342tel;NE;fon1,fon2;;amig@amig.ch;franz\366sisch;Kardiologie,Psychokardiologie\n"> expected but was <"7601000616715;1998;Herrn;Dr. med;Fabrice;Dami;false;at_work;\"\";\"\";Foobodenstrasse 1;1234;Neuch\342tel;NE;fon1,fon2;\"\";amig@amig.ch;franz\366sisch;Kardiologie,Psychokardiologie\n">. 2) Failure: test_dump_2(ODDB::OdbaExporter::TestCsvExporter) [test/test_csv_exporter.rb:82]: <"7601000616715;1998;Herrn;Dr. med;Fabrice;Dami;true;at_praxis;;;Foobodenstrasse 1;1234;Neuch\342tel;NE;fon1,fon2;;amig@amig.ch;franz\366sisch;Kardiologie,Psychokardiologie\n"> expected but was <"7601000616715;1998;Herrn;Dr. med;Fabrice;Dami;true;at_praxis;\"\";\"\";Foobodenstrasse 1;1234;Neuch\342tel;NE;fon1,fon2;\"\";amig@amig.ch;franz\366sisch;Kardiologie,Psychokardiologie\n">. 3 tests, 3 assertions, 2 failures, 0 errors
Note
The following methods are only in generics_xls.rb
Notes
Template
ext/export/test/test_generics_xls.rb
#!/usr/bin/env ruby # Odba::Exporter::TestGenericsXls -- oddb -- 22.12.2010 -- mhatakeyama@ywesee.com #$: << File.expand_path('../src', File.dirname(__FILE__)) require 'test/unit' require 'flexmock' module ODDB module OdbaExporter class TestGenericsXls < Test::Unit::TestCase include FlexMock::TestCase def setup end def test_export_comparable end def test_export_comparables end def test_export_generic end def test_export_generics end def test_format_original end def test_format_generic end def test_format_price end def test_format_row end def test_preprocess_fields end def test_remarks end def test__remarks end end end end
Result
masa@masa ~/ywesee/oddb.org/ext/export $ ruby test/test_generics_xls.rb Loaded suite test/test_generics_xls Started ........... Finished in 0.00039 seconds. 11 tests, 0 assertions, 0 failures, 0 errors
ext/export/test/test_generics_xls.rb
#!/usr/bin/env ruby # Odba::Exporter::TestGenericsXls -- oddb -- 22.12.2010 -- mhatakeyama@ywesee.com $: << File.expand_path('../src', File.dirname(__FILE__)) $: << File.expand_path('../../../src', File.dirname(__FILE__)) $: << File.expand_path('../../..', File.dirname(__FILE__)) require 'test/unit' require 'flexmock' require 'spreadsheet' require 'generics_xls' module ODDB module OdbaExporter class TestGenericsXls < Test::Unit::TestCase include FlexMock::TestCase def setup flexstub(ODBA.cache) do |cacheobj| cacheobj.should_receive(:fetch_named).and_return do flexmock do |appobj| appobj.should_receive(:log_group).and_return do flexmock do |obj| obj.should_receive(:latest).and_return do flexmock do |obj2| obj2.should_receive(:change_flags).and_return({}) end end end end end end end @generics_xls = GenericXls.new(".") end ...
Result
masa@masa ~/ywesee/oddb.org/ext/export $ ruby test/test_generics_xls.rb Started . Finished in 0.001849 seconds. 1 tests, 0 assertions, 0 failures, 0 errors
Note
Improved setup
ext/export/test/test_generics_xls.rb
$: << File.expand_path('../src', File.dirname(__FILE__)) $: << File.expand_path('../../../src', File.dirname(__FILE__)) $: << File.expand_path('../../..', File.dirname(__FILE__)) require 'test/unit' require 'flexmock' require 'spreadsheet' require 'generics_xls' require 'date' module ODDB module OdbaExporter class TestGenericXls < Test::Unit::TestCase include FlexMock::TestCase def setup loggroup_swiss = LogGroup.new(:swissmedic_journal) loggroup_swiss.create_log(Date.today) loggroup_swiss.latest.change_flags = {} loggroup_bsv = LogGroup.new(:bsv_sl) loggroup_bsv.create_log(Date.today) loggroup_bsv.latest.change_flags = {} flexstub(ODBA.cache) do |cacheobj| cacheobj.should_receive(:fetch_named).and_return do flexmock do |appobj| appobj.should_receive(:log_group).with(:swissmedic_journal).and_return(loggroup_swiss) appobj.should_receive(:log_group).with(:bsv_sl).and_return(loggroup_bsv) end end end @generics_xls = GenericXls.new(".") end ...
Result
masa@masa ~/ywesee/oddb.org/ext/export $ ruby test/test_generics_xls.rb Loaded suite test/test_generics_xls Started . Finished in 0.001876 seconds. 1 tests, 0 assertions, 0 failures, 0 errors
ext/export/test/test_generics_xls.rb
def setup loggroup_swiss = LogGroup.new(:swissmedic_journal) loggroup_swiss.create_log(Date.today) loggroup_swiss.latest.change_flags = {123 => [:new]} loggroup_bsv = LogGroup.new(:bsv_sl) loggroup_bsv.create_log(Date.today) loggroup_bsv.latest.change_flags = {123 => [:price_cut]} flexstub(ODBA.cache) do |cacheobj| cacheobj.should_receive(:fetch_named).and_return do flexmock do |appobj| appobj.should_receive(:log_group).with(:swissmedic_journal).and_return(loggroup_swiss) appobj.should_receive(:log_group).with(:bsv_sl).and_return(loggroup_bsv) end end end @generics_xls = GenericXls.new(".") end def test__remarks1 pac = flexmock(Package) do |pacobj| pacobj.should_receive(:"registration.pointer").and_return(999) pacobj.should_receive(:pointer).and_return(999) end assert_nil(@generics_xls._remarks(pac, 'Generikum')) end def test__remarks2 pac = flexmock(Package) do |pacobj| pacobj.should_receive(:"registration.pointer").and_return(123) pacobj.should_receive(:pointer).and_return(123) end assert_equal("Generikum: neue Registration, Preissenkung", @generics_xls._remarks(pac, 'Generikum')) end
Result
masa@masa ~/ywesee/oddb.org/ext/export $ ruby test/test_generics_xls.rb Loaded suite test/test_generics_xls Started .. Finished in 0.004724 seconds. 2 tests, 2 assertions, 0 failures, 0 errors
Note
def test_remarks pac = flexstub(Package) do |pacobj| pacobj.should_receive(:"registration.pointer").and_return(123) pacobj.should_receive(:pointer).and_return(123) end assert_equal("Original: neue Registration, Preissenkung Generikum: neue Registration, Preissenkung", @generics_xls.remarks(pac, pac)) end
Result
masa@masa ~/ywesee/oddb.org/ext/export $ ruby test/test_generics_xls.rb Loaded suite test/test_generics_xls Started ... Finished in 0.007019 seconds. 3 tests, 3 assertions, 0 failures, 0 errors
ext/export/src/generics_xls.rb#format_price
def format_price(price) if(price && price > 0.0) sprintf("%4.2f", price.to_f) end end
Note
def test_format_price price = nil assert_nil(@generics_xls.format_price(price)) price = 12.349 assert_equal("12.35", @generics_xls.format_price(price)) end
Result
masa@masa ~/ywesee/oddb.org/ext/export $ ruby test/test_generics_xls.rb Loaded suite test/test_generics_xls Started .... Finished in 0.008478 seconds. 4 tests, 5 assertions, 0 failures, 0 errors
def test_preprocess_fields fields = [1,2,3,Date.new(2010, 12, 31)] assert_equal(["1","2","3","31.12.2010"], @generics_xls.preprocess_fields(fields)) end
Result
masa@masa ~/ywesee/oddb.org/ext/export $ ruby test/test_generics_xls.rb Loaded suite test/test_generics_xls Started ..... Finished in 0.010271 seconds. 5 tests, 6 assertions, 0 failures, 0 errors
def test_format_original pac = flexstub(Package) do |pacobj| pacobj.should_receive(:basename).and_return("basename") pacobj.should_receive(:dose).and_return("dose") pacobj.should_receive(:comparable_size).and_return(111) pacobj.should_receive(:barcode).and_return(222) pacobj.should_receive(:pharmacode).and_return(333) pacobj.should_receive(:name).and_return("name") pacobj.should_receive(:price_exfactory).and_return(444.444) pacobj.should_receive(:price_public).and_return(555.555) pacobj.should_receive(:company_name).and_return("company_name") pacobj.should_receive(:ikscat).and_return(666) pacobj.should_receive(:sl_entry).and_return(777) pacobj.should_receive(:registration_date).and_return(Date.new(2010,12,31)) end expect = ["basename", "basename dose/111", "222", "333", "name", "dose", "111", "444.44", "555.55", "company_name", "666", "SL", "31.12.2010"] assert_equal(expect, @generics_xls.format_original(pac)) end
Result
masa@masa ~/ywesee/oddb.org/ext/export $ ruby test/test_generics_xls.rb Loaded suite test/test_generics_xls Started ...... Finished in 0.013855 seconds. 6 tests, 7 assertions, 0 failures, 0 errors
def test_format_generic pac = flexstub(Package) do |pacobj| pacobj.should_receive(:basename).and_return("basename") pacobj.should_receive(:dose).and_return("dose") pacobj.should_receive(:comparable_size).and_return(111) pacobj.should_receive(:barcode).and_return(222) pacobj.should_receive(:pharmacode).and_return(333) pacobj.should_receive(:name).and_return("name") pacobj.should_receive(:price_exfactory).and_return(444.444) pacobj.should_receive(:price_public).and_return(555.555) pacobj.should_receive(:company_name).and_return("company_name") pacobj.should_receive(:ikscat).and_return(666) pacobj.should_receive(:sl_entry).and_return(nil) pacobj.should_receive(:registration_date).and_return(Date.new(2010,12,31)) end expect = ["222", "333", "name", "dose", "111", "444.44", "555.55", "company_name", "666", "", "31.12.2010"] assert_equal(expect, @generics_xls.format_generic(pac))
Result
masa@masa ~/ywesee/oddb.org/ext/export $ ruby test/test_generics_xls.rb Loaded suite test/test_generics_xls Started ....... Finished in 0.017462 seconds. 7 tests, 8 assertions, 0 failures, 0 errors
def test_format_row pac = flexstub(Package) do |pacobj| pacobj.should_receive(:basename).and_return("basename") pacobj.should_receive(:dose).and_return("dose") pacobj.should_receive(:comparable_size).and_return(111) pacobj.should_receive(:barcode).and_return(222) pacobj.should_receive(:pharmacode).and_return(333) pacobj.should_receive(:name).and_return("name") pacobj.should_receive(:price_exfactory).and_return(444.444) pacobj.should_receive(:price_public).and_return(555.555) pacobj.should_receive(:company_name).and_return("company_name") pacobj.should_receive(:ikscat).and_return(666) pacobj.should_receive(:sl_entry).and_return('SL') pacobj.should_receive(:registration_date).and_return(Date.new(2010,12,31)) pacobj.should_receive(:"registration.pointer").and_return(123) pacobj.should_receive(:pointer).and_return(123) end expect = ["basename", "basename dose/111", "222", "333", "name", "dose", "111", "444.44", "555.55", "company_name", "666", "SL", "31.12.2010", "222", "333", "name", "dose", "111", "444.44", "555.55", "company_name", "666", "SL", "31.12.2010", "Original: neue Registration, Preissenkung Generikum: neue Registration, Preissenkung"] assert_equal(expect, @generics_xls.format_row(pac, pac)) end
Result
masa@masa ~/ywesee/oddb.org/ext/export $ ruby test/test_generics_xls.rb Loaded suite test/test_generics_xls Started ........ Finished in 0.021883 seconds. 8 tests, 9 assertions, 0 failures, 0 errors