view · edit · sidebar · attach · print · history

20130923-brand2csv-vertreter

<< | Index | >>


Summary

  • Sometimes having a Vertreter breaks output of brand2csv.
  • Add a field to brand2csv indicating whether the owner has an agent or nor
  • Migrate from test/unit -> minitest

Commits

Index


Sometimes having a Vertreter breaks output of brand2csv

Looking why we have the problems that the lines after Dragana don't display correctly. Ran bin/brand2csv 01.01.2001-24.01.2016 Dr to look at the problem.

The problem is not at line 345 Dragana, but e.g. at line 545 "Urner Wildheu". Running bin/brand2csv 01.05.2013-30.06.2013 "Urner Wildheu" returned exactly one hit and is therefore an easy result

Refactored the spechelper to run a swissreg trademark search to be able to easily add more tests. Made test fail.

Added a new test-case and made the test pass. Forgot to commit after adding the line 342 inhaber = inhaber.split(', , ')[0] # Catch cases where Inhaber has several postal addresses. Therefore is part of commit Added support for agent

Add a field to brand2csv indicating whether the owner has an agent or nor

Added a new field to structure Marke and filled it correctly. Unit-tests failed, then passed. Commit via Added support for agent

Reviewed the changes after pushing. Committed another fix to remove some debugging output.

Travis-CI comes to my rescue and shows that my changes does not run under Ruby 1.8.7. Fixed that by replacing false/true by "Ja"/"Nein".

Pushed commit Fix errors under Ruby 1.8.7. Use Ja/Nein instead of false/true

Migrate from test/unit -> minitest

Motivation:

Created the following helper script to migrate all my test.

#!/usr/bin/env ruby
# encoding: utf-8
require 'fileutils'
files = Dir.glob('**/test/**/*.rb')
toTreat =  []
files.each{ |f| 
            next if /vendor/.match(f)
          toTreat << f
            }
puts "Converting #{toTreat.size} files to use MiniTest"

def convert_content(f)
    lines = IO.readlines(f)
    ausgabe = File.open(f, 'w+')
    lines.each {
      |line|
              ausgabe.puts line.sub(/require .test\/unit./, "gem 'minitest'\nrequire 'minitest/autorun'").
                  sub(/ Test::Unit::TestCase/, "Minitest::Test").
                  sub(/assert_raise/, 'assert_raises')
            }
end

def iconv_to_utf8(f)
  cmd = "iconv -f ISO8859-14 #{f} > #{f}.utf-8"
  exit 1 unless system(cmd)
  FileUtils.mv("#{f}.utf-8", f, :verbose => true)
end

toTreat.each{ 
  |f|
  begin
    convert_content(f)
rescue
  puts "rescue #{f}"
  $stdout.flush
  cmd = "git checkout #{f}"
  exit 1 unless system(cmd)
  iconv_to_utf8(f)
  convert_content(f)
end
}

See commit After running migration script to minitest Manually added some changes, eg.

 It was removed because it's not useful enough. Test the proper behavior 
of your method, not the fact that it doesn't raise an exception.
  • assert_not_nil => refute_nil
  • Some more if !defined(Test::Unit) -> Minitest
  • assert_not_equal(x,y) > assert(x != y)
  • Fixed some errors by running test_oddbdat.rb separately.

Running locally I don't have any errors now.

grep assertions, suite.log
55 runs, 66 assertions, 3 failures, 0 errors, 0 skips
239 runs, 619 assertions, 17 failures, 0 errors, 0 skips
790 runs, 890 assertions, 43 failures, 0 errors, 15 skips
271 runs, 316 assertions, 38 failures, 0 errors, 5 skips
3 runs, 3 assertions, 0 failures, 0 errors, 0 skips
6 runs, 5 assertions, 0 failures, 0 errors, 1 skips
43 runs, 43 assertions, 10 failures, 0 errors, 0 skips
66 runs, 140 assertions, 0 failures, 0 errors, 2 skips
30 runs, 39 assertions, 0 failures, 0 errors, 10 skips
9 runs, 11 assertions, 0 failures, 0 errors, 0 skips
431 runs, 653 assertions, 4 failures, 0 errors, 21 skips
312 runs, 450 assertions, 0 failures, 0 errors, 8 skips

Pushed commit https://github.com/ngiger/oddb.org/commit/5007d5f2e988561bb79460441c1e3cdd60b26c8a, Manual fixes for using Minitest

Waiting whether travics.ci has the same results. No. But at least I get now a clearer error message, which indicates an UTF-8 and/or LANG error.

/home/travis/build/ngiger/oddb.org/vendor/bundle/ruby/1.9.1/gems/simplecov-0.7.1/lib/simplecov/source_file.rb:171:in `block in process_skipped_lines!': invalid byte sequence in UTF-8 (ArgumentError)
  from /home/travis/build/ngiger/oddb.org/vendor/bundle/ruby/1.9.1/gems/simplecov-0.7.1/lib/simplecov/source_file.rb:170:in `each'
  from /home/travis/build/ngiger/oddb.org/vendor/bundle/ruby/1.9.1/gems/simplecov-0.7.1/lib/simplecov/source_file.rb:170:in `process_skipped_lines!'
  from /home/travis/build/ngiger/oddb.org/vendor/bundle/ruby/1.9.1/gems/simplecov-0.7.1/lib/simplecov/source_file.rb:100:in `lines'
  from /home/travis/build/ngiger/oddb.org/vendor/bundle/ruby/1.9.1/gems/simplecov-0.7.1/lib/simplecov/source_file.rb:141:in `covered_lines'
  from /home/travis/build/ngiger/oddb.org/vendor/bundle/ruby/1.9.1/gems/simplecov-0.7.1/lib/simplecov/file_list.rb:7:in `block in covered_lines'
  from /home/travis/build/ngiger/oddb.org/vendor/bundle/ruby/1.9.1/gems/simplecov-0.7.1/lib/simplecov/file_list.rb:7:in `map'
  from /home/travis/build/ngiger/oddb.org/vendor/bundle/ruby/1.9.1/gems/simplecov-0.7.1/lib/simplecov/file_list.rb:7:in `covered_lines'
  from /home/travis/build/ngiger/oddb.org/vendor/bundle/ruby/1.9.1/gems/simplecov-0.7.1/lib/simplecov/file_list.rb:30:in `lines_of_code'
  from /home/travis/build/ngiger/oddb.org/vendor/bundle/ruby/1.9.1/gems/simplecov-0.7.1/lib/simplecov/file_list.rb:35:in `covered_percent'
  from (erb):8:in `block in format'
  from /home/travis/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/erb.rb:838:in `eval'
  from /home/travis/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/erb.rb:838:in `result'
  from /home/travis/build/ngiger/oddb.org/vendor/bundle/ruby/1.9.1/gems/simplecov-html-0.7.1/lib/simplecov-html.rb:19:in `block in format'
  from /home/travis/build/ngiger/oddb.org/vendor/bundle/ruby/1.9.1/gems/simplecov-html-0.7.1/lib/simplecov-html.rb:18:in `open'
  from /home/travis/build/ngiger/oddb.org/vendor/bundle/ruby/1.9.1/gems/simplecov-html-0.7.1/lib/simplecov-html.rb:18:in `format'
  from /home/travis/build/ngiger/oddb.org/vendor/bundle/ruby/1.9.1/gems/simplecov-0.7.1/lib/simplecov/result.rb:91:in `format!'
  from /home/travis/build/ngiger/oddb.org/vendor/bundle/ruby/1.9.1/gems/simplecov-0.7.1/lib/simplecov/configuration.rb:133:in `block in at_exit'
  from /home/travis/build/ngiger/oddb.org/vendor/bundle/ruby/1.9.1/gems/simplecov-0.7.1/lib/simplecov/defaults.rb:52:in `call'
  from /home/travis/build/ngiger/oddb.org/vendor/bundle/ruby/1.9.1/gems/simplecov-0.7.1/lib/simplecov/defaults.rb:52:in `block in <top (required)>'
view · edit · sidebar · attach · print · history
Page last modified on September 23, 2013, at 04:40 PM