Commit cccff49e authored by Gautier P's avatar Gautier P Committed by Vincent A

[logicimmo] Fix housing detection

parent 7f8d7a6d
Pipeline #3531 passed with stages
in 15 minutes and 58 seconds
......@@ -90,7 +90,7 @@ class HousingPage(HTMLPage):
obj_advert_type = ADVERT_TYPES.PROFESSIONAL
def obj_house_type(self):
house_type = CleanText('.//div[has-class("offer-type")]')(self).lower()
house_type = CleanText('.//h2[@class="offerMainFeatures"]/div')(self).lower()
if house_type == "appartement":
return HOUSE_TYPES.APART
elif house_type == "maison":
......@@ -104,10 +104,16 @@ class HousingPage(HTMLPage):
obj_title = CleanText(CleanHTML('//meta[@itemprop="name"]/@content'))
obj_area = CleanDecimal(Regexp(CleanText(CleanHTML('//meta[@itemprop="name"]/@content')),
'(.*?)(\d*) m\xb2(.*?)', '\\2', default=NotAvailable),
'(.*?)(\d*)m\xb2(.*?)', '\\2', default=NotAvailable),
default=NotAvailable)
obj_rooms = CleanDecimal('//div[has-class("offer-info")]//span[has-class("offer-rooms-number")]',
default=NotAvailable)
obj_rooms = CleanDecimal(
Regexp(
CleanText('.//h2[@class="offerMainFeatures"]'),
'(\d) pièce',
default=NotAvailable
),
default=NotAvailable
)
obj_cost = CleanDecimal('//*[@itemprop="price"]', default=0)
obj_currency = Currency(
'//*[@itemprop="price"]'
......@@ -125,7 +131,7 @@ class HousingPage(HTMLPage):
u'.* Mis à jour : (\d{2}/\d{2}/\d{4}).*'),
dayfirst=True)
obj_text = CleanHTML('//div[has-class("offer-description-text")]/meta[@itemprop="description"]/@content')
obj_location = CleanText('//*[@itemprop="address"]')
obj_location = CleanText('//div[@itemprop="address"]')
obj_station = CleanText(
'//div[has-class("offer-description-metro")]',
default=NotAvailable
......@@ -265,7 +271,7 @@ class SearchPage(HTMLPage):
obj_advert_type = ADVERT_TYPES.PROFESSIONAL
def obj_house_type(self):
house_type = CleanText('.//div[has-class("offer-details-type")]/a')(self).split(' ')[0].lower()
house_type = CleanText('.//div[has-class("offer-details-caracteristik")]/meta[@itemprop="name"]/@content')(self).lower()
if house_type == "appartement":
return HOUSE_TYPES.APART
elif house_type == "maison":
......
......@@ -93,7 +93,7 @@ class HousingTest(object):
return results
def check_single_housing_all(self, housing,
type, house_types, advert_type):
type, house_type, advert_type):
for field in self.FIELDS_ALL_SINGLE_HOUSING:
self.assertNotEmpty(housing, field)
if 'type' in self.FIELDS_ALL_SINGLE_HOUSING:
......@@ -106,8 +106,8 @@ class HousingTest(object):
else:
self.assertEqual(housing.type, type)
if 'house_type' in self.FIELDS_ALL_SINGLE_HOUSING:
if not empty(house_types):
self.assertEqual(housing.house_type, house_types)
if not empty(house_type):
self.assertEqual(housing.house_type, house_type)
else:
self.assertNotEmpty(housing, 'house_type')
if 'advert_type' in self.FIELDS_ALL_SINGLE_HOUSING:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment