Adding new Admin UI. Updating Fredy to V3.0.0 as it has been a large rewrite. Thanks for all contributions and help on the way!
This commit is contained in:
Christian Kellner
2021-01-21 16:09:23 +01:00
committed by GitHub
parent 8185bfe818
commit b2847f6834
124 changed files with 9768 additions and 1495 deletions

View File

@@ -8,5 +8,5 @@ module.exports = {
get: () => {
return this._tmpStore;
}
},
};

View File

@@ -1,11 +1,5 @@
const db = {};
exports.init = () => {
return new Promise(resolve => {
resolve();
});
};
exports.setKnownListings = (jobKey, providerId, listings) => {
if (!Array.isArray(listings)) throw Error('Not a valid array');
@@ -15,38 +9,3 @@ exports.setKnownListings = (jobKey, providerId, listings) => {
exports.getKnownListings = (jobKey, providerId) => {
return db[providerId] || [];
};
exports.setNumberOfTotalFoundProviderListings = () => {
/*noop*/
};
exports.getForTesting = () => {
return db;
};
/*
class Store {
constructor(name) {
this._name = name;
this._db = {};
}
get warmup() {
this._db = {};
return new Promise(resolve => resolve());
}
set knownListings(value) {
if (!Array.isArray(value)) throw Error('Not a valid array');
return new Promise(resolve => {
this._db[this._name] = value;
resolve(value);
});
}
get knownListings() {
return this._db[this._name] || [];
}
}
module.exports = Store;
*/

View File

@@ -1,29 +1,31 @@
const mockNotification = require('../mocks/mockNotification');
const mockConfig = require('../../conf/forTesting/config.multi.test');
const providerConfig = require('./testProvider.json');
const mockStore = require('../mocks/mockStore');
const proxyquire = require('proxyquire').noCallThru();
const expect = require('chai').expect;
const provider = require('../../lib/provider/einsAImmobilien');
describe('#einsAImmobilien testsuite()', () => {
provider.init(mockConfig.jobs.test1.provider.einsAImmobilien, [], []);
provider.init(providerConfig.einsAImmobilien, [], []);
const Fredy = proxyquire('../../lib/FredyRuntime', {
'./services/store': mockStore,
'./notification/notify': mockNotification
'./services/storage/listingsStorage': {
...mockStore,
},
'./notification/notify': mockNotification,
});
it('should test einsAImmobilien provider', async () => {
return await new Promise(resolve => {
const fredy = new Fredy(provider.config, null, provider.id(), 'test1');
fredy.execute().then(() => {
const immonetDbContent = fredy._getStore();
expect(immonetDbContent.einsAImmobilien).to.be.a('array');
return await new Promise((resolve) => {
const fredy = new Fredy(provider.config, null, provider.metaInformation.id, 'test1');
fredy.execute().then((listings) => {
expect(listings).to.be.a('array');
const notificationObj = mockNotification.get();
expect(notificationObj).to.be.a('object');
expect(notificationObj.serviceName).to.equal('einsAImmobilien');
notificationObj.payload.forEach((notify, idx) => {
notificationObj.payload.forEach((notify) => {
/** check the actual structure **/
expect(notify.id).to.be.a('number');
expect(notify.price).to.be.a('string');
@@ -32,7 +34,6 @@ describe('#einsAImmobilien testsuite()', () => {
expect(notify.link).to.be.a('string');
/** check the values if possible **/
expect(notify.id).to.equal(immonetDbContent.einsAImmobilien[idx]);
expect(notify.price).that.does.include('EUR');
expect(notify.size).to.be.not.empty;
expect(notify.title).to.be.not.empty;

View File

@@ -1,30 +1,30 @@
const mockNotification = require('../mocks/mockNotification');
const mockConfig = require('../../conf/forTesting/config.multi.test');
const providerConfig = require('./testProvider.json');
const mockStore = require('../mocks/mockStore');
const proxyquire = require('proxyquire').noCallThru();
const expect = require('chai').expect;
const provider = require('../../lib/provider/immonet');
describe('#immonet testsuite()', () => {
provider.init(mockConfig.jobs.test1.provider.immonet, [], []);
provider.init(providerConfig.immonet, [], []);
const Fredy = proxyquire('../../lib/FredyRuntime', {
'./services/store': mockStore,
'./notification/notify': mockNotification
'./services/storage/listingsStorage': {
...mockStore,
},
'./notification/notify': mockNotification,
});
it('should test immonet provider', async () => {
return await new Promise(resolve => {
const fredy = new Fredy(provider.config, null, provider.id(), 'test1');
fredy.execute().then(() => {
const immonetDbContent = fredy._getStore();
expect(immonetDbContent.immonet).to.be.a('array');
return await new Promise((resolve) => {
const fredy = new Fredy(provider.config, null, provider.metaInformation.id, 'test1');
fredy.execute().then((listing) => {
expect(listing).to.be.a('array');
const notificationObj = mockNotification.get();
expect(notificationObj).to.be.a('object');
expect(notificationObj.serviceName).to.equal('immonet');
notificationObj.payload.forEach((notify, idx) => {
notificationObj.payload.forEach((notify) => {
/** check the actual structure **/
expect(notify.id).to.be.a('number');
expect(notify.price).to.be.a('string');
@@ -34,7 +34,6 @@ describe('#immonet testsuite()', () => {
expect(notify.address).to.be.a('string');
/** check the values if possible **/
expect(notify.id).to.equal(immonetDbContent.immonet[idx]);
expect(notify.price).that.does.include('€');
expect(notify.size).that.does.include('m²');
expect(notify.title).to.be.not.empty;

View File

@@ -1,47 +0,0 @@
const mockNotification = require('../mocks/mockNotification');
const mockConfig = require('../../conf/forTesting/config.multi.test');
const proxyquire = require('proxyquire').noCallThru();
const mockStore = require('../mocks/mockStore');
const expect = require('chai').expect;
const provider = require('../../lib/provider/immoscout');
describe('#immoscout testsuite()', () => {
provider.init(mockConfig.jobs.test1.provider.immoscout, [], []);
const Fredy = proxyquire('../../lib/FredyRuntime', {
'./services/store': mockStore,
'./notification/notify': mockNotification
});
it('should test immoscout provider', async () => {
return await new Promise(resolve => {
const fredy = new Fredy(provider.config, null, provider.id(), 'test1');
fredy.execute().then(() => {
const immoscoutDbContent = fredy._getStore();
expect(immoscoutDbContent.immoscout).to.be.a('array');
const notificationObj = mockNotification.get();
expect(notificationObj).to.be.a('object');
expect(notificationObj.serviceName).to.equal('immoscout');
notificationObj.payload.forEach((notify, idx) => {
/** check the actual structure **/
expect(notify.id).to.be.a('number');
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.id).to.equal(immoscoutDbContent.immoscout[idx]);
expect(notify.price).that.does.include('€');
expect(notify.size).that.does.include('m²');
expect(notify.title).to.be.not.empty;
expect(notify.link).that.does.include('https://www.immobilienscout24.de');
expect(notify.address).to.be.not.empty;
});
resolve();
});
});
});
});

View File

@@ -1,5 +1,5 @@
const mockNotification = require('../mocks/mockNotification');
const mockConfig = require('../../conf/forTesting/config.multi.test');
const providerConfig = require('./testProvider.json');
const mockStore = require('../mocks/mockStore');
const proxyquire = require('proxyquire').noCallThru();
const expect = require('chai').expect;
@@ -7,23 +7,24 @@ const provider = require('../../lib/provider/immowelt');
describe('#immowelt testsuite()', () => {
it('should test immowelt provider', async () => {
provider.init(mockConfig.jobs.test1.provider.immowelt, [], []);
provider.init(providerConfig.immowelt, [], []);
const Fredy = proxyquire('../../lib/FredyRuntime', {
'./services/store': mockStore,
'./notification/notify': mockNotification
'./services/storage/listingsStorage': {
...mockStore,
},
'./notification/notify': mockNotification,
});
return await new Promise(resolve => {
const fredy = new Fredy(provider.config, null, provider.id(), 'test1');
fredy.execute().then(() => {
const immoweltDbContent = fredy._getStore();
expect(immoweltDbContent.immowelt).to.be.a('array');
return await new Promise((resolve) => {
const fredy = new Fredy(provider.config, null, provider.metaInformation.id, 'test1');
fredy.execute().then((listing) => {
expect(listing).to.be.a('array');
const notificationObj = mockNotification.get();
expect(notificationObj).to.be.a('object');
expect(notificationObj.serviceName).to.equal('immowelt');
notificationObj.payload.forEach((notify, idx) => {
notificationObj.payload.forEach((notify) => {
/** check the actual structure **/
expect(notify.id).to.be.a('number');
expect(notify.price).to.be.a('string');
@@ -33,7 +34,6 @@ describe('#immowelt testsuite()', () => {
expect(notify.address).to.be.a('string');
/** check the values if possible **/
expect(notify.id).to.equal(immoweltDbContent.immowelt[idx]);
expect(notify.price).that.does.include('€');
if (notify.size.trim().toLowerCase() !== 'k.a.') {
expect(notify.size).that.does.include('m²');

View File

@@ -1,44 +0,0 @@
const mockNotification = require('../mocks/mockNotification');
const mockConfig = require('../../conf/forTesting/config.multi.test');
const mockStore = require('../mocks/mockStore');
const proxyquire = require('proxyquire').noCallThru();
const expect = require('chai').expect;
const provider = require('../../lib/provider/kalaydo');
describe('#kalaydo testsuite()', () => {
provider.init(mockConfig.jobs.test1.provider.kalaydo, [], []);
const Fredy = proxyquire('../../lib/FredyRuntime', {
'./services/store': mockStore,
'./notification/notify': mockNotification
});
it('should test kalaydo provider', async () => {
return await new Promise(resolve => {
const fredy = new Fredy(provider.config, null, provider.id(), 'test1');
fredy.execute().then(() => {
const kalaydoDbContent = fredy._getStore();
expect(kalaydoDbContent.kalaydo).to.be.a('array');
const notificationObj = mockNotification.get();
expect(notificationObj).to.be.a('object');
expect(notificationObj.serviceName).to.equal('kalaydo');
notificationObj.payload.forEach((notify, idx) => {
/** 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');
/** check the values if possible **/
expect(notify.id).to.equal(kalaydoDbContent.kalaydo[idx]);
expect(notify.title).to.be.not.empty;
expect(notify.link).that.does.include('https://www.kalaydo.de');
});
resolve();
});
});
});
});

View File

@@ -1,5 +1,5 @@
const mockNotification = require('../mocks/mockNotification');
const mockConfig = require('../../conf/forTesting/config.multi.test');
const providerConfig = require('./testProvider.json');
const mockStore = require('../mocks/mockStore');
const proxyquire = require('proxyquire').noCallThru();
const expect = require('chai').expect;
@@ -7,23 +7,24 @@ const provider = require('../../lib/provider/kleinanzeigen');
describe('#kleinanzeigen testsuite()', () => {
it('should test kleinanzeigen provider', async () => {
provider.init(mockConfig.jobs.test1.provider.kleinanzeigen, [], []);
provider.init(providerConfig.kleinanzeigen, [], []);
const Fredy = proxyquire('../../lib/FredyRuntime', {
'./services/store': mockStore,
'./notification/notify': mockNotification
'./services/storage/listingsStorage': {
...mockStore,
},
'./notification/notify': mockNotification,
});
return await new Promise(resolve => {
const fredy = new Fredy(provider.config, null, provider.id(), 'test1');
fredy.execute().then(() => {
const kleinanzeigenDbContent = fredy._getStore();
expect(kleinanzeigenDbContent.kleinanzeigen).to.be.a('array');
return await new Promise((resolve) => {
const fredy = new Fredy(provider.config, null, provider.metaInformation.id, 'test1');
fredy.execute().then((listing) => {
expect(listing).to.be.a('array');
const notificationObj = mockNotification.get();
expect(notificationObj).to.be.a('object');
expect(notificationObj.serviceName).to.equal('kleinanzeigen');
notificationObj.payload.forEach((notify, idx) => {
notificationObj.payload.forEach((notify) => {
/** check the actual structure **/
expect(notify.id).to.be.a('number');
expect(notify.price).to.be.a('string');
@@ -33,7 +34,6 @@ describe('#kleinanzeigen testsuite()', () => {
expect(notify.address).to.be.a('string');
/** check the values if possible **/
expect(notify.id).to.equal(kleinanzeigenDbContent.kleinanzeigen[idx]);
expect(notify.title).to.be.not.empty;
expect(notify.link).that.does.include('https://www.ebay-kleinanzeigen.de');
expect(notify.address).to.be.not.empty;

View File

@@ -1,28 +1,29 @@
const mockNotification = require('../mocks/mockNotification');
const mockConfig = require('../../conf/forTesting/config.multi.test');
const providerConfig = require('./testProvider.json');
const mockStore = require('../mocks/mockStore');
const proxyquire = require('proxyquire').noCallThru();
const expect = require('chai').expect;
const provider = require('../../lib/provider/neubauKompass');
describe('#neubauKompass testsuite()', () => {
provider.init(mockConfig.jobs.test1.provider.neubauKompass, [], []);
provider.init(providerConfig.neubauKompass, [], []);
const Fredy = proxyquire('../../lib/FredyRuntime', {
'./services/store': mockStore,
'./notification/notify': mockNotification
'./services/storage/listingsStorage': {
...mockStore,
},
'./notification/notify': mockNotification,
});
it('should test neubauKompass provider', async () => {
return await new Promise(resolve => {
const fredy = new Fredy(provider.config, null, provider.id(), 'test1');
fredy.execute().then(() => {
const neubauKompassDbContent = fredy._getStore();
expect(neubauKompassDbContent.neubauKompass).to.be.a('array');
return await new Promise((resolve) => {
const fredy = new Fredy(provider.config, null, provider.metaInformation.id, 'test1');
fredy.execute().then((listing) => {
expect(listing).to.be.a('array');
const notificationObj = mockNotification.get();
expect(notificationObj.serviceName).to.equal('neubauKompass');
notificationObj.payload.forEach((notify, idx) => {
notificationObj.payload.forEach((notify) => {
expect(notify).to.be.a('object');
/** check the actual structure **/
@@ -32,7 +33,6 @@ describe('#neubauKompass testsuite()', () => {
expect(notify.address).to.be.a('string');
/** check the values if possible **/
expect(notify.id).to.equal(neubauKompassDbContent.neubauKompass[idx]);
expect(notify.title).to.be.not.empty;
expect(notify.link).that.does.include('https://www.neubaukompass.de');
expect(notify.address).to.be.not.empty;

View File

@@ -0,0 +1,31 @@
{
"einsAImmobilien": {
"url": "https://www.1a-immobilienmarkt.de/suchen/duesseldorf/wohnung-kaufen.html?search=yes&cfid=98b39c7e-b403-4764-8f3c-57bf590923d0&data_hash=f46f89548257740094dd708996adcd68&sort_type=newest",
"enabled": true,
"id": "einsAImmobilien"
},
"immonet": {
"url": "https://www.immonet.de/immobiliensuche/sel.do?pageoffset=1&listsize=100&objecttype=1&locationname=Düsseldorf&acid=&actype=&district=8717&district=8718&district=8719&district=8720&district=8721&district=8723&district=8724&district=8725&district=8727&district=8728&district=8729&district=8730&district=8731&district=8732&district=8733&district=8737&district=8738&district=8741&district=8745&district=8747&district=8750&district=8752&district=8754&district=8755&district=8756&district=8759&district=8760&district=8761&district=8763&district=8764&district=8765&ajaxIsRadiusActive=false&sortby=19&suchart=1&radius=0&pcatmtypes=1_1&pCatMTypeStoragefield=&parentcat=1&marketingtype=1&fromprice=&toprice=420000&fromarea=90&toarea=&fromplotarea=&toplotarea=&fromrooms=3&torooms=&objectcat=225&objectcat=18&objectcat=17&objectcat=12&objectcat=16&objectcat=181&objectcat=14&objectcat=15&objectcat=226&objectcat=13&wbs=-1&fromyear=&toyear=",
"enabled": true
},
"immowelt": {
"url": "https://www.immowelt.de/liste/duesseldorf-benrath/wohnungen/kaufen?geoid=10805111000004%2C10805111000005%2C10805111000006%2C10805111000007%2C10805111000009%2C10805111000010%2C10805111000011%2C10805111000013%2C10805111000014%2C10805111000015%2C10805111000016%2C10805111000017%2C10805111000018%2C10805111000019%2C10805111000023%2C10805111000024%2C10805111000027%2C10805111000032%2C10805111000034%2C10805111000035%2C10805111000039%2C10805111000041%2C10805111000042%2C10805111000043%2C10805111000047%2C10805111000048%2C10805111000049%2C10805111000051%2C10805111000052%2C10805111000053&roomi=3&prima=420000&wflmi=90&sort=createdate%2Bdesc",
"enabled": true
},
"kalaydo": {
"url": "https://www.kalaydo.de/immobilien/eigentumswohnung-kaufen/o/duesseldorf/4/?attr_gt_estate_size_living_area=90.0&attr_gt_no_of_rooms=3.5&maxPrice=420000.00&radius=5&resultsPerPage=50&sorting=-date",
"enabled": true
},
"kleinanzeigen": {
"url": "https://www.ebay-kleinanzeigen.de/s-wohnung-kaufen/duesseldorf/anzeige:angebote/preis::420000/wohnung/k0c196l2068r5+wohnung_kaufen.qm_d:90,+wohnung_kaufen.zimmer_d:3.5,",
"enabled": true
},
"neubauKompass": {
"url": "https://www.neubaukompass.de/neubau-immobilien/duesseldorf-region/eigentumswohnung/",
"enabled": true
},
"wgGesucht": {
"url": "https://www.wg-gesucht.de/wg-zimmer-in-Duesseldorf.30.0.1.0.html?offer_filter=1&noDeact=1&city_id=30&category=0&rent_type=0&rMax=5000",
"enabled": true
}
}

View File

@@ -1,26 +1,27 @@
const mockNotification = require('../mocks/mockNotification');
const mockConfig = require('../../conf/forTesting/config.multi.test');
const providerConfig = require('./testProvider.json');
const mockStore = require('../mocks/mockStore');
const proxyquire = require('proxyquire').noCallThru();
const expect = require('chai').expect;
const provider = require('../../lib/provider/wgGesucht');
describe('#wgGesucht testsuite()', () => {
provider.init(mockConfig.jobs.test1.provider.wgGesucht, [], []);
provider.init(providerConfig.wgGesucht, [], []);
const Fredy = proxyquire('../../lib/FredyRuntime', {
'./services/store': mockStore,
'./notification/notify': mockNotification
'./services/storage/listingsStorage': {
...mockStore,
},
'./notification/notify': mockNotification,
});
it('should test wgGesucht provider', async () => {
return await new Promise(resolve => {
const fredy = new Fredy(provider.config, null, provider.id(), 'test1');
fredy.execute().then(() => {
const wgGesuchtDbContent = fredy._getStore();
expect(wgGesuchtDbContent.wgGesucht).to.be.a('array');
return await new Promise((resolve) => {
const fredy = new Fredy(provider.config, null, provider.metaInformation.id, 'test1');
fredy.execute().then((listing) => {
expect(listing).to.be.a('array');
const notificationObj = mockNotification.get();
expect(notificationObj.serviceName).to.equal('wgGesucht');
notificationObj.payload.forEach(notify => {
notificationObj.payload.forEach((notify) => {
expect(notify).to.be.a('object');
/** check the actual structure **/