Skip to content

Commit

Permalink
Fix warnings and errors in unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ngiger committed Apr 18, 2017
1 parent d51b316 commit c3d5506
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 23 deletions.
1 change: 0 additions & 1 deletion src/model/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ def sequence_data(*names)
:shortage_state => "String",
:shortage_last_update => "Date",
:shortage_delivery_date => "String", # can be offen
:shortage_link => "String",
:nomarketing_date => "Date",
:nomarketing_since => "Date",
:nodelivery_since => "Date",
Expand Down
28 changes: 14 additions & 14 deletions test/test_model/registration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ def test_active
assert_equal(true, @registration.active?)
@registration.inactive_date = (Date.today >> 1)
assert_equal(true, @registration.active?)
@registration.inactive_date = Date.today
@registration.inactive_date = Date.today
assert_equal(false, @registration.active?)
end
def test_active__renewal
assert_equal(true, @registration.active?)
@registration.expiration_date = @@two_years_ago - 1
@registration.expiration_date = @@two_years_ago - 1
assert_nil(@registration.active?)
@registration.renewal_flag = true
assert_equal(true, @registration.active?)
Expand Down Expand Up @@ -219,17 +219,17 @@ def test_checkout
"02" => seq2,
}
@registration.instance_variable_set('@sequences', sequences)
seq1.should_receive(:checkout).and_return {
assert(true)
seq1.should_receive(:checkout).and_return {
assert(true)
}
seq1.should_receive(:odba_delete).and_return {
assert(true)
seq1.should_receive(:odba_delete).and_return {
assert(true)
}
seq2.should_receive(:checkout).and_return {
assert(true)
seq2.should_receive(:checkout).and_return {
assert(true)
}
seq2.should_receive(:odba_delete).and_return {
assert(true)
seq2.should_receive(:odba_delete).and_return {
assert(true)
}
@registration.checkout
end
Expand Down Expand Up @@ -317,8 +317,8 @@ def test_fachinfo_writer
end
def test_generic_type
company = flexmock "company"
@registration.company = company
company.should_receive(:generic_type).and_return { "complementary" }
@registration.company = company
company.should_receive(:generic_type).and_return { "complementary" }
assert_equal("complementary", @registration.generic_type)
@registration.generic_type = "generic"
assert_equal("generic", @registration.generic_type)
Expand Down Expand Up @@ -356,7 +356,7 @@ def test_localized_name
assert_equal 'Localized Name', @registration.localized_name(:de)
end
def test_may_violate_patent
assert_equal nil, @registration.may_violate_patent?
assert_nil(@registration.may_violate_patent?)
@registration.registration_date = @@today
assert_equal true, @registration.may_violate_patent?
@registration.registration_date = @@one_year_ago
Expand Down Expand Up @@ -423,7 +423,7 @@ def test_packages
assert_equal %w{pac1 pac2 pac3}, @registration.packages
end
def test_patent_protected
assert_equal nil, @registration.patent_protected?
assert_nil(@registration.patent_protected?)
pat1 = flexmock :protected? => false
@registration.instance_variable_set '@patent', pat1
assert_equal false, @registration.patent_protected?
Expand Down
3 changes: 2 additions & 1 deletion test/test_state/global.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1211,7 +1211,8 @@ def test_snapback_event
assert_equal('snapback_event', state.snapback_event)
end
def test_snapback_event__direct_event
assert_equal(@state.instance_eval('DIRECT_EVENT'), @state.snapback_event)
assert_nil(@state.snapback_event)
assert_nil(@state.instance_eval('DIRECT_EVENT'))
end
def test_sort
@state.instance_eval('@model = []')
Expand Down
8 changes: 4 additions & 4 deletions test/test_util/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def test_search_hospital_valid_ean
def test_search_pharmacy
@app.should_receive(:search_pharmacies).once.and_return( ['search_pharmacies'])
@app.should_receive(:pharmacy_by_gln).with('key').once.and_return(nil)
assert_equal(nil , @session.search_pharmacy('key'))
assert_nil(@session.search_pharmacy('key'))
assert_equal(['search_pharmacies'], @session.search_pharmacies('key'))
end
def test_search_companies
Expand Down Expand Up @@ -286,7 +286,7 @@ def test_choosen_drugs_for_interactions_with_atc_and_iksnr
@session = ODDB::Session.new('key', @app, @validator)
@session.instance_eval("@request_path = '/de/gcc/home_interactions/58392,7680591310011,L02BA01,58643'")
expected = {"58392"=>"package",
"7680591310011"=>"package",
"7680591310011"=>"package",
"L02BA01"=>"package",
"58643"=>"package",}
assert_equal(expected, @session.choosen_drugs)
Expand All @@ -297,7 +297,7 @@ def test_choosen_drugs_for_interactions_plus_persistent
drugs = {'7680591310012' => 'package_drugs'}
@session.set_persistent_user_input(:drugs, drugs)
expected = {"58392"=>"package",
"7680591310011"=>"package",
"7680591310011"=>"package",
"L02BA01"=>"package",
"58643"=>"package",
"7680591310012"=>"package_drugs",}
Expand Down Expand Up @@ -364,7 +364,7 @@ def test_create_search_url_with_choosen_drugs
}
@session = ODDB::Session.new('key', @app, @validator)
@session.set_persistent_user_input(:zsr_id, 'P123456')
@session.set_persistent_user_input(:drugs, drugs)
@session.set_persistent_user_input(:drugs, drugs)
res = @session.instance_eval(cmd)
assert_equal(url,res)
}
Expand Down
6 changes: 3 additions & 3 deletions test/test_view/admin/fachinfoconfirm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def test_compose_footer1
'<INPUT value="lookup" type="button" name="back" onClick="document.location.href=&#39;back&#39;;">',
'<INPUT value="lookup" type="submit" name="update">',
]
expected.each { |line|
expected.each { |line|
assert(html.index(line), "missing: #{line}\nin:\n#{html}")
}
end
Expand All @@ -83,9 +83,9 @@ def test_compose_footer2
'<FORM NAME="stdform" METHOD="POST" ACCEPT-CHARSET="UTF-8" ENCTYPE="application/x-www-form-urlencoded"><TABLE cellspacing="0" class="composite"><TR><TD colspan="4">',
'<INPUT value="lookup" type="button" name="back" onClick="document.location.href=&#39;back&#39;;">',
]
expected.each { |line|
expected.each { |line|
assert(html.index(line), "missing: #{line}\nin:\n#{html}")
}
}
line = '<INPUT name="update" type="submit" value="lookup">'
assert_nil(html.index(line), "found: #{line}\nin:\n#{html}\n...but it should not be there!")
end
Expand Down
4 changes: 4 additions & 0 deletions test/test_view/drugs/javascript.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
else
puts "Running javascript tests"
class TestJavaScript <Minitest::Test
def setup
has_node_js = `which nodejs`
skip('No nodejs found. Therefore skipping javascript tests')
end
def test_simple_logging
assert_equal("testing\n", `nodejs -e "console.log('testing');"`);
end
Expand Down
1 change: 1 addition & 0 deletions test/test_view/suite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

run_isolated = ['searchbar.rb',
'navigationfoot.rb',
'admin/fachinfoconfirm.rb',
'drugs/fachinfo.rb',
'drugs/fachinfo_change_logs.rb',
'drugs/javascript.rb',
Expand Down

0 comments on commit c3d5506

Please sign in to comment.