Flatisfy is your new companion to ease your search of a new housing :)

test.py 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. # -*- coding: utf-8 -*-
  2. # Copyright(C) 2014 Bezleputh
  3. #
  4. # This file is part of a weboob module.
  5. #
  6. # This weboob module is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU Affero General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This weboob module is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU Affero General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU Affero General Public License
  17. # along with this weboob module. If not, see <http://www.gnu.org/licenses/>.
  18. from weboob.tools.test import BackendTest
  19. from weboob.tools.value import Value
  20. from weboob.capabilities.housing import Query, POSTS_TYPES, ADVERT_TYPES
  21. from weboob.tools.capabilities.housing.housing_test import HousingTest
  22. class LeboncoinTest(BackendTest, HousingTest):
  23. MODULE = 'leboncoin'
  24. FIELDS_ALL_HOUSINGS_LIST = [
  25. "id", "type", "advert_type", "url", "title",
  26. "currency", "utilities", "date", "location", "text"
  27. ]
  28. FIELDS_ANY_HOUSINGS_LIST = [
  29. "area",
  30. "cost",
  31. "price_per_meter",
  32. "photos"
  33. ]
  34. FIELDS_ALL_SINGLE_HOUSING = [
  35. "id", "url", "type", "advert_type", "house_type", "title",
  36. "cost", "currency", "utilities", "date", "location", "text",
  37. "rooms", "details"
  38. ]
  39. FIELDS_ANY_SINGLE_HOUSING = [
  40. "area",
  41. "GES",
  42. "DPE",
  43. "photos",
  44. # Don't test phone as leboncoin API is strongly rate-limited
  45. ]
  46. def setUp(self):
  47. if not self.is_backend_configured():
  48. self.backend.config['advert_type'] = Value(value='a')
  49. self.backend.config['region'] = Value(value='ile_de_france')
  50. def test_leboncoin_rent(self):
  51. query = Query()
  52. query.area_min = 20
  53. query.cost_max = 1500
  54. query.type = POSTS_TYPES.RENT
  55. query.cities = []
  56. for city in self.backend.search_city('paris'):
  57. city.backend = self.backend.name
  58. query.cities.append(city)
  59. if len(query.cities) == 3:
  60. break
  61. self.check_against_query(query)
  62. def test_leboncoin_sale(self):
  63. query = Query()
  64. query.area_min = 20
  65. query.type = POSTS_TYPES.SALE
  66. query.cities = []
  67. for city in self.backend.search_city('paris'):
  68. city.backend = self.backend.name
  69. query.cities.append(city)
  70. if len(query.cities) == 3:
  71. break
  72. self.check_against_query(query)
  73. def test_leboncoin_furnished_rent(self):
  74. query = Query()
  75. query.area_min = 20
  76. query.cost_max = 1500
  77. query.type = POSTS_TYPES.FURNISHED_RENT
  78. query.cities = []
  79. for city in self.backend.search_city('paris'):
  80. city.backend = self.backend.name
  81. query.cities.append(city)
  82. if len(query.cities) == 3:
  83. break
  84. self.check_against_query(query)
  85. def test_leboncoin_professional(self):
  86. query = Query()
  87. query.area_min = 20
  88. query.cost_max = 900
  89. query.type = POSTS_TYPES.RENT
  90. query.advert_types = [ADVERT_TYPES.PROFESSIONAL]
  91. query.cities = []
  92. for city in self.backend.search_city('paris'):
  93. city.backend = self.backend.name
  94. query.cities.append(city)
  95. self.check_against_query(query)