Class: ODDB::TestOddbSession

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
test/test_util/session.rb

Defined Under Namespace

Classes: StubApp, StubUnknownUser, StubValidator

Instance Method Summary (collapse)

Instance Method Details

- (Object) setup



57
58
59
60
# File 'test/test_util/session.rb', line 57

def setup
  @session = ODDB::Session.new("test", StubApp.new, StubValidator.new)
  @session.reset
end

- (Object) test_cgi_compatible



70
71
72
73
74
75
# File 'test/test_util/session.rb', line 70

def test_cgi_compatible
  assert_respond_to(@session, :restore)
  assert_respond_to(@session, :update)
  assert_respond_to(@session, :close)
  assert_respond_to(@session, :delete)
end

- (Object) test_flavor



115
116
117
118
119
120
121
122
123
# File 'test/test_util/session.rb', line 115

def test_flavor
  assert_equal('gcc', @session.flavor)
  request = SBSM::Request.new('druby://localhost:10001')
  @session.process(request)
  assert_equal('gcc', @session.flavor)
  request.params["flavor"] = 'hdd'
  @session.process(request)
  assert_equal('gcc', @session.flavor)
end

- (Object) test_init_state



64
65
66
# File 'test/test_util/session.rb', line 64

def test_init_state
  assert_equal(ODDB::State::Drugs::Init, @session.state.class)
end

- (Object) test_initialize



61
62
63
# File 'test/test_util/session.rb', line 61

def test_initialize
  assert_nothing_raised { ODDB::Session.new("test", StubApp.new, nil) }
end

- (Object) test_process



80
81
82
83
84
85
# File 'test/test_util/session.rb', line 80

def test_process
  request = SBSM::Request.new('druby://localhost:10001')
  assert_nothing_raised {
    @session.process(request)
  }
end

- (Object) test_restore



76
77
78
79
# File 'test/test_util/session.rb', line 76

def test_restore
  restore = @session.restore[:proxy]
  assert_instance_of(Session, restore)
end

- (Object) test_unwrapped_lookandfeel



67
68
69
# File 'test/test_util/session.rb', line 67

def test_unwrapped_lookandfeel
  assert_equal(ODDB::LookandfeelBase, @session.lookandfeel.class)
end

- (Object) test_user_input



94
95
96
97
98
99
100
101
# File 'test/test_util/session.rb', line 94

def test_user_input
  request = SBSM::Request.new('druby://localhost:10001')
  request.cgi["foo"] = "bar"
  request.cgi["bar"] = "foo"
  @session.process(request) 
  assert_equal("bar", @session.user_input(:foo))
  assert_equal("foo", @session.user_input(:bar))
end

- (Object) test_user_input_hash



102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'test/test_util/session.rb', line 102

def test_user_input_hash
  request = SBSM::Request.new('druby://localhost:10001')
  request.cgi["hash[1]"] = "4"
  request.cgi["hash[2]"] = "5"
  request.cgi["hash[3]"] = "6"
  @session.process request
  hash = @session.user_input(:hash)
  assert_equal(Hash, hash.class)
  assert_equal(3, hash.size)
  assert_equal("4", hash["1"])
  assert_equal("5", hash["2"])
  assert_equal("6", hash["3"])
end

- (Object) test_user_input_nil



89
90
91
92
93
# File 'test/test_util/session.rb', line 89

def test_user_input_nil
  @session.process SBSM::Request.new('druby://localhost:10001')
  assert_not_nil(@session.request)
  assert_equal(nil, @session.user_input("no_input"))
end

- (Object) test_user_input_no_context



86
87
88
# File 'test/test_util/session.rb', line 86

def test_user_input_no_context
  assert_equal(nil, @session.user_input("no_input"))
end