josephholsten-rets4r 1.1.17 → 1.1.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. metadata +44 -84
  2. data/CHANGELOG +0 -336
  3. data/CONTRIBUTORS +0 -7
  4. data/GPL +0 -340
  5. data/LICENSE +0 -29
  6. data/NEWS +0 -183
  7. data/README.rdoc +0 -45
  8. data/RUBYS +0 -56
  9. data/Rakefile +0 -57
  10. data/TODO +0 -29
  11. data/VERSION.yml +0 -5
  12. data/examples/client_get_object.rb +0 -47
  13. data/examples/client_login.rb +0 -37
  14. data/examples/client_metadata.rb +0 -40
  15. data/examples/client_parser.rb +0 -10
  16. data/examples/client_search.rb +0 -47
  17. data/examples/settings.yml +0 -12
  18. data/lib/rets4r.rb +0 -9
  19. data/lib/rets4r/auth.rb +0 -73
  20. data/lib/rets4r/client.rb +0 -723
  21. data/lib/rets4r/client/data.rb +0 -14
  22. data/lib/rets4r/client/dataobject.rb +0 -20
  23. data/lib/rets4r/client/metadata.rb +0 -15
  24. data/lib/rets4r/client/parsers/compact.rb +0 -42
  25. data/lib/rets4r/client/parsers/compact_nokogiri.rb +0 -81
  26. data/lib/rets4r/client/parsers/metadata.rb +0 -92
  27. data/lib/rets4r/client/parsers/response_parser.rb +0 -100
  28. data/lib/rets4r/client/transaction.rb +0 -31
  29. data/lib/rets4r/core_ext/array/extract_options.rb +0 -15
  30. data/lib/rets4r/core_ext/class/attribute_accessors.rb +0 -58
  31. data/lib/rets4r/core_ext/hash/keys.rb +0 -46
  32. data/lib/rets4r/core_ext/hash/slice.rb +0 -39
  33. data/lib/rets4r/listing_mapper.rb +0 -17
  34. data/lib/rets4r/listing_service.rb +0 -35
  35. data/lib/rets4r/loader.rb +0 -8
  36. data/lib/tasks/annotations.rake +0 -20
  37. data/lib/tasks/coverage.rake +0 -13
  38. data/test/compact_nokogiri_test.rb +0 -35
  39. data/test/data/1.5/bad_compact.xml +0 -7
  40. data/test/data/1.5/count_only_compact.xml +0 -3
  41. data/test/data/1.5/error.xml +0 -1
  42. data/test/data/1.5/invalid_compact.xml +0 -4
  43. data/test/data/1.5/login.xml +0 -16
  44. data/test/data/1.5/metadata.xml +0 -0
  45. data/test/data/1.5/search_compact.xml +0 -8
  46. data/test/data/1.5/search_compact_big.xml +0 -136
  47. data/test/data/1.5/search_unescaped_compact.xml +0 -8
  48. data/test/data/listing_service.yml +0 -36
  49. data/test/listing_mapper_test.rb +0 -112
  50. data/test/loader_test.rb +0 -24
  51. data/test/test_auth.rb +0 -68
  52. data/test/test_client.rb +0 -315
  53. data/test/test_helper.rb +0 -12
  54. data/test/test_parser.rb +0 -96
@@ -1,112 +0,0 @@
1
- $:.unshift File.expand_path(File.join(File.dirname(__FILE__)))
2
- require 'test_helper'
3
-
4
- class ListingMapperTest < Test::Unit::TestCase
5
- context "ListingMapper" do
6
- should "access select" do
7
- config = RETS4R::ListingService.connection
8
- mapper = RETS4R::ListingMapper.new(config)
9
- assert_equal config[:select], mapper.select
10
- end
11
- should "map from rets keys to record keys" do
12
- original = {
13
- "ListingID"=>"11322886",
14
- "AgentID"=>"000533246",
15
- "Status"=>"act",
16
- "ListPrice"=>"239000",
17
- "StreetNumber"=>"8317",
18
- "StreetName"=>"Thompson",
19
- "StreetDirection"=>"",
20
- "Unit"=>"",
21
- "ZipCode"=>"79606-6652",
22
- "City"=>"Abilene",
23
- "County"=>"Taylor",
24
- "State"=>"TX",
25
- "LotSize"=>"LTS.5-.99A",
26
- "SqFt"=>"2825",
27
- "LivingArea"=>"2",
28
- "Bedrooms"=>"4",
29
- "Garage"=>"PARATTACHE,PAROPENER,PARREAR,PARSIDE",
30
- "YearBuilt"=>"2005",
31
- "AgentName"=>"CD Boyd, II",
32
-
33
- "GARAGECAP"=>"2",
34
- "BATHSFULLBASEMENT"=>"",
35
- "BATHSFULLLEVEL1"=>"",
36
- "BATHSFULLLEVEL2"=>"",
37
- "BATHSFULLLEVEL3"=>"",
38
- "STORIES"=>"2",
39
- "INTERIOR"=>"INFBAY-WIN,INFCABLE-A,INFDECLTNG,INFHIGHSPD,INFLOFT,INFSOUND-W,INFVAUL-CL,INFWIND-CO",
40
- "ACRESCULTIVATED"=>"",
41
- "CARPORTCAP"=>"0",
42
- "TAXUNEXEMPT"=>"5876",
43
- "STREETDIRSUFFIX"=>"",
44
- "NUMSTOCKTANKS"=>"",
45
- "LOTDIM"=>"87X182",
46
- "ACRESPRICE"=>"662049",
47
- "FIREPLACES"=>"1",
48
- "SUBDIVISION"=>"Belle Vista Estates",
49
- "UTILITIES"=>"STUASPHALT,UTLCITY-SE,UTLCITY-WA,STUCONCRET",
50
- "LISTSTATUSFLAG"=>"",
51
- "NUMDININGAREAS"=>"2",
52
- "SQFTPRICE"=>"84.6",
53
- "MAPPAGE"=>"9999",
54
- "NUMBARNS"=>"",
55
- "UIDPRP"=>"3211078",
56
- "NUMRESIDENCE"=>"",
57
- "LISTPRICELOW"=>"0",
58
- "MAPBOOK"=>"OT",
59
- "LOTNUM"=>"",
60
- "OFFICELIST_OFFICENAM1"=>"McClure, REALTORS",
61
- "ACRES"=>"0.361",
62
- "AGENTSELL_FULLNAME"=>"",
63
- "BATHSHALFLEVEL1"=>"",
64
- "PROPSUBTYPE"=>"S",
65
- "ROOMBEDBATHDESC"=>"BBFJET-TUB,BBFLIN-CLO,BBFSEP-SHO,BBFW+I-CLO",
66
- "BATHSHALFLEVEL2"=>"",
67
- "LISTPRICEORIG"=>"239000",
68
- "BATHSHALFLEVEL3"=>"",
69
- "UID"=>"3211078",
70
- "OFFICELIST"=>"FMAB",
71
- "BATHSHALFBASEMENT"=>"",
72
- "STORIESBLDG"=>"",
73
- "REMARKS"=>"Custom home built in 05'. Growing neighborhood convienient to Wylie schools. Abundant living areas and and open space floor plan.Could be 5th BDRM, or upstair BDRM & Bath could be another living area. Perfect office next to Master. Gourmet sized kitchen, granite countertops, barell ceilings, wonderful storage space!!!!",
74
- "STREETNUMDISPLAY"=>"8317",
75
- "PROPSUBTYPEDISPLAY"=>"RES-S",
76
- "BATHSHALF"=>"0",
77
- "STYLE"=>"STYRANCH",
78
- "COMMONFEATURES"=>"",
79
- "OFFICESELL_OFFICENAM2"=>"",
80
- "BATHSFULL"=>"3",
81
- "MAPCOORD"=>"none",
82
- "SQFTSOURCE"=>"TAX",
83
- "NUMLAKES"=>"",
84
- "NUMWELLS"=>"",
85
- "NUMPONDS"=>"",
86
- "LOTDESC"=>"LTDSUBDIV"}
87
- mapper = RETS4R::ListingMapper.new
88
- actual = mapper.map(original)
89
- expected = {
90
- :mls => "11322886",
91
- :agent_id =>"000533246",
92
- :rets_updated_at => nil,
93
- :status=>"act",
94
- :list_price =>"239000",
95
- :street_number =>"8317",
96
- :street_direction => "",
97
- :street_name=>"Thompson",
98
- :unit_number =>"",
99
- :zip_code =>"79606-6652",
100
- :city => "Abilene",
101
- :county =>"Taylor",
102
- :square_feet =>"2825",
103
- :living_area => "2",
104
- :baths =>nil,
105
- :beds => "4",
106
- :garage => "PARATTACHE,PAROPENER,PARREAR,PARSIDE",
107
- :year_built => "2005",
108
- }
109
- expected.merge(actual).keys.each{|k| assert_equal expected[k], actual[k], "mismatched on key #{k}"}
110
- end
111
- end
112
- end
data/test/loader_test.rb DELETED
@@ -1,24 +0,0 @@
1
- $:.unshift File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))
2
-
3
- require 'rets4r'
4
- require 'test/unit'
5
-
6
- class LoaderTest < Test::Unit::TestCase
7
- def test_should_pass_records_to_block
8
- file = File.expand_path(File.join('test', 'data', '1.5', 'search_compact.xml'))
9
-
10
- listings = []
11
- RETS4R::Loader.load(open(file)) do |record|
12
- listings << record
13
- end
14
-
15
- assert_equal 2, listings.length
16
- assert_equal "Datum1", listings[0]['First']
17
- assert_equal "Datum2", listings[0]['Second']
18
- assert_equal "Datum3", listings[0]['Third']
19
- assert_equal "Datum4", listings[1]['First']
20
- assert_equal "Datum5", listings[1]['Second']
21
- assert_equal "Datum6", listings[1]['Third']
22
-
23
- end
24
- end
data/test/test_auth.rb DELETED
@@ -1,68 +0,0 @@
1
- $:.unshift File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))
2
-
3
- require 'rets4r/auth'
4
- require 'test/unit'
5
-
6
- module RETS4R
7
- class TestAuth < Test::Unit::TestCase
8
- def setup
9
- @useragent = 'TestAgent/0.00'
10
- @username = 'username'
11
- @password = 'password'
12
- @realm = 'REALM'
13
- @nonce = '2006-03-03T17:37:10'
14
- end
15
-
16
- def test_authenticate
17
- response = {
18
- 'www-authenticate' => 'Digest qop="auth",realm="'+ @realm +'",nonce="'+ @nonce +'",opaque="",stale="false",domain="\my\test\domain"'
19
- }
20
-
21
- Auth.authenticate(response, @username, @password, '/my/rets/url', 'GET', Auth.request_id, @useragent)
22
- end
23
-
24
- # test without spacing
25
- def test_parse_auth_header_without_spacing
26
- header = 'Digest qop="auth",realm="'+ @realm +'",nonce="'+ @nonce +'",opaque="",stale="false",domain="\my\test\domain"'
27
- check_header(header)
28
- end
29
-
30
- # test with spacing between each item
31
- def test_parse_auth_header_with_spacing
32
- header = 'Digest qop="auth", realm="'+ @realm +'", nonce="'+ @nonce +'", opaque="", stale="false", domain="\my\test\domain"'
33
- check_header(header)
34
- end
35
-
36
- # used to check the that the header was processed properly.
37
- def check_header(header)
38
- results = Auth.parse_header(header)
39
-
40
- assert_equal('auth', results['qop'])
41
- assert_equal('REALM', results['realm'])
42
- assert_equal('2006-03-03T17:37:10', results['nonce'])
43
- assert_equal('', results['opaque'])
44
- assert_equal('false', results['stale'])
45
- assert_equal('\my\test\domain', results['domain'])
46
- end
47
-
48
- def test_calculate_digest
49
- # with qop
50
- assert_equal('c5f9ef280f0ca78ed7a488158fc2f4cc', Auth.calculate_digest(@username, \
51
- @password, @realm, 'test', 'GET', '/my/rets/url', true, 'test'))
52
-
53
- # without qop
54
- assert_equal('bceafa34467a3519c2f6295d4800f4ea', Auth.calculate_digest(@username, \
55
- @password, @realm, 'test', 'GET', '/my/rets/url', false))
56
- end
57
-
58
- def test_request_id
59
- assert_not_nil(true, Auth.request_id)
60
- end
61
-
62
- def test_cnonce
63
- # We call cnonce with a static request ID so that we have a consistent result with which
64
- # to test against
65
- assert_equal('d5cdfa1acffde590d263689fb40cf53c', Auth.cnonce(@useragent, @password, 'requestId', @nonce))
66
- end
67
- end
68
- end
data/test/test_client.rb DELETED
@@ -1,315 +0,0 @@
1
- $:.unshift File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))
2
-
3
- require 'rets4r'
4
- require 'test/unit'
5
- require 'stringio'
6
- require 'logger'
7
- require 'rubygems' rescue nil
8
- require 'mocha'
9
-
10
- module RETS4R
11
- class Client
12
- public :process_content_type
13
- end
14
-
15
- class TestClientGetMetadata < Test::Unit::TestCase
16
- RETS_PORT = '9080'
17
- RETS_URL = "http://localhost:#{RETS_PORT}"
18
- RETS_LOGIN = 'login'
19
- RETS_PASSWORD = 'password'
20
-
21
- class CustomError < StandardError; end
22
-
23
- def setup
24
- @logfile = StringIO.open
25
- @rets = RETS4R::Client.new(RETS_URL)
26
- @rets.logger = Logger.new(@logfile)
27
- @rets.logger.level = Logger::DEBUG
28
-
29
- @rets.stubs(:request).returns(@response = mock("response"))
30
- @response.stubs(:body).returns(:body)
31
- @rets.stubs(:parse).returns(@results = mock("results"))
32
- Client::ResponseParser.any_instance.stubs(:parse_metadata).returns(@results = mock("results"))
33
- end
34
-
35
- def teardown
36
- @logfile.close
37
- end
38
-
39
- def test_get_metadata_yields_the_results_if_given_a_block
40
- in_block = false
41
- @rets.get_metadata do |results|
42
- in_block = true
43
- assert_equal @results, results
44
- end
45
-
46
- assert in_block, "Block was never yielded to"
47
- end
48
-
49
- def test_get_metadata_returns_the_metadata_when_no_block_given
50
- rval = @rets.get_metadata
51
-
52
- assert_equal @results, rval
53
- end
54
-
55
- def test_get_metadata_returns_the_blocks_value_when_given_a_block
56
- rval = @rets.get_metadata do |results|
57
- :block_value
58
- end
59
-
60
- assert_equal :block_value, rval
61
- end
62
- end
63
-
64
- class TestClientGetObject < Test::Unit::TestCase
65
- RETS_PORT = '9080'
66
- RETS_URL = "http://localhost:#{RETS_PORT}"
67
- RETS_LOGIN = 'login'
68
- RETS_PASSWORD = 'password'
69
-
70
- class CustomError < StandardError; end
71
-
72
- def setup
73
- @logfile = StringIO.open
74
- @rets = RETS4R::Client.new(RETS_URL)
75
- @rets.logger = Logger.new(@logfile)
76
- @rets.logger.level = Logger::DEBUG
77
-
78
- @rets.stubs(:request).returns(@response = mock("response"))
79
- end
80
-
81
- def test_returns_multipart_parallel_objects_in_a_single_array(boundary = "1231")
82
- @response.expects(:[]).with('content-type').at_least_once.returns("multipart/parallel; boundary=#{boundary}")
83
- @response.expects(:body).returns("\r\n--1231\r\nContent-ID: 392103\r\nObject-ID: 1\r\nContent-Type: image/jpeg\r\n\r\n" + "\000"*120 + "\r\n--1231\r\nContent-ID: 392103\r\nObject-ID: 2\r\nContent-Type: image/gif\r\n\r\n" + "\000"*140 + "\r\n--1231--")
84
- results = @rets.get_object("Property", "Photo", "392103:*")
85
- assert_equal 2, results.size, "Client should parse two objects out of the request"
86
- assert_kind_of RETS4R::Client::DataObject, results[0], "First result isn't a DataObject"
87
- assert_kind_of RETS4R::Client::DataObject, results[1], "Second result isn't a DataObject"
88
- assert_equal "image/jpeg", results[0].type["Content-Type"], "First object isn't an image/jpeg"
89
- assert_equal 120, results[0].data.size, "First object isn't 120 bytes in length"
90
- assert_equal "image/gif", results[1].type["Content-Type"], "Second object isn't an image/gif"
91
- assert_equal 140, results[1].data.size, "Second object isn't 140 bytes in length"
92
- end
93
-
94
- def test_returns_multipart_parallel_objects_in_a_single_array_boundary_with_double_quotes
95
- test_returns_multipart_parallel_objects_in_a_single_array('"1231"')
96
- end
97
-
98
- def test_returns_multipart_parallel_objects_in_a_single_array_boundary_with_single_quotes
99
- test_returns_multipart_parallel_objects_in_a_single_array("'1231'")
100
- end
101
-
102
- def test_returns_single_entity_object_in_a_single_element_array
103
- @response.expects(:[]).with('content-type').at_least_once.returns("image/jpeg")
104
- @response.expects(:[]).with('Transfer-Encoding').at_least_once.returns("")
105
- @response.expects(:[]).with('Content-Length').at_least_once.returns(241)
106
- @response.expects(:[]).with('Object-ID').at_least_once.returns("25478")
107
- @response.expects(:[]).with('Content-ID').at_least_once.returns("5589")
108
- @response.expects(:body).returns("\000"*241)
109
-
110
- results = @rets.get_object("Property", "Photo", "392103:*")
111
- assert_equal 1, results.size, "Client parsed one object out of the request"
112
- assert_kind_of RETS4R::Client::DataObject, results[0], "First result isn't a DataObject"
113
- assert_equal "image/jpeg", results[0].type["Content-Type"], "Content-Type not copied"
114
- assert_equal "5589", results[0].type["Content-ID"], "Content-ID not copied"
115
- assert_equal "25478", results[0].type["Object-ID"], "Object-ID not copied"
116
- assert_equal 241, results[0].data.size, "First object isn't 241 bytes in length"
117
- end
118
-
119
- def test_returns_single_entity_object_as_chunked_encoding_in_a_single_element_array
120
- @response.expects(:[]).with('content-type').at_least_once.returns("image/jpeg")
121
- @response.expects(:[]).with('Transfer-Encoding').at_least_once.returns("chunked")
122
- @response.expects(:[]).with('Object-ID').at_least_once.returns("25478")
123
- @response.expects(:[]).with('Content-ID').at_least_once.returns("5589")
124
- @response.expects(:body).returns("\000"*241)
125
-
126
- results = @rets.get_object("Property", "Photo", "392103:*")
127
- assert_equal 1, results.size, "Client parsed one object out of the request"
128
- assert_kind_of RETS4R::Client::DataObject, results[0], "First result isn't a DataObject"
129
- assert_equal "image/jpeg", results[0].type["Content-Type"], "Content-Type not copied"
130
- assert_equal "5589", results[0].type["Content-ID"], "Content-ID not copied"
131
- assert_equal "25478", results[0].type["Object-ID"], "Object-ID not copied"
132
- assert_equal 241, results[0].data.size, "First object isn't 241 bytes in length"
133
- end
134
-
135
- def test_yields_data_objects_to_block_and_returns_blocks_value
136
- @response.expects(:[]).with('content-type').at_least_once.returns("image/jpeg")
137
- @response.expects(:[]).with('Transfer-Encoding').at_least_once.returns("")
138
- @response.expects(:[]).with('Content-Length').at_least_once.returns(241)
139
- @response.expects(:[]).with('Object-ID').at_least_once.returns("25478")
140
- @response.expects(:[]).with('Content-ID').at_least_once.returns("5589")
141
- @response.expects(:body).returns("\000"*241)
142
-
143
- yielded_count = 0
144
-
145
- value = @rets.get_object("Property", "VRImage", "912:0") do |result|
146
- assert_kind_of RETS4R::Client::DataObject, result
147
- yielded_count += 1
148
- :return_value
149
- end
150
-
151
- assert_equal yielded_count, value
152
- end
153
- end
154
-
155
- class TestClientLogin < Test::Unit::TestCase
156
- RETS_PORT = '9080'
157
- RETS_URL = "http://localhost:#{RETS_PORT}"
158
- RETS_LOGIN = 'login'
159
- RETS_PASSWORD = 'password'
160
-
161
- class CustomError < StandardError; end
162
-
163
- def setup
164
- @logfile = StringIO.open
165
- @rets = RETS4R::Client.new(RETS_URL)
166
- @rets.logger = Logger.new(@logfile)
167
- @rets.logger.level = Logger::DEBUG
168
-
169
- @rets.stubs(:request).returns(@response = mock("response"))
170
- @response.stubs(:body).returns(:body)
171
- Client::ResponseParser.any_instance.stubs(:parse_key_value).returns(@results = mock("results"))
172
- @results.stubs(:success?).returns(true)
173
- @results.stubs(:response).returns(Hash.new)
174
- @results.stubs(:secondary_response=)
175
- end
176
-
177
- def teardown
178
- @logfile.close
179
- end
180
-
181
- def test_successful_login_yields_the_results_to_the_block
182
- @rets.expects(:request).with {|arg| arg.kind_of?(URI)}.returns(@response)
183
- Client::ResponseParser.any_instance.expects(:parse_key_value).returns(@results)
184
- @results.expects(:success?).returns(true)
185
- @rets.expects(:logout)
186
-
187
- in_block = false
188
- @rets.login("user", "pass") do |results|
189
- assert_equal @results, results
190
- in_block = true
191
- end
192
-
193
- assert in_block, "Block was never yielded to"
194
- end
195
-
196
- def test_logout_called_after_block_execution_if_block_raises
197
- assert_raises(CustomError) do
198
- @rets.expects(:logout)
199
- @rets.login("user", "pass") do |results|
200
- raise CustomError
201
- end
202
- end
203
- end
204
-
205
- def test_login_returns_the_blocks_value
206
- rval = @rets.login("user", "pass") do |results|
207
- :value
208
- end
209
-
210
- assert_equal :value, rval
211
- end
212
-
213
- def test_login_without_a_block_returns_the_results
214
- results = @rets.login("user", "pass")
215
- assert_equal @results, results
216
- end
217
- end
218
-
219
- class TestClient < Test::Unit::TestCase
220
- RETS_PORT = '9080'
221
- RETS_URL = "http://localhost:#{RETS_PORT}"
222
- RETS_LOGIN = 'login'
223
- RETS_PASSWORD = 'password'
224
-
225
- def setup
226
- @logfile = StringIO.open
227
- @rets = RETS4R::Client.new(RETS_URL)
228
- @rets.logger = Logger.new(@logfile)
229
- @rets.logger.level = Logger::DEBUG
230
- end
231
-
232
- def teardown
233
- @logfile.close
234
- end
235
-
236
- def test_setup
237
- assert_nothing_raised() { @rets.set_user_agent('ACK/2.1') }
238
- assert_equal('ACK/2.1', @rets.user_agent)
239
-
240
- assert_nothing_raised() { @rets.user_agent = 'SPRETS/0.1' }
241
- assert_nothing_raised() { @rets.set_request_method('GET') }
242
-
243
- assert_raise(RETS4R::Client::Unsupported) { @rets.set_rets_version('1.4.0') }
244
- assert_nothing_raised() { @rets.set_rets_version('1.5') }
245
- assert_equal("1.5", @rets.rets_version)
246
- assert_equal("RETS/1.5", @rets.get_header("RETS-Version"))
247
- assert_nothing_raised() { @rets.rets_version = '1.7' }
248
- assert_equal("RETS/1.7", @rets.get_header("RETS-Version"))
249
-
250
- assert_equal('SPRETS/0.1', @rets.get_user_agent)
251
- assert_equal('GET', @rets.get_request_method)
252
- assert_equal('1.7', @rets.get_rets_version)
253
-
254
- assert_nothing_raised() { @rets.request_method = 'POST' }
255
-
256
- assert_equal('POST', @rets.request_method)
257
-
258
-
259
- # Check that our changes were logged when in debug mode
260
- assert @logfile.length > 0
261
- end
262
-
263
- # Just to make sure that we're okay when we don't have a logger, we set it to nil and
264
- # make a change that would trigger a debug mode log.
265
- def test_without_logger
266
- @rets.logger = nil
267
-
268
- assert_nothing_raised() { @rets.set_request_method('GET') }
269
- end
270
-
271
- def test_content_type_parsing
272
- ct = 'multipart/parallel; boundary=cc2631bb.0165.3b32.8a7d.a8453f662101; charset=utf-8'
273
-
274
- results = @rets.process_content_type(ct)
275
-
276
- assert_equal('cc2631bb.0165.3b32.8a7d.a8453f662101', results['boundary'])
277
- assert_equal('multipart/parallel', results['content-type'])
278
- assert_equal('utf-8', results['charset'])
279
- end
280
-
281
- def test_performs_get_request
282
- assert_nothing_raised() {@rets.request_method = 'GET'}
283
- assert_equal('GET', @rets.request_method)
284
-
285
- http = mock('http')
286
- response = mock('response')
287
- response.stubs(:to_hash).returns({})
288
- response.stubs(:code).returns('500')
289
- response.stubs(:message).returns('Move along, nothing to see here.')
290
-
291
- http.expects(:get).with('', {'RETS-Session-ID' => '0', 'User-Agent' => @rets.user_agent, 'RETS-Version' => "RETS/#{@rets.rets_version}", 'Accept' => '*/*'}).at_least_once.returns(response)
292
- http.expects(:post).never
293
- Net::HTTP.any_instance.expects(:start).at_least_once.yields(http)
294
-
295
- assert_raises(RETS4R::Client::HTTPError) {@rets.login('user', 'pass')}
296
- end
297
-
298
- def test_performs_post_request
299
- assert_nothing_raised() {@rets.request_method = 'POST'}
300
- assert_equal('POST', @rets.request_method)
301
-
302
- http = mock('http')
303
- response = mock('response')
304
- response.stubs(:to_hash).returns({})
305
- response.stubs(:code).returns('500')
306
- response.stubs(:message).returns('Move along, nothing to see here.')
307
-
308
- http.expects(:post).with('', '', {'RETS-Session-ID' => '0', 'User-Agent' => @rets.user_agent, 'RETS-Version' => "RETS/#{@rets.rets_version}", 'Accept' => '*/*'}).at_least_once.returns(response)
309
- http.expects(:get).never
310
- Net::HTTP.any_instance.expects(:start).at_least_once.yields(http)
311
-
312
- assert_raises(RETS4R::Client::HTTPError) {@rets.login('user', 'pass')}
313
- end
314
- end
315
- end