view · edit · sidebar · attach · print · history

20101213-update-export_fachinfo_yaml

<< Masa.20101214-update-bbmb-ch | 2010 | Masa.20101210-report-export-fachinfo_yaml >>


  1. Update export_fachinfos
  2. Test case export_fachinfos

Goal
  • Update export_fachinfos / 100%
Milestones
  1. Update export_fachinfo company, product name should be reported in a mail 11:05
  2. Test case for export_fachinfos
  3. (Spreadsheet announcement japanese english)
Summary
Commits
ToDo Tomorrow
Keep in Mind
  1. All test cases YamlExporter test cases oddb.org 20101213
  2. On Ice
  3. emerge --sync

Update export_fachinfos

Confirm the current process

Run

  • oddb.org/bin/oddbd
  • oddb.org/ext/export/bin/exportd

Run export_fachinfos by using bin/admin

masa@masa ~/ywesee/oddb.org $ bin/admin
ch.oddb> YamlExporter.new(self).export_fachinfos

Result

  • There is no warning report
  • Data was corrected

Restore the old data on the cache

masa@masa ~/ywesee/oddb.org $ sudo -u postgres dropdb oddb.org
masa@masa ~/ywesee/oddb.org $ sudo -u postgres createdb -E UTF8 -T template0 oddb.org
masa@masa ~/ywesee/oddb.org.bak.20101210_3_report_process_fachinfo_yaml/data/sql $ zcat oddb.org.20101209.sql.gz |psql -U postgres oddb.org

Run YamlExporter#export_fachinfos again

Result

  • Warning report comes
Message:
YamlExporter#export_fachinfs method is still running,
but I found some missing Fachinfo document data.
This may cause an error in export ebooks process of ebps.

There is no 'fr' description of Fachinformation of the following
Swissmedic Registration Number:
56811, 58417, 53183, 00610, 00528

Next

  • How to get product name from the registration number
  • How to get company name from the registration number

Experiment

src/plugin/yaml.rb

        def export_fachinfos(name='fachinfo.yaml')
          # Check missing data of fachinfo data
          no_descr = {'de' => [], 'fr' => []}
          @app.fachinfos.values.each do |fachinfo|
            no_descr.keys.each do |language|
              unless fachinfo.descriptions[language]
                swissmedic_registration_numbers = ODBA.cache.fetch(fachinfo.odba_id, nil).iksnrs
                no_descr[language].push(
                  [fachinfo.company_name, fachinfo.name_base].concat(swissmedic_registration_numbers)
                )
              end
            end
          end

          # Send a warning report of fachinfo description
          if no_descr.values.flatten.length > 0
            log = Log.new(@@today)
            message = []
            no_descr.keys.each do |language|
              unless no_descr[language].empty?
                i = 0
                message.concat([
                  "There is no '#{language}' description of Fachinformation of the following",
                  "Swissmedic Registration (Company, Product, Numbers):",
                  no_descr[language].map{|fachlist| " " + (i+=1).to_s + ". " + fachlist.join(", ") + "\n"}.to_s
                ])
              end
            end
            log.report = [
              "Message: ",
              "YamlExporter#export_fachinfs method is still running,",
              "but I found some missing Fachinfo document data.",
              "This may cause an error in export ebooks process of ebps.",
              "",
            ].concat(message).join("\n")
            log.notify(" Warning Export: #{name}")
          end

          # Go to actual exporting process
          export_array(name, @app.fachinfos.values)
        end

Reboot oddbd, exportd

Run YamlExporter#export_fachinfs

Result

Message:
YamlExporter#export_fachinfs method is still running,
but I found some missing Fachinfo document data.
This may cause an error in export ebooks process of ebps.

There is no 'fr' description of Fachinformation of the following
Swissmedic Registration (Company, Product, Numbers):
 1. Sandoz Pharmaceuticals AG, Amicosol 1,2 g (1000/200), 56811
 2. Axapharm AG, Muco-X 200, 58417
 3. Tentan AG, Imucal, 53183
 4. Sanofi Pasteur MSD AG, Gen H-B-Vax 5, 00610, 00528

Commit

Test case export_fachinfos

Check current test

masa@masa ~/ywesee/oddb.org $ vim src/plugin/yaml.rb 
masa@masa ~/ywesee/oddb.org $ 

Note

  • All the tests are commented out
  • Why?

Experiment (remove comments)

Run test

masa@masa ~/ywesee/oddb.org $ ruby test/test_plugin/yaml.rb 
test/test_plugin/yaml.rb:144: uninitialized constant ODDB::Package (NameError)

Note

  • I have to check tests one by one

Check git history

Consideration

  • I guess it is so tough to update all the test cases since there are so many updates since 2005
    • There may be not so many regarding yaml.rb, though
  • I should make a test case for export_fachinfo first
  • Then I should think what to do next

Test case for YamlExporter#export_fachinfos

Note

  • Most of the functions in yaml.rb are delegated to EXPORT_SERVER.export_yaml through export_array method

Template test/test_plugin/yaml.rb

#!/usr/bin/env ruby
# TestYamlPlugin -- oddb -- 02.09.2003 -- rwaltert@ywesee.com

$: << File.expand_path('..', File.dirname(__FILE__))
$: << File.expand_path("../../src", File.dirname(__FILE__))
require 'test/unit'
require 'plugin/yaml'
require 'flexmock'

module ODDB
  class YamlExporter < Plugin
    remove_const :EXPORT_DIR
    EXPORT_DIR = File.expand_path('../data/export', File.dirname(__FILE__))
  end
  class TestYamlExporter < Test::Unit::TestCase
    include FlexMock::TestCase
    def test_export_fachinfos
      assert(true)
    end
  end
end

Run

masa@masa ~/ywesee/oddb.org/test/test_plugin $ ruby yaml.rb 
Loaded suite yaml
Started
.
Finished in 0.000193 seconds.

1 tests, 1 assertions, 0 failures, 0 errors

Consideration

  • ODBA.cache.fetch should be mocked
  • How can I check log.notify
  • Check 2 points
    1. case1: there is no description of 'de' or 'fr', then report it
    2. case2: all the data is correct, then report nothing
  • The argument, name, is delegated to export_array

Commit

masa@masa ~/ywesee/oddb.org/test/test_plugin $ ruby yaml.rb Loaded suite yaml Started .. Finished in 0.00281 seconds.

2 tests, 3 assertions, 0 failures, 0 errors Result


view · edit · sidebar · attach · print · history
Page last modified on July 13, 2011, at 12:05 PM