view · edit · sidebar · attach · print · history

20110617-testcases-plugin-companyuser-substance-oddb_org

<< | Index | >>


  1. Testcases swissmedic plugin
  2. Debug export_oddbdat
  3. Testcases oddb.org

Goal/Estimate/Evaluation
  • Testcases (swissmedic plugin) / 100% / 100%
  • oddb.dat debug / 70% / 100%
Milestones
Summary
Commits

Testcases swissmedic plugin

  • src/plugin/swissmedic.rb (coverage: 96.64%)

Commit

Debug export_oddbdat

Email

Error: RuntimeError
Message: not same unit:  != ml
Backtrace:
(druby://localhost:10005)
/var/www/oddb.org/src/util/quanty/main.rb:46:in `adjust'
(druby://localhost:10005) /var/www/oddb.org/src/util/quanty/main.rb:62:in `+'
(druby://localhost:10005) /var/www/oddb.org/src/model/dose.rb:100:in `+'
(druby://localhost:10005)
/var/www/oddb.org/ext/export/src/oddbdat.rb:401:in `structure'
(druby://localhost:10005)
/var/www/oddb.org/src/model/sequence.rb:130:in `inject'
(druby://localhost:10005)
/var/www/oddb.org/ext/export/src/oddbdat.rb:401:in `each'
(druby://localhost:10005)
/var/www/oddb.org/ext/export/src/oddbdat.rb:401:in `inject'
(druby://localhost:10005)
/var/www/oddb.org/ext/export/src/oddbdat.rb:401:in `structure'
(druby://localhost:10005)
/var/www/oddb.org/ext/export/src/oddbdat.rb:269:in `initialize'
(druby://localhost:10005)
/var/www/oddb.org/ext/export/src/oddbdat.rb:292:in `initialize'
(druby://localhost:10005)
/var/www/oddb.org/ext/export/src/oddbdat.rb:53:in `new'
(druby://localhost:10005)
/var/www/oddb.org/ext/export/src/oddbdat.rb:53:in `lines'
(druby://localhost:10005)
/var/www/oddb.org/ext/export/src/odba_exporter.rb:175:in
`export_oddbdat'
(druby://localhost:10005)
/var/www/oddb.org/ext/export/src/odba_exporter.rb:174:in `each'
(druby://localhost:10005)
/var/www/oddb.org/ext/export/src/odba_exporter.rb:174:in
`export_oddbdat'
(druby://localhost:10005)
/var/www/oddb.org/ext/export/src/odba_exporter.rb:172:in `each'
(druby://localhost:10005)
/var/www/oddb.org/ext/export/src/odba_exporter.rb:172:in
`export_oddbdat'
/var/www/oddb.org/src/plugin/oddbdat_export.rb:58:in `export'
/var/www/oddb.org/src/util/exporter.rb:154:in `export_oddbdat'
/var/www/oddb.org/src/util/exporter.rb:307:in `call'
/var/www/oddb.org/src/util/exporter.rb:307:in `safe_export'
/var/www/oddb.org/src/util/exporter.rb:152:in `export_oddbdat'
/var/www/oddb.org/src/util/exporter.rb:52:in `run'
/var/www/oddb.org/jobs/export_daily:13
/var/www/oddb.org/src/util/job.rb:17:in `call'
/var/www/oddb.org/src/util/job.rb:17:in `run'
/var/www/oddb.org/jobs/export_daily:12
  • Confirm error

Run

  • bin/oddbd
  • yusd
  • currencyd
  • ext/export/bin/exportd
  • export_oddbdat (bin/admin)
masa@masa ~/ywesee/oddb.org $ bin/admin
ch.oddb> Exporter.new(self).export_oddbdat

Result

Error: RuntimeError
Message: not same unit:  != ml
Backtrace:
(druby://localhost:10005) /home/masa/ywesee/oddb.org/src/util/quanty/main.rb:46:in `adjust'
(druby://localhost:10005) /home/masa/ywesee/oddb.org/src/util/quanty/main.rb:62:in `+'
(druby://localhost:10005) /home/masa/ywesee/oddb.org/src/model/dose.rb:100:in `+'
(druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/oddbdat.rb:401:in `structure'
(druby://localhost:10005) /home/masa/ywesee/oddb.org/src/model/sequence.rb:130:in `inject'
(druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/oddbdat.rb:401:in `each'
(druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/oddbdat.rb:401:in `inject'
(druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/oddbdat.rb:401:in `structure'
(druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/oddbdat.rb:269:in `initialize'
(druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/oddbdat.rb:292:in `initialize'
(druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/oddbdat.rb:53:in `new'
(druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/oddbdat.rb:53:in `lines'
(druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/odba_exporter.rb:175:in `export_oddbdat'
(druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/odba_exporter.rb:174:in `each'
(druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/odba_exporter.rb:174:in `export_oddbdat'
(druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/odba_exporter.rb:172:in `each'
(druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/odba_exporter.rb:172:in `export_oddbdat'
/home/masa/ywesee/oddb.org/src/plugin/oddbdat_export.rb:58:in `export'
/home/masa/ywesee/oddb.org/src/util/exporter.rb:154:in `export_oddbdat'
/home/masa/ywesee/oddb.org/src/util/exporter.rb:307:in `call'
/home/masa/ywesee/oddb.org/src/util/exporter.rb:307:in `safe_export'
/home/masa/ywesee/oddb.org/src/util/exporter.rb:152:in `export_oddbdat'
(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:1426:in `_admin'
/home/masa/ywesee/oddb.org/src/util/oddbapp.rb:1424:in `initialize'
/home/masa/ywesee/oddb.org/src/util/oddbapp.rb:1424:in `new'
/home/masa/ywesee/oddb.org/src/util/oddbapp.rb:1424:in `_admin'
/usr/lib64/ruby/1.8/drb/drb.rb:1555:in `__send__'
/usr/lib64/ruby/1.8/drb/drb.rb:1555:in `perform_without_block'
/usr/lib64/ruby/1.8/drb/drb.rb:1515:in `perform'
/usr/lib64/ruby/1.8/drb/drb.rb:1589:in `main_loop'
/usr/lib64/ruby/1.8/drb/drb.rb:1585:in `loop'
/usr/lib64/ruby/1.8/drb/drb.rb:1585:in `main_loop'
/usr/lib64/ruby/1.8/drb/drb.rb:1581:in `start'
/usr/lib64/ruby/1.8/drb/drb.rb:1581:in `main_loop'
/usr/lib64/ruby/1.8/drb/drb.rb:1430:in `run'
/usr/lib64/ruby/1.8/drb/drb.rb:1427:in `start'
/usr/lib64/ruby/1.8/drb/drb.rb:1427:in `run'
/usr/lib64/ruby/1.8/drb/drb.rb:1347:in `initialize'
/usr/lib64/ruby/1.8/drb/drb.rb:1627:in `new'
/usr/lib64/ruby/1.8/drb/drb.rb:1627:in `start_service'
bin/oddbd:38

Note

  • It is the same error

Experiment (ext/export/src/odba_exporter.rb#export_oddbdat)

    def OdbaExporter.export_oddbdat(odba_ids, dir, klasses)
      FileUtils.mkdir_p(dir)
      files = klasses.collect { |klass|
        table = klass.new
        file = Tempfile.new(table.filename, dir)
        [file, table]
      }
      if(odba_ids.nil?)
        files.each { |file, table|
          file.puts table.lines
        }
      else
        odba_ids.each { |odba_id|
          item = ODBA.cache.fetch(odba_id, nil)
          files.each { |file, table|
open("/home/masa/work/log.dat","a"){|f|
  f.print "table.class = ", table.class, "\n"
  f.print "item.pharmacode = ", item.pharmacode, "\n"
  f.print "item.parts.collect { |part| part.measure }.compact.join(',') = ", item.parts.collect { |part| part.measure }.compact.join(","), "\n"
}
            file.puts table.lines(item)
          }
          #ODBA.cache.clear
        }
      end

Result

....
item.pharmacode = nil
item.parts.collect { |part| part.measure }.compact.join(',') = 1
table.class = ODDB::OdbaExporter::LimitationTable
item.pharmacode = nil
item.parts.collect { |part| part.measure }.compact.join(',') = 1
table.class = ODDB::OdbaExporter::LimTxtTable
item.pharmacode = nil
item.parts.collect { |part| part.measure }.compact.join(',') = 1
table.class = ODDB::OdbaExporter::EanTable
item.pharmacode = nil
item.parts.collect { |part| part.measure }.compact.join(',') = 1
table.class = ODDB::OdbaExporter::AcTable
item.pharmacode = 2237077
item.parts.collect { |part| part.measure }.compact.join(',') = 1 ,3 ml
table.class = ODDB::OdbaExporter::AccompTable
item.pharmacode = 2237077
item.parts.collect { |part| part.measure }.compact.join(',') = 1 ,3 ml
table.class = ODDB::OdbaExporter::AcLimTable
item.pharmacode = 2237077
item.parts.collect { |part| part.measure }.compact.join(',') = 1 ,3 ml
table.class = ODDB::OdbaExporter::AcmedTable
item.pharmacode = 2237077
item.parts.collect { |part| part.measure }.compact.join(',') = 1 ,3 ml
table.class = ODDB::OdbaExporter::AcnamTable
item.pharmacode = 2237077
item.parts.collect { |part| part.measure }.compact.join(',') = 1 ,3 ml

Note

  • The different 'unit' is the cause of the error
  • But how did it become different?

Experiment (delete one of parts)

ch.oddb> ODDB::Package.find_by_pharmacode('2237077').iksnr
-> 54915
ch.oddb> delete(ODDB::Package.find_by_pharmacode('2237077').parts[1].pointer)
-> #<ODDB::Part:0x7f97dd1aba68>

Run

  • reboot bin/oddbd
  • export_oddbdat
masa@masa ~/ywesee/oddb.org $  bin/admin
ch.oddb> Exporter.new(self).export_oddbdat

Result

masa@masa ~/ywesee/oddb.org $ ls data/downloads/
oddbdat.tar.gz  oddbdat.zip  README  s01x  s02x  s03x  s06x  s07x  s09x  s10x  s11x  s12x  s16x  s19x  s40x  s41x  s99x

Note

  • Looks good

Online server

ywesee@server /var/www/oddb.org $ bin/admin
ch.oddb> ODDB::Package.find_by_pharmacode('2237077')
-> 

Note

  • There is no package

Anyway, try to execute it

ywesee@server /var/www/oddb.org $ bin/admin
ch.oddb> Exporter.new(self).export_oddbdat
-> 

Result

ywesee@server /var/www/oddb.org $ ls data/downloads/ -al
-rw-r--r--  1 apache apache   2160825 2011-06-17 14:21 oddbdat.tar.gz
-rw-r--r--  1 apache apache   2146220 2011-06-17 14:21 oddbdat.zip

Note

  • It looks no problem
  • I guess the update_swissmedic fixed the wrong data of online server

Testcases oddb.org

  1. src/state/admin/entity.rb (coverage: 83.90%) suspend
    • It is covered 100% if the testcases run without require'state/global'
  2. src/util/soundex.rb (coverage: 78.85%) (this is a third party library)
  3. src/state/substances/substance.rb (coverage: 100%)
  4. src/view/user/plugin.rb (coverage: 100%)
  5. src/state/admin/companyuser.rb (coverage: 100%)
  6. src/view/admin/orphaned_fachinfo_assign.rb (coverage: 81.44%)
  7. src/util/language.rb (coverage: 93.75%)
  8. src/state/admin/assign_fachinfo.rb (coverage: 26.32%)
  9. src/view/navigationfoot.rb (coverage: 75.79%)

Commmit

view · edit · sidebar · attach · print · history
Page last modified on June 17, 2011, at 04:57 PM