view · edit · sidebar · attach · print · history

20110329-testcases-oddb_org-resolve-leap_year-state-admin-registration_rb

<< | Index | >>


  1. Fix failure and error
  2. Update testcases

Goal/Estimate/Evaluation
  • test-cases coverage oddb.org / 79% / 78.94%.
Milestones
  • Fix testcases regarding leap year problem 10:45
  • Contine to update testcases
    1. src/state/admin/registration.rb (coverage: 100%)
    2. src/state/companies/company.rb (coverage: 72.77%)
    3. src/util/ipn.rb (coverage: 8.15%)
    4. src/state/admin/package.rb (coverage: 14.47%)
Summary
Commits
Todo Tomorrow
  • Add renewal_flag count to oddb.csv report mail

Fix failure and error

Failures and errors happens.

  1) Failure:
test_update_swissmedicjournal(ODDB::TestUpdater) [/home/masa/ywesee/oddb.org/test/test_util/updater.rb:548]:
<Tue, 29 Mar 2011> expected but was
<Mon, 28 Mar 2011>.

  2) Failure:
test_invoice_date_fachinfo(TestCompany) [/home/masa/ywesee/oddb.org/test/test_model/company.rb:133]:
<#<Date: 4911973/2,0,2299161>> expected but was
<#<Date: 4911971/2,0,2299161>>.

  3) Failure:
test_invoice_date_index(TestCompany) [/home/masa/ywesee/oddb.org/test/test_model/company.rb:142]:
<#<Date: 4911973/2,0,2299161>> expected but was
<#<Date: 4911971/2,0,2299161>>.

  4) Failure:
test_invoice_date_lookandfeel(TestCompany) [/home/masa/ywesee/oddb.org/test/test_model/company.rb:151]:
<#<Date: 4911973/2,0,2299161>> expected but was
<#<Date: 4911971/2,0,2299161>>.

  5) Failure:
test_invoice_date_patinfo(TestCompany) [/home/masa/ywesee/oddb.org/test/test_model/company.rb:124]:
<#<Date: 4911973/2,0,2299161>> expected but was
<#<Date: 4911971/2,0,2299161>>.

  6) Failure:
test_recent_items(ODDB::TestPatinfoInvoicer) [/home/masa/ywesee/oddb.org/test/test_plugin/patinfo_invoicer.rb:183]:
<1> expected but was
<2>.

Hypothesis

  • I guess these comes beucase of the relation to the end of February.

Test

require 'date'

date = Date.new(2008,2,29)

def _yearly_repetition(date)
  if(date)
    while(date < Date.today)
      date = date >> 12
    end
    date
  end
end
print 'date.leap? = ', date.leap?, "\n"
print 'date.to_s  = ', date.to_s, "\n"
print '(date >> 12).to_s = ', (date >> 12).to_s, "\n"
print '_yearly_repetition(date).to_s = ', _yearly_repetition(date).to_s, "\n"

Result

date.leap? = true
date.to_s  = 2008-02-29
(date >> 12).to_s = 2009-02-28
_yearly_repetition(date).to_s = 2012-02-28

Test2

date = Date.new(2011,3,29)
date = date << 1
date = date >> 12
p date.to_s

date = Date.new(2011,3,29)
date = date >> 11
p date.to_s

Result

"2012-02-28"
"2012-02-29"

Test3

date = Date.new(2011,3,31)
date = date >> 1
p date.to_s
date = Date.new(2011,3,30)
date = date >> 1
p date.to_s

Result

"2011-04-30"
"2011-04-30"

Note

  • The one year ofter the 29th of Feb. in the leap year is the 28th of Febraury in the next year.
  • We should be careful about '>>' and '<<' operations of Date class
  • In particular, (Date.new(2011,3,29) << 1) >> 12 is NOT Date.new(2011,3,29) >> 11

Commit

Update testcases

Total coverage: 78.94%

Commit

view · edit · sidebar · attach · print · history
Page last modified on March 30, 2011, at 07:30 AM