@@ -57,6 +57,7 @@ def test_row_convert_to_out(self):
5757 "type" : "Feature" ,
5858 "properties" : {
5959 "unit" : "" ,
60+ "building_name" : "" ,
6061 "number" : "123" ,
6162 "street" : "MAPLE LN" ,
6263 "city" : "" ,
@@ -375,6 +376,7 @@ def test_transform_and_convert(self):
375376 "region" : "" ,
376377 "district" : "" ,
377378 "postcode" : "" ,
379+ "building_name" : "" ,
378380 'hash' : 'b3af08e447c7ed16' ,
379381 "id" : ""
380382 },
@@ -405,6 +407,7 @@ def test_transform_and_convert(self):
405407 "region" : "" ,
406408 "district" : "" ,
407409 "postcode" : "" ,
410+ "building_name" : "" ,
408411 "id" : "" ,
409412 'hash' : 'd4681f7e1d34e6ed'
410413 },
@@ -453,6 +456,7 @@ def test_transform_and_convert(self):
453456 "district" : "" ,
454457 "postcode" : "" ,
455458 "id" : "" ,
459+ "building_name" : "" ,
456460 'hash' : '591d7970b5753b0d'
457461 }
458462 }, r )
@@ -491,6 +495,7 @@ def test_transform_and_convert(self):
491495 "district" : "" ,
492496 "postcode" : "" ,
493497 "id" : "" ,
498+ "building_name" : "" ,
494499 'hash' : '7b1dc0b74cbc0162'
495500 }
496501 }, r )
@@ -510,6 +515,44 @@ def test_row_canonicalize_unit_and_number(self):
510515 r = row_canonicalize_unit_and_number ({}, {"number" : a , "street" : "" , "unit" : "" })
511516 self .assertEqual (e , r ["number" ])
512517
518+ def test_row_canonicalize_building_name (self ):
519+ r = row_canonicalize_unit_and_number ({}, {"number" : "" , "street" : " OAK DR." , "unit" : "" , "building_name" : " Rose Cottage " })
520+ self .assertEqual ("Rose Cottage" , r ["building_name" ])
521+
522+ # Missing building_name canonicalizes to empty string
523+ r = row_canonicalize_unit_and_number ({}, {"number" : "" , "street" : "OAK DR." , "unit" : "" })
524+ self .assertEqual ("" , r ["building_name" ])
525+
526+ def test_row_transform_and_convert_building_name (self ):
527+ "A BUILDING_NAME source column flows through to the output building_name attribute"
528+ d = SourceConfig (dict ({
529+ "schema" : 2 ,
530+ "layers" : {
531+ "addresses" : [{
532+ "name" : "default" ,
533+ "conform" : {
534+ "street" : "STREET" ,
535+ "number" : "NUMBER" ,
536+ "building_name" : "BUILDING_NAME" ,
537+ "lon" : "LON" ,
538+ "lat" : "LAT"
539+ }
540+ }]
541+ }
542+ }), "addresses" , "default" )
543+
544+ feat = row_transform_and_convert (d , {
545+ "STREET" : "HIGH STREET" ,
546+ "NUMBER" : "" ,
547+ "BUILDING_NAME" : "Rose Cottage" ,
548+ "LON" : "-1.25" ,
549+ "LAT" : "51.75"
550+ })
551+
552+ self .assertEqual ("Rose Cottage" , feat ["properties" ]["building_name" ])
553+ self .assertEqual ("" , feat ["properties" ]["number" ])
554+ self .assertEqual ("HIGH STREET" , feat ["properties" ]["street" ])
555+
513556 def test_row_canonicalize_street_and_no_number (self ):
514557 r = row_canonicalize_unit_and_number ({}, {"number" : None , "street" : " OAK DR." , "unit" : None })
515558 self .assertEqual ("" , r ["number" ])
0 commit comments