diff --git a/flatisfy/test_files/124910113@seloger.jpg b/flatisfy/test_files/124910113@seloger.jpg new file mode 100644 index 0000000..bb95551 Binary files /dev/null and b/flatisfy/test_files/124910113@seloger.jpg differ diff --git a/flatisfy/test_files/124910113@seloger.json b/flatisfy/test_files/124910113@seloger.json new file mode 100644 index 0000000..122aefa --- /dev/null +++ b/flatisfy/test_files/124910113@seloger.json @@ -0,0 +1,67 @@ +{ + "id": "124910113@seloger", + "url": "http://www.seloger.com/annonces/achat/appartement/rennes-35/maurepas-patton/124910113.htm?p=", + "title": "Appartement 3 pi\u00e8ces 65m\u00b2 - Rennes", + "area": 65, + "cost": 145275, + "price_per_meter": 2235, + "currency": "\u20ac", + "utilities": "", + "date": "2018-01-20T02:09:00", + "location": "225 RUE DE FOUGERES Rennes (35700)", + "station": "", + "text": "Rennes en exclusivit\u00e9 rue de Foug\u00e8res - Grand Appartement 3 pi\u00e8ces avec Balcon dans une copropri\u00e9t\u00e9 avec ascenseur - Travaux \u00e0 pr\u00e9voir - 2 chambres - Cave et garage.", + "phone": null, + "photos": [{ + "id": "17b055i7hici1wxr951unlycfs5rhai73sbnnv2ki.jpg", + "url": "https://v.seloger.com/s/cdn/x/visuels/1/7/b/0/17b055i7hici1wxr951unlycfs5rhai73sbnnv2ki.jpg", + "data": null + }, { + "id": "1s5t0lal78twswu22mahad9vtc75y3s5utuit2yte.jpg", + "url": "https://v.seloger.com/s/cdn/x/visuels/1/s/5/t/1s5t0lal78twswu22mahad9vtc75y3s5utuit2yte.jpg", + "data": null + }, { + "id": "282rrcholht5full009yb8a5k1xe2jx0yiwtqyite.jpg", + "url": "https://v.seloger.com/s/cdn/x/visuels/2/8/2/r/282rrcholht5full009yb8a5k1xe2jx0yiwtqyite.jpg", + "data": null + }, { + "id": "0wskjpe0511ak2ynzxual2qa0fp3bmz3ccaoqc5oi.jpg", + "url": "https://v.seloger.com/s/cdn/x/visuels/0/w/s/k/0wskjpe0511ak2ynzxual2qa0fp3bmz3ccaoqc5oi.jpg", + "data": null + }, { + "id": "0kfne4iignt712pcunkcu2u9e497vt6oi11l30hxe.jpg", + "url": "https://v.seloger.com/s/cdn/x/visuels/0/k/f/n/0kfne4iignt712pcunkcu2u9e497vt6oi11l30hxe.jpg", + "data": null + }, { + "id": "1jvyyiua1l843w1ohymxcbs9gj9zxvtfiajjfvwle.jpg", + "url": "https://v.seloger.com/s/cdn/x/visuels/1/j/v/y/1jvyyiua1l843w1ohymxcbs9gj9zxvtfiajjfvwle.jpg", + "data": null + }, { + "id": "1ihj8ufsfdxgfecq03c154hcsj5jo5ysts29wjnia.jpg", + "url": "https://v.seloger.com/s/cdn/x/visuels/1/i/h/j/1ihj8ufsfdxgfecq03c154hcsj5jo5ysts29wjnia.jpg", + "data": null + }, { + "id": "1g9yb1xe0bc8se0w8jys8ouiscpwer6y6lccd1ltu.jpg", + "url": "https://v.seloger.com/s/cdn/x/visuels/1/g/9/y/1g9yb1xe0bc8se0w8jys8ouiscpwer6y6lccd1ltu.jpg", + "data": null + }], + "rooms": 3, + "bedrooms": 2, + "details": { + "Box": "1", + "Pi\u00e8ces": "3", + "Etage": "1", + "Reference": "MT0135140", + "Chambres": "2", + "Salle d'eau": "1", + "Cave": "", + "Ascenseur": "", + "Surface": "65 m\u00b2", + "Balcon": "1", + "Travaux \u00c0 Pr\u00e9voir": "", + "Ann\u00e9e de construction": "1968", + "Toilettes S\u00e9par\u00e9es": "", + "Etages": "6", + "Toilette": "1" + } +} diff --git a/flatisfy/test_files/13783671@explorimmo.jpg b/flatisfy/test_files/13783671@explorimmo.jpg new file mode 100644 index 0000000..02bf5ac Binary files /dev/null and b/flatisfy/test_files/13783671@explorimmo.jpg differ diff --git a/flatisfy/test_files/13783671@explorimmo.json b/flatisfy/test_files/13783671@explorimmo.json new file mode 100644 index 0000000..7eaa74a --- /dev/null +++ b/flatisfy/test_files/13783671@explorimmo.json @@ -0,0 +1,44 @@ +{ + "id": "13783671@explorimmo", + "url": "http://www.explorimmo.com/annonce-13783671.html", + "title": "Vente appartement 3 pi\u00e8ces 65 m2", + "area": 65, + "cost": 145275, + "price_per_meter": 2235, + "currency": "EUR", + "utilities": "H.C.", + "date": "2017-11-10T02:04:00", + "location": "225 RUE DE FOUGERES Rennes 35700", + "station": null, + "text": "Rennes en exclusivit\u00e9 rue de Foug\u00e8res - Grand Appartement 3 pi\u00e8ces avec Balcon\ndans une copropri\u00e9t\u00e9 avec ascenseur - Travaux \u00e0 pr\u00e9voir - 2 chambres - Cave et\ngarage\n\n", + "phone": null, + "photos": [{ + "id": "cb10f556708c4e858c1a45ec1dfda623.jpg", + "url": "http://thbr.figarocms.net/images/AXuL6XMCphsRrTYttb7yR2W3CCg=/560x420/filters:fill(f6f6f6):quality(80):strip_icc()/cb10f556708c4e858c1a45ec1dfda623.jpg", + "data": null + }, { + "id": "e2696eacce2d487e99e88c2b945cee34.jpg", + "url": "http://thbr.figarocms.net/images/0Va3M6bf1eFkJJzPXC--QIc6WTo=/560x420/filters:fill(f6f6f6):quality(80):strip_icc()/e2696eacce2d487e99e88c2b945cee34.jpg", + "data": null + }], + "rooms": 3, + "bedrooms": 2, + "details": { + "available": true, + "heatingType": "", + "agency": "NEXITY LAMY, 6 avenue Jean Janvier, 35000, Rennes", + "bathrooms": 0, + "exposure": "Non pr\u00e9cis\u00e9", + "floor": "1", + "energy": "E", + "bedrooms": 2, + "greenhouseGasEmission": null, + "isFurnished": false, + "rooms": 3, + "fees": 0.0, + "creationDate": 1507712100000, + "agencyFees": 0.0, + "availabilityDate": null, + "guarantee": 0.0 + } +} diff --git a/flatisfy/tests.py b/flatisfy/tests.py index dd35d39..becfe20 100644 --- a/flatisfy/tests.py +++ b/flatisfy/tests.py @@ -225,6 +225,11 @@ class TestPhotos(unittest.TestCase): TestPhotos.HASH_THRESHOLD )) + def test_matching_cropped_photos(self): + """ + Compares two matching photos with one being cropped. + """ + # Fixme: the image hash treshold should be 10 ideally self.assertTrue(duplicates.compare_photos( {"url": TESTS_DATA_DIR + "vertical.jpg"}, {"url": TESTS_DATA_DIR + "vertical-cropped.jpg"}, @@ -232,6 +237,13 @@ class TestPhotos(unittest.TestCase): 20 )) + # Fixme: the image hash treshold should be 10 ideally + self.assertTrue(duplicates.compare_photos( + {"url": TESTS_DATA_DIR + "13783671@explorimmo.jpg"}, + {"url": TESTS_DATA_DIR + "124910113@seloger.jpg"}, + TestPhotos.IMAGE_CACHE, + 20 + )) class TestDuplicates(unittest.TestCase): """ @@ -404,6 +416,20 @@ class TestDuplicates(unittest.TestCase): score >= TestDuplicates.DUPLICATES_MIN_SCORE_WITH_PHOTOS ) + # Different number of photos, and some are cropped + flats = self.load_files( + "124910113@seloger", + "13783671@explorimmo" + ) + + score = duplicates.get_duplicate_score( + flats[0], flats[1], + TestDuplicates.IMAGE_CACHE, 20 + ) + self.assertTrue( + score >= TestDuplicates.DUPLICATES_MIN_SCORE_WITH_PHOTOS + ) + # Same flat, different agencies, texts and photos flats = self.load_files( "122509451@seloger",