forked from josephholsten/rets4r
-
Notifications
You must be signed in to change notification settings - Fork 0
/
listing_mapper_test.rb
112 lines (110 loc) · 3.8 KB
/
listing_mapper_test.rb
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
$:.unshift File.expand_path(File.join(File.dirname(__FILE__)))
require 'test_helper'
class ListingMapperTest < Test::Unit::TestCase
context "ListingMapper" do
should "access select" do
config = RETS4R::ListingService.connection
mapper = RETS4R::ListingMapper.new(config)
assert_equal config[:select], mapper.select
end
should "map from rets keys to record keys" do
original = {
"ListingID"=>"11322886",
"AgentID"=>"000533246",
"Status"=>"act",
"ListPrice"=>"239000",
"StreetNumber"=>"8317",
"StreetName"=>"Thompson",
"StreetDirection"=>"",
"Unit"=>"",
"ZipCode"=>"79606-6652",
"City"=>"Abilene",
"County"=>"Taylor",
"State"=>"TX",
"LotSize"=>"LTS.5-.99A",
"SqFt"=>"2825",
"LivingArea"=>"2",
"Bedrooms"=>"4",
"Garage"=>"PARATTACHE,PAROPENER,PARREAR,PARSIDE",
"YearBuilt"=>"2005",
"AgentName"=>"CD Boyd, II",
"GARAGECAP"=>"2",
"BATHSFULLBASEMENT"=>"",
"BATHSFULLLEVEL1"=>"",
"BATHSFULLLEVEL2"=>"",
"BATHSFULLLEVEL3"=>"",
"STORIES"=>"2",
"INTERIOR"=>"INFBAY-WIN,INFCABLE-A,INFDECLTNG,INFHIGHSPD,INFLOFT,INFSOUND-W,INFVAUL-CL,INFWIND-CO",
"ACRESCULTIVATED"=>"",
"CARPORTCAP"=>"0",
"TAXUNEXEMPT"=>"5876",
"STREETDIRSUFFIX"=>"",
"NUMSTOCKTANKS"=>"",
"LOTDIM"=>"87X182",
"ACRESPRICE"=>"662049",
"FIREPLACES"=>"1",
"SUBDIVISION"=>"Belle Vista Estates",
"UTILITIES"=>"STUASPHALT,UTLCITY-SE,UTLCITY-WA,STUCONCRET",
"LISTSTATUSFLAG"=>"",
"NUMDININGAREAS"=>"2",
"SQFTPRICE"=>"84.6",
"MAPPAGE"=>"9999",
"NUMBARNS"=>"",
"UIDPRP"=>"3211078",
"NUMRESIDENCE"=>"",
"LISTPRICELOW"=>"0",
"MAPBOOK"=>"OT",
"LOTNUM"=>"",
"OFFICELIST_OFFICENAM1"=>"McClure, REALTORS",
"ACRES"=>"0.361",
"AGENTSELL_FULLNAME"=>"",
"BATHSHALFLEVEL1"=>"",
"PROPSUBTYPE"=>"S",
"ROOMBEDBATHDESC"=>"BBFJET-TUB,BBFLIN-CLO,BBFSEP-SHO,BBFW+I-CLO",
"BATHSHALFLEVEL2"=>"",
"LISTPRICEORIG"=>"239000",
"BATHSHALFLEVEL3"=>"",
"UID"=>"3211078",
"OFFICELIST"=>"FMAB",
"BATHSHALFBASEMENT"=>"",
"STORIESBLDG"=>"",
"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!!!!",
"STREETNUMDISPLAY"=>"8317",
"PROPSUBTYPEDISPLAY"=>"RES-S",
"BATHSHALF"=>"0",
"STYLE"=>"STYRANCH",
"COMMONFEATURES"=>"",
"OFFICESELL_OFFICENAM2"=>"",
"BATHSFULL"=>"3",
"MAPCOORD"=>"none",
"SQFTSOURCE"=>"TAX",
"NUMLAKES"=>"",
"NUMWELLS"=>"",
"NUMPONDS"=>"",
"LOTDESC"=>"LTDSUBDIV"}
mapper = RETS4R::ListingMapper.new
actual = mapper.map(original)
expected = {
:mls => "11322886",
:agent_id =>"000533246",
:rets_updated_at => nil,
:status=>"act",
:list_price =>"239000",
:street_number =>"8317",
:street_direction => "",
:street_name=>"Thompson",
:unit_number =>"",
:zip_code =>"79606-6652",
:city => "Abilene",
:county =>"Taylor",
:square_feet =>"2825",
:living_area => "2",
:baths =>nil,
:beds => "4",
:garage => "PARATTACHE,PAROPENER,PARREAR,PARSIDE",
:year_built => "2005",
}
expected.merge(actual).keys.each{|k| assert_equal expected[k], actual[k], "mismatched on key #{k}"}
end
end
end