public
Description: RESTful workflow / bpm engine based on Rack and OpenWFEru
Homepage: http://openwferu.rubyforge.org
Clone URL: git://github.com/jmettraux/ruote-rest.git
ruote-rest / test / st_participants.rb
100644 90 lines (55 sloc) 1.66 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#
# Testing ruote-rest
#
# John Mettraux at OpenWFE dot org
#
# Mon Apr 14 15:45:00 JST 2008
#
 
require 'rubygems'
 
require 'testbase'
require 'ruote_rest.rb'
 
 
class StParticipantsTest < Test::Unit::TestCase
 
  include TestBase
 
 
  def test_0
 
    get '/participants'
 
    #puts @response.body
 
    assert_equal 200, @response.status
    assert_equal 'application/xml', @response['Content-Type']
 
    post(
      '/participants',
      '["toto","OpenWFE::HashParticipant"]',
      { 'CONTENT_TYPE' => 'application/json' })
 
    assert_equal 201, @response.status
    assert_not_equal '', @response.body
 
    get '/participants'
 
    #puts @response.body
 
    assert_not_nil(
      @response.body.index(' count="4"'), "expected 4 participants")
 
    get '/participants/toto'
 
    assert_not_nil @response.body.index('>toto<')
 
    delete '/participants/toto'
 
    assert_equal 303, @response.status
 
    get '/participants'
 
    #puts @response.body
 
    assert_not_nil @response.body.index(' count="3"')
  end
 
  def test_1
 
    post(
      '/participants',
      '["toto","OpenWFE::Extras::ActiveStoreParticipant", "totostore"]',
      { 'CONTENT_TYPE' => 'application/json' })
 
    assert_equal 201, @response.status
    assert_not_equal '', @response.body
 
    get '/participants'
 
    assert_not_nil(
      @response.body.index(' count="4"'), 'expected 4 participants')
 
    get '/participants?pname=toto'
 
    assert_equal 200, @response.status
    assert_not_nil @response.body.index('toto')
  end
 
  def test_2
 
    assert_equal(
      [ 'one', 'two', 'three' ],
      $app.engine.get_participant_map.lookup_participant('carlito').params)
  end
 
end