Fix and improve immowelt/immonet provider (#194)

* Fix and improve immowelt provider

* Add description to immonet provider

* Fix tests and improve readability
This commit is contained in:
Thomas Brockmöller
2025-09-27 09:42:08 +02:00
committed by GitHub
parent 9387de1cd9
commit 702ffabc1a
4 changed files with 47 additions and 47 deletions

View File

@@ -29,6 +29,7 @@ const config = {
address: 'div[data-testid="cardmfe-description-box-address"] | trim', address: 'div[data-testid="cardmfe-description-box-address"] | trim',
image: 'div[data-testid="cardmfe-picture-box-test-id"] img@src', image: 'div[data-testid="cardmfe-picture-box-test-id"] img@src',
link: 'button@data-base', link: 'button@data-base',
description: 'div[data-testid="cardmfe-description-text-test-id"] | trim',
}, },
normalize: normalize, normalize: normalize,
filter: applyBlacklist, filter: applyBlacklist,

View File

@@ -26,8 +26,9 @@ const config = {
size: 'div[data-testid="cardmfe-keyfacts-testid"] | removeNewline | trim', size: 'div[data-testid="cardmfe-keyfacts-testid"] | removeNewline | trim',
title: 'div[data-testid="cardmfe-description-box-text-test-id"] > div:nth-of-type(2)', title: 'div[data-testid="cardmfe-description-box-text-test-id"] > div:nth-of-type(2)',
link: 'a@href', link: 'a@href',
description: 'div[data-testid="cardmfe-description-text-test-id"] > div:nth-of-type(2) | removeNewline | trim',
address: 'div[data-testid="cardmfe-description-box-address"] | removeNewline | trim', address: 'div[data-testid="cardmfe-description-box-address"] | removeNewline | trim',
image: 'div[data-testid="cardMfe-card-pictureBox-opacity"] img@src', image: 'div[data-testid="cardmfe-picture-box-opacity-layer-test-id"] img@src',
}, },
normalize: normalize, normalize: normalize,
filter: applyBlacklist, filter: applyBlacklist,

View File

@@ -8,31 +8,30 @@ describe('#immonet testsuite()', () => {
after(() => { after(() => {
similarityCache.stopCacheCleanup(); similarityCache.stopCacheCleanup();
}); });
provider.init(providerConfig.immonet, [], []);
it('should test immonet provider', async () => { it('should test immonet provider', async () => {
const Fredy = await mockFredy(); const Fredy = await mockFredy();
return await new Promise((resolve) => { provider.init(providerConfig.immonet, [], []);
const fredy = new Fredy(provider.config, null, provider.metaInformation.id, 'immonet', similarityCache);
fredy.execute().then((listing) => {
expect(listing).to.be.a('array');
const notificationObj = get();
expect(notificationObj).to.be.a('object');
expect(notificationObj.serviceName).to.equal('immonet');
notificationObj.payload.forEach((notify) => {
/** check the actual structure **/
expect(notify.id).to.be.a('string');
expect(notify.price).to.be.a('string');
expect(notify.size).to.be.a('string');
expect(notify.title).to.be.a('string');
expect(notify.link).to.be.a('string');
expect(notify.address).to.be.a('string');
expect(notify.size).that.does.include('m²'); const fredy = new Fredy(provider.config, null, provider.metaInformation.id, 'immonet', similarityCache);
expect(notify.title).to.be.not.empty; const listing = await fredy.execute();
expect(notify.address).to.be.not.empty;
}); expect(listing).to.be.a('array');
resolve(); const notificationObj = get();
}); expect(notificationObj).to.be.a('object');
expect(notificationObj.serviceName).to.equal('immonet');
notificationObj.payload.forEach((notify) => {
/** check the actual structure **/
expect(notify.id).to.be.a('string');
expect(notify.price).to.be.a('string');
expect(notify.size).to.be.a('string');
expect(notify.title).to.be.a('string');
expect(notify.link).to.be.a('string');
expect(notify.address).to.be.a('string');
/** check the values if possible **/
expect(notify.size).that.does.include('m²');
expect(notify.title).to.be.not.empty;
expect(notify.address).to.be.not.empty;
}); });
}); });
}); });

View File

@@ -8,33 +8,32 @@ describe('#immowelt testsuite()', () => {
after(() => { after(() => {
similarityCache.stopCacheCleanup(); similarityCache.stopCacheCleanup();
}); });
it('should test immowelt provider', async () => { it('should test immowelt provider', async () => {
const Fredy = await mockFredy(); const Fredy = await mockFredy();
provider.init(providerConfig.immowelt, [], []); provider.init(providerConfig.immowelt, [], []);
return await new Promise((resolve) => {
const fredy = new Fredy(provider.config, null, provider.metaInformation.id, 'immowelt', similarityCache); const fredy = new Fredy(provider.config, null, provider.metaInformation.id, 'immowelt', similarityCache);
fredy.execute().then((listing) => { const listing = await fredy.execute();
expect(listing).to.be.a('array');
const notificationObj = get(); expect(listing).to.be.a('array');
expect(notificationObj).to.be.a('object'); const notificationObj = get();
expect(notificationObj.serviceName).to.equal('immowelt'); expect(notificationObj).to.be.a('object');
notificationObj.payload.forEach((notify) => { expect(notificationObj.serviceName).to.equal('immowelt');
/** check the actual structure **/ notificationObj.payload.forEach((notify) => {
expect(notify.id).to.be.a('string'); /** check the actual structure **/
expect(notify.price).to.be.a('string'); expect(notify.id).to.be.a('string');
expect(notify.title).to.be.a('string'); expect(notify.price).to.be.a('string');
expect(notify.link).to.be.a('string'); expect(notify.title).to.be.a('string');
expect(notify.address).to.be.a('string'); expect(notify.link).to.be.a('string');
/** check the values if possible **/ expect(notify.address).to.be.a('string');
if (notify.size != null && notify.size.trim().toLowerCase() !== 'k.a.') { /** check the values if possible **/
expect(notify.size).that.does.include('m²'); if (notify.size != null && notify.size.trim().toLowerCase() !== 'k.a.') {
} expect(notify.size).that.does.include('m²');
expect(notify.title).to.be.not.empty; }
expect(notify.link).that.does.include('https://www.immowelt.de'); expect(notify.title).to.be.not.empty;
expect(notify.address).to.be.not.empty; expect(notify.link).that.does.include('https://www.immowelt.de');
}); expect(notify.address).to.be.not.empty;
resolve();
});
}); });
}); });
}); });