Skip to content

Commit

Permalink
No more errors in test_state. 48 failures remain
Browse files Browse the repository at this point in the history
  • Loading branch information
ngiger committed Sep 4, 2013
1 parent e92a474 commit 20cdac1
Show file tree
Hide file tree
Showing 20 changed files with 210 additions and 78 deletions.
2 changes: 1 addition & 1 deletion test/test_state/admin/address_suggestion.rb
Expand Up @@ -106,7 +106,7 @@ def test_accept
:user => 'user'
)
flexmock(@model, :pointer => 'pointer')
parent = flexmock('parent', :pointer => 'pointer')
parent = flexmock('parent', :pointer => 'pointer', :addresses => [address])
active_address = flexmock('active_address', :email_suggestion= => nil)
@state.instance_eval do
@parent = parent
Expand Down
9 changes: 6 additions & 3 deletions test/test_state/admin/assign_patinfo.rb
Expand Up @@ -16,13 +16,16 @@ module Admine
class TestAssignPatinfo < Test::Unit::TestCase
include FlexMock::TestCase
def setup
@app = flexmock('app', :update => 'update')
match = flexmock('match', :to_a => [':!registration,12345!sequence,1.'])
pointer = flexmock('pointer', :resolve => true, :match => match)
@sequence = flexmock('sequence', :pointer => pointer)
@registration = flexmock('registration', :sequence => @sequence)
@app = flexmock('app', :update => 'update', :registration => @registration)
@lnf = flexmock('lookandfeel', :lookup => 'lookup')
pointer = flexmock('pointer', :resolve => 'resolve')
@session = flexmock('session',
:app => @app,
:lookandfeel => @lnf,
:user_input => {:pointer => pointer, :pointers => {'key' => pointer}}
:user_input => { "a" => ':!registration,12345!sequence,1.', "b"=> ':!registration,12345!sequence,1.'},
)
@sequence = flexmock('sequence', :pdf_patinfo => 'pdf_patinfo')
@model = flexmock('model', :sequence => @sequence)
Expand Down
3 changes: 2 additions & 1 deletion test/test_state/admin/fachinfoconfirm.rb
Expand Up @@ -263,9 +263,10 @@ def setup
:allowed? => nil,
:lookandfeel => @lnf
)
@inject = flexmock('inject', :each => [])
@model = flexmock('model',
:registration => @registration,
:inject => 'inject'
:inject => @inject,
)
@state = ODDB::State::Admin::FachinfoConfirm.new(@session, @model)
end
Expand Down
20 changes: 15 additions & 5 deletions test/test_state/admin/galenicform.rb
Expand Up @@ -23,7 +23,8 @@ def setup
:app => @app,
:lookandfeel => @lnf
)
@model = flexmock('model', :empty? => nil)
@parent = flexmock('parent', :pointer => 'pointer')
@model = flexmock("model_#{__LINE__}", :empty? => nil, :parent => @parent)
@form = ODDB::State::Admin::GalenicForm.new(@session, @model)
end
def test_delete
Expand All @@ -37,7 +38,7 @@ def test_delete__model_empty
:parent => parent,
:pointer => 'pointer'
)
assert_kind_of(ODDB::State::Admin::GalenicGroup, @form.delete)
assert_kind_of(ODDB::State::Admin::MergeGalenicForm, @form.delete)
end
def test_update
galenic_form = flexmock('galenic_form')
Expand Down Expand Up @@ -75,7 +76,9 @@ def user_input(*keys)
end
end
class StubApp
attr_accessor :galenic_forms
include FlexMock::TestCase
attr_accessor :galenic_forms
attr_accessor :model
attr_reader :update_called
def initialize
@update_called = false
Expand Down Expand Up @@ -103,8 +106,15 @@ def languages
def setup
@session = StubSession.new
@galform = StubGalenicForm.new
@galform.update_values({'de'=>'Tabletten', 'fr'=>'comprim?s'})
@parent = flexmock('parent', :pointer => 'pointer')
@galform = flexmock("model_#{__LINE__}",
:empty? => nil,
:parent => @parent,
:pointer => 'pointer',
)
# @galform.update_values({'de'=>'Tabletten', 'fr'=>'comprim?s'})
@state = State::Admin::GalenicForm.new(@session, @galform)

end
def test_update1
@session.app.galenic_forms = {
Expand All @@ -113,7 +123,7 @@ def test_update1
}
@session.user_input = { :de => 'Tabletten', :fr => 'comprim?s'}
flexstub(@state) do |sta|
sta.should_receive(:unique_email)
sta.should_receive(:unique_email).once
end
@state.update
assert_equal(false, @state.error?)
Expand Down
6 changes: 5 additions & 1 deletion test/test_state/admin/galenicgroup.rb
Expand Up @@ -7,6 +7,7 @@

require 'test/unit'
require 'flexmock'
require 'model/galenicgroup'
require 'state/admin/galenicgroup'
require 'util/language'
require 'state/admin/root'
Expand Down Expand Up @@ -55,6 +56,9 @@ def initialize
@odba_id = 123
end
include Language
def galenic_group
self
end
end
class StubApp; end
class StubResolved; end
Expand Down Expand Up @@ -96,7 +100,7 @@ def test_delete__error
end
def test_update
flexmock(@lnf, :languages => ['language'])
flexmock(@session, :user_input => 'user_input')
flexmock(@session, :user_input => ['user_input'])
flexmock(@state, :unique_email => 'unique_email')
flexmock(@app, :update => 'update')
assert_equal(@state, @state.update)
Expand Down
8 changes: 6 additions & 2 deletions test/test_state/admin/login.rb
Expand Up @@ -28,10 +28,14 @@ module Root

class StubLoginMethods
include ODDB::State::Admin::LoginMethods
attr_accessor :http_headers
def initialize(session)
@session = session
@errors = {}
end
def request_path
'dummyLocation'
end
end

class TestLoginMethods < Test::Unit::TestCase
Expand All @@ -48,7 +52,7 @@ def test_autologin
assert_kind_of(ODDB::State::User::InvalidUser, @loginmethods.autologin(user))
end
def test_autologin__valid
state = flexmock('state', :augment_self => 'augment_self')
state = flexmock('state', :augment_self => 'augment_self', :request_path => 'request_path')
flexmock(@session,
:desired_state => state,
:desired_state= => nil
Expand All @@ -60,7 +64,7 @@ def test_autologin__valid
assert_equal('augment_self', @loginmethods.autologin(user))
end
def test_autologin__allowed
state = flexmock('state', :augment_self => 'augment_self')
state = flexmock('state', :augment_self => 'augment_self', :request_path => 'request_path')
flexmock(@session,
:desired_state => state,
:desired_state= => nil
Expand Down
5 changes: 3 additions & 2 deletions test/test_state/admin/orphaned_fachinfo_assign.rb
Expand Up @@ -52,7 +52,7 @@ def setup
:app => @app,
:error? => nil
)
@model = flexmock('model', :name => 'name')
@model = flexmock('model', :name => 'name', :languages => 'languages')
@state = ODDB::State::Admin::OrphanedFachinfoAssign.new(@session, @model)
end
def test_init
Expand All @@ -66,7 +66,8 @@ def test_assign
assert_equal(@state, @state.assign)
end
def test_assign__else
flexmock(@session, :error? => true)
user_input = flexmock('user_input', :values => 'values', :empty? => true)
flexmock(@session, :error? => true, :user_input => user_input)
assert_equal(@state, @state.assign)
end
def test_delete_orphaned_fachinfo
Expand Down
46 changes: 34 additions & 12 deletions test/test_state/admin/package.rb
Expand Up @@ -14,7 +14,18 @@
module ODDB
module State
module Admin

class StubPointer
attr_writer :model
def resolve(app)
@model ||= StubResolved.new
end
def +(other)
self
end
def skeleton
'skeleton'
end
end
class TestPackage < Test::Unit::TestCase
include FlexMock::TestCase
def setup
Expand All @@ -25,6 +36,7 @@ def setup
@session = flexmock('session', :app => @app)
@model = flexmock('model')
@state = ODDB::State::Admin::Package.new(@session, @model)
@ikscode = flexmock('ikscode', :read => 'read', :empty? => true, :to_f => 0.1)
end
def test_check_model
flexmock(@model, :pointer => 'pointer')
Expand Down Expand Up @@ -78,7 +90,8 @@ def test_delete
sequence = flexmock('sequence', :pointer => pointer)
flexmock(@model,
:parent => sequence,
:pointer => pointer
:pointer => pointer,
:odba_delete => 'odba_delete',
)
assert_kind_of(ODDB::State::Companies::Company, @state.delete)
end
Expand Down Expand Up @@ -171,24 +184,27 @@ def test_update
)
@app = flexmock('app', :update => @model)
flexmock(@session,
:user_input => 'ikscode',
:user_input => @ikscode,
:app => @app,
:user => 'user'
)
assert_kind_of(ODDB::State::Admin::Package, @state.update)
end
def test_update__price
parent = flexmock('parent', :package => nil)
pointer = StubPointer.new
parent = flexmock('parent', :package => pointer)
package = flexmock('package', :pointer => 'pointer')
generic_group = flexmock('generic_group',
:pointer => 'pointer',
:packages => [package]
)
company = flexmock('company', :invoiceable? => false, :pointer => pointer)
flexmock(@model,
:parent => parent,
:ikscd => 'ikscd',
:ikscd= => nil,
:pointer => 'pointer',
:company => company,
:galenic_form => 'galenic_form',
:generic_group => generic_group
)
Expand All @@ -215,10 +231,11 @@ def test_update__price
:lppv,
]
user_input = {:price_public => 'price_public'}
@mock_input = flexmock('mock_input', :read => 'read')
flexmock(@session) do |s|
s.should_receive(:user_input).with(:ikscd).and_return('ikscode')
s.should_receive(:user_input).with(*keys).and_return(user_input)
s.should_receive(:user_input).with_any_args.and_return('user_input')
s.should_receive(:user_input).with_any_args.and_return(@mock_input)
end
assert_kind_of(ODDB::State::Admin::Package, @state.update)
end
Expand All @@ -239,7 +256,7 @@ def test_update__group_nil
)
@app = flexmock('app', :update => @model)
flexmock(@session,
:user_input => 'ikscode',
:user_input => @ikscode,
:app => @app,
:user => 'user',
:create => generic_group
Expand Down Expand Up @@ -267,9 +284,10 @@ def test_update__group_scan
:user => 'user',
:package_by_ikskey => package
)

flexmock(@session) do |s|
s.should_receive(:user_input).with(:generic_group).and_return('12345678 12 x')
s.should_receive(:user_input).with_any_args.and_return('ikscode')
s.should_receive(:user_input).with_any_args.and_return(@ikscode)
end
assert_kind_of(ODDB::State::Admin::Package, @state.update)
end
Expand All @@ -281,9 +299,10 @@ def test_update__create_item
:pointer => 'pointer',
:packages => [package]
)
@ikscode = flexmock('ikscode', :read => 'read', :empty? => true, :to_f => 0.1)
flexmock(@model,
:parent => parent,
:ikscd => 'ikscd',
:ikscd => @ikscode,
:ikscd= => nil,
:pointer => 'pointer',
:galenic_form => 'galenic_form',
Expand All @@ -297,7 +316,7 @@ def test_update__create_item
:create => @model
)
flexmock(@session,
:user_input => 'ikscode',
:user_input => @ikscode,
:app => @app,
:user => 'user'
)
Expand Down Expand Up @@ -409,8 +428,10 @@ def test_new_item
class TestCompanyPackage < Test::Unit::TestCase
include FlexMock::TestCase
def setup
pointer = StubPointer.new
@session = flexmock('session')
@model = flexmock('model')
@company = flexmock('company', :invoiceable? => false, :pointer => pointer)
@model = flexmock('model', :odba_delete => 'odba_delete', :company => @company, :pointer => pointer)
@state = ODDB::State::Admin::CompanyPackage.new(@session, @model)
end
def test_init
Expand All @@ -436,7 +457,7 @@ def test_new_item
assert_kind_of(ODDB::State::Admin::SlEntry, @state.new_item)
end
def test_update
parent = flexmock('parent', :package => nil)
parent = flexmock('parent', :package => [])
package = flexmock('package', :pointer => 'pointer')
generic_group = flexmock('generic_group',
:pointer => 'pointer',
Expand All @@ -451,8 +472,9 @@ def test_update
:generic_group => generic_group
)
@app = flexmock('app', :update => @model)
ikscode = flexmock('ikscode', :read => 'read', :empty? => false)
flexmock(@session,
:user_input => 'ikscode',
:user_input => ikscode,
:app => @app,
:user => 'user',
:allowed? => true
Expand Down
2 changes: 1 addition & 1 deletion test/test_state/admin/poweruser.rb
Expand Up @@ -41,7 +41,7 @@ def test_limited
assert(@state.limited?)
end
def test_limit_state
user = flexmock('user', :allowed? => nil)
user = flexmock('user', :allowed? => nil, :valid? => true)
flexmock(@session, :user => user)
assert_kind_of(ODDB::State::User::InvalidUser, @state.limit_state)
end
Expand Down
24 changes: 19 additions & 5 deletions test/test_state/admin/registration.rb
Expand Up @@ -27,11 +27,18 @@ module Admin
class TestRegistration < Test::Unit::TestCase
include FlexMock::TestCase
def setup
@app = flexmock('app')
@pointer = flexmock('pointer', :+ => @pointer)
@registration= flexmock('registration',
:pointer => @pointer,
:company => 'company',
:iksnr => 'iksnr',
)
@app = flexmock('app', :registration => @registration)
@lnf = flexmock('lookandfeel', :event_url => 'event_url')
@session = flexmock('session',
:lookandfeel => @lnf,
:app => @app
:app => @app,
:persistent_user_input => 'persistent_user_input',
)
@model = flexmock('model',
:fachinfo => 'fachinfo',
Expand Down Expand Up @@ -297,12 +304,19 @@ def test_update__duplicate_iksnr
class TestCompanyRegistration < Test::Unit::TestCase
include FlexMock::TestCase
def setup
@app = flexmock('app')
@pointer = flexmock('pointer', :+ => @pointer)
@registration= flexmock('registration',
:pointer => @pointer,
:company => 'company',
:iksnr => 'iksnr',
)
@app = flexmock('app', :registration => @registration)
@lnf = flexmock('lookandfeel', :event_url => 'event_url')
@session = flexmock('session',
:lookandfeel => @lnf,
:app => @app,
:allowed? => false
:allowed? => true,
:persistent_user_input => 'persistent_user_input',
)
@model = flexmock('model',
:company => 'company',
Expand All @@ -311,7 +325,7 @@ def setup
@reg = ODDB::State::Admin::CompanyRegistration.new(@session, @model)
end
def test_init
assert_equal(ODDB::View::Admin::Registration, @reg.init)
assert_equal(nil, @reg.init)
end
def test_allowed
flexmock(@session, :allowed? => true)
Expand Down

0 comments on commit 20cdac1

Please sign in to comment.