view · edit · sidebar · attach · print · history

20110203-testcases-export_oddbdat-oddb_org

<< | Index | >>


  1. Run export_oddbdat online
  2. Check export_fachinfo_pdf locally
  3. Check the current test-cases
  4. Update test-case for package.rb
  5. Update test-case for oddbdat.rb

Goal
  • Update test-cases export_oddbdat / 100%
Milestones
  1. Run export_oddbdat online 10:00
  2. Check the current test-cases 9:00
  3. test/test_model/package.rb 10:30
Summary
Commits
ToDo Tomorrow
Keep in Mind
  1. Next Task Also probably Dose error ch.ODDB.org Report - Error: Generikaliste - 02/2011 ch.ODDB.org Report - Error: oddb.csv - 02/2011
  2. Add my email address to SL-Update recipients
  3. Debug bsv_followers autorun
  4. oddb.org test-case 100%
  5. Some concerns about FI news job
  6. Check rdbi instead of dbi for ODBA
  7. Encoding woes (from Davatz-san)
  8. Feedback: This option indicates that the regular expression is parsed as 'UTF8' (from Davatz-san)
  9. pg on Ubuntu - see http://dev.ywesee.com/wiki.php/Gem/Pg (from Davatz-san)
  10. On Ice
  11. emerge --sync

Run export_oddbdat online

Error when 'git pull' online server

oddb.org $ git pull
remote: Counting objects: 25, done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 13 (delta 11), reused 0 (delta 0)
Unpacking objects: 100% (13/13), done.
From /home/ywesee/git/oddb.org
   fc33b55..1353688  master     -> origin
Updating fc33b55..1353688
error: Your local changes to the following files would be overwritten by merge:
        src/util/exporter.rb
Please, commit your changes or stash them before you can merge.
Aborting

Note

diff --git a/src/util/exporter.rb b/src/util/exporter.rb
index 23571e2..1935ce2 100644
--- a/src/util/exporter.rb
+++ b/src/util/exporter.rb
@@ -53,9 +53,11 @@ module ODDB
       export_doc_csv
       export_index_therapeuticus_csv
       export_price_history_csv
+=begin # inoperable atm.
       run_on_monthday(1) {
         export_fachinfo_pdf
       }
+=end
       nil
     end
     def export_helper(name)

Note

  • This is different from the source code in the git repository
  • 'export_fachinfo_pdf' method is commented out

Commit

Restart

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

Run

  • Exporter.new(self).export_oddbdat

~ $ screen -S masa
~ $ cd /var/www/oddb.org/
/var/www/oddb.org $ bin/admin
ch.oddb> Exporter.new(self).export_oddbdat
(Ctl+a, Ctl+d) (detach)
~ $ screen -ls
There are screens on:
        11252.pts-2.thinpower   (Detached)
        28306.pts-2.thinpower   (Detached)
        31058.masa      (Detached)
3 Sockets in /var/run/screen/S-ywesee.

Note

  • I can attach the same screen by the following command
 screen -x masa

or

 screen -r masa

Note

  • It will probably take about 20 minutes
  • It is done
/var/www/oddb.org $ ls -al data/downloads/
 2011-02-03 10:02 oddbdat.tar.gz
 2011-02-03 10:02 oddbdat.zip

Check export_fachinfo_pdf locally

Memo

  • 'export_fachinfo_pdf' does not have to run at the moment.

Reference

Run

  • oddb.org/bin/oddbd
  • currency/bin/currencyd
  • oddb.org/ext/export/bin/exportd
  • oddb.org/ext/fipdf/bin/fipdfd

Run export_fachinfo_pdf

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

Result

Error: Errno::ENOENT
Message: No such file or directory - fachinfos_de.pdf
Backtrace:
(druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/odba_exporter.rb:39:in `initialize'
(druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/odba_exporter.rb:39:in `open'
(druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/odba_exporter.rb:39:in `compress'
/home/masa/ywesee/oddb.org/src/util/exporter.rb:109:in `export_fachinfo_pdf'
/home/masa/ywesee/oddb.org/src/util/exporter.rb:304:in `call'
/home/masa/ywesee/oddb.org/src/util/exporter.rb:304:in `safe_export'
/home/masa/ywesee/oddb.org/src/util/exporter.rb:106:in `export_fachinfo_pdf'
/home/masa/ywesee/oddb.org/src/util/exporter.rb:104:in `each'
/home/masa/ywesee/oddb.org/src/util/exporter.rb:104:in `export_fachinfo_pdf'
(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

  • Certainly 'export_fachinfo_pdf' does not work

Check the current test-cases

Check changed parts

File list

  1. ext/export/src/oddbdat.rb No test-cases
  2. src/model/package.rb Error
  3. src/plugin/oddbdat_export.rb All the tests are commented out
  4. src/util/exporter.rb No test-cases

for /src/model/package.rb

masa@masa ~/work/oddb.org $ ruby test/test_model/package.rb 
/usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- util/quanty (LoadError)
        from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
        from /home/masa/work/oddb.org/src/model/dose.rb:4
        from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
        from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
        from /home/masa/work/oddb.org/src/model/part.rb:4
        from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
        from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
        from /home/masa/work/oddb.org/src/model/package.rb:10
        from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
        from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
        from test/test_model/package.rb:6

for src/plugin/oddbdat_export.rb

masa@masa ~/work/oddb.org/test/test_plugin $ ruby oddbdat_export.rb 
Loaded suite oddbdat_export
Started

Finished in 0.0001 seconds.

0 tests, 0 assertions, 0 failures, 0 errors

Note

  • All the tests are commented out

Update test-case for package.rb

masa@masa ~/work $ git clone git://scm.ywesee.com/oddb.org
Initialized empty Git repository in /home/masa/work/oddb.org/.git/
remote: Counting objects: 27515, done.
remote: Compressing objects: 100% (9158/9158), done.
remote: Total 27515 (delta 21538), reused 22975 (delta 18081)
Receiving objects: 100% (27515/27515), 16.37 MiB | 3.39 MiB/s, done.
Resolving deltas: 100% (21538/21538), done.
masa@masa ~/work $ cd oddb.org
masa@masa ~/work/oddb.org $ ruby test/test_model/package.rb 
/usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- util/quanty (LoadError)
        from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
        from /home/masa/work/oddb.org/src/model/dose.rb:4
        from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
        from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
        from /home/masa/work/oddb.org/src/model/part.rb:4
        from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
        from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
        from /home/masa/work/oddb.org/src/model/package.rb:10
        from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
        from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
        from test/test_model/package.rb:6

But

masa@masa ~/work $ sh setup.oddb.org.sh
masa@masa ~/work $ cd oddb.org
masa@masa ~/work/oddb.org $ ruby test/test_model/package.rb 
Loaded suite test/test_model/package
Started
....................................................
Finished in 0.02224 seconds.

52 tests, 128 assertions, 0 failures, 0 errors

Note

Add a new test-case

Experiment

test/test_model/package.rb

    def test_comparable_size__empty
      assert_equal 'masa', @package.comparable_size
    end

Result (confirm the failure)

masa@masa ~/ywesee/oddb.org $ ruby test/test_model/package.rb 
Loaded suite test/test_model/package
Started
..........F..........................................
Finished in 0.022925 seconds.

  1) Failure:
test_comparable_size__empty(ODDB::TestPackage) [test/test_model/package.rb:171]:
<"masa"> expected but was
<Quanty(0,'')>.

53 tests, 129 assertions, 1 failures, 0 errors

Experiment (make it pass)

test/test_model/package.rb

    def test_comparable_size__empty
      assert_equal [], @package.parts
      assert_equal Dose.new(0, ''), @package.comparable_size
    end

Result

masa@masa ~/ywesee/oddb.org $ ruby test/test_model/package.rb 
Loaded suite test/test_model/package
Started
.....................................................
Finished in 0.02257 seconds.

53 tests, 130 assertions, 0 failures, 0 errors

Note

  • Good

Next

  1. src/model/package.rb Error Done
  2. ext/export/src/oddbdat.rb No test-cases
  3. src/plugin/oddbdat_export.rb All the tests are commented out
  4. src/util/exporter.rb No test-cases

Update test-case for oddbdat.rb

ext/export/test/test_oddbdat.rb (the first skelton)

#!/usr/bin/env ruby
# ODDB::OdbaExporter::TestTable, TestLine -- oddb -- 03.02.2011 -- 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 'oddbdat'

module ODDB
  module OdbaExporter
    class TestTable < Test::Unit::TestCase
      Table::FILENAME = 'table'
      def test_filename
        table = Table.new
        assert_equal('table', table.filename)
      end
    end
    class TestLine < Test::Unit::TestCase
      def test_content
        line = Line.new
        assert([], line.content(nil))
      end
    end
  end
end

Result

masa@masa ~/ywesee/oddb.org/ext/export/test $ ruby test_oddbdat.rb 
Loaded suite test_oddbdat
Started
..
Finished in 0.000563 seconds.

2 tests, 2 assertions, 0 failures, 0 errors

Next

  • Add test-cases

ext/export/test/test_oddbdat.rb (About Table and Line classes)

#!/usr/bin/env ruby
# ODDB::OdbaExporter::TestTable, TestLine -- oddb -- 03.02.2011 -- 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 'oddbdat'

module ODDB
  module OdbaExporter
    class TestTable < Test::Unit::TestCase
      Table::FILENAME = 'table'
      def test_filename
        table = Table.new
        assert_equal('table', table.filename)
      end
    end
    class TestLine < Test::Unit::TestCase
      Line::LENGTH = 3
      def setup
        @line = Line.new
      end
      def test_content
        assert_equal([], @line.content(nil))
        structure = {1=>"1", 2=>"2", 3=>"3"}
        assert_equal(["1", "2", "3"], @line.content(structure))
      end
      def test_empty?
        assert_equal(true, @line.empty?)
      end
      def test_structure
        assert_equal(nil, @line.structure)
      end
      def test_to_s
        assert_equal('', @line.to_s)
      end
    end
  end
end

Result

masa@masa ~/ywesee/oddb.org/ext/export/test $ ruby test_oddbdat.rb 
Loaded suite test_oddbdat
Started
.....
Finished in 0.001622 seconds.

5 tests, 6 assertions, 0 failures, 0 errors

Next

  • Test-cases for the other subclasses inherit Talbe and Line class

Memo

  • *Line classes are used in *Table classes
  • So *Line classes should be tested first

AcLine test

    class TestAcLine < Test::Unit::TestCase
      include FlexMock::TestCase
      def setup
        @package = ODDB::Package.new('12')
        @package.sequence = StubPackageSequence.new
        @registration = flexmock('registration') do |mock|
          mock.should_receive(:generic_type).and_return(:generic)
          mock.should_receive(:registration_date).and_return(Date.new(2011,2,3))
        end
        @package.sequence.registration = @registration
        @package.create_sl_entry
        @package.sl_entry.limitation = 'limitation'
        @package.sl_entry.limitation_points = 5
        @acline = AcLine.new(@package)
      end
      def test_generic_code
        assert_equal('Y', @acline.generic_code(@registration))
      end
      def test_iks_date
        assert_equal('20110203', @acline.iks_date(@registration))
      end
      def test_ikskey
        assert_equal('12345012', @acline.ikskey)
      end
      def test_inscode
        assert_equal('1', @acline.inscode)
      end
      def test_limitation
        assert_equal('Y', @acline.limitation)
      end
      def test_limitation_points
        assert_equal(5, @acline.limitation_points)
      end
      def test_structure
        expected = {
          1 =>"01",
          2 =>"20110203000000",
          3 =>"1",
          4 =>@package.oid,
          5 =>"4",
          7 =>"12345012",
          14=>nil,
          20=>"Y",
          22=>"20110203",
          29=>"3",
          32=>nil,
          39=>"1",
          40=>"Y",
          41=>5,
          47=>nil,
        }

        # test
        assert_equal(expected.sort, @acline.structure.sort)
      end
    end

Result

masa@masa ~/ywesee/oddb.org/ext/export/test $ ruby test_oddbdat.rb 
Loaded suite test_oddbdat
Started
............
Finished in 0.006488 seconds.

12 tests, 13 assertions, 0 failures, 0 errors

Note

  • Good

Next

  • AccompLine test

Attach:test_oddbdat.rb.txt

Result

masa@masa ~/ywesee/oddb.org/ext/export/test $ ruby test_oddbdat.rb 
Loaded suite test_oddbdat
Started
.........................
Finished in 0.014636 seconds.

25 tests, 27 assertions, 0 failures, 0 errors

Test coverage (ext/export/src/oddbdat.rb)

 masa@masa ~/ywesee/oddb.org/ext/export/test $ rcov test_oddbdat.rb 
 ...
 ext/export/src/oddbdat.rb 	54.75%

Total coverage (oddb.org)

 masa@masa ~/ywesee/oddb.org $ rcov test/suite.rb
 ...
 TOTAL 	63.83%
view · edit · sidebar · attach · print · history
Page last modified on February 03, 2011, at 04:55 PM