mirror of
https://github.com/orangecoding/fredy.git
synced 2026-06-16 12:31:07 +00:00
Concurrent-Jobs (#7)
Fredy 2.0.0 introduces the concept of search jobs. You can now configure multiple of these jobs running in the same instance of Fredy. Also a new API has been created 🎉
This commit is contained in:
committed by
GitHub
parent
52a32f7453
commit
770d30af95
@@ -1,49 +0,0 @@
|
||||
const mockNotification = require('./mocks/mockNotification');
|
||||
const mockConfig = require('../conf/config.test');
|
||||
const mockStore = require('./mocks/mockStore');
|
||||
const mockStats = require('./mocks/mockStats');
|
||||
const proxyquire = require('proxyquire').noCallThru();
|
||||
const expect = require('chai').expect;
|
||||
|
||||
describe('#einsAImmobilien testsuite()', () => {
|
||||
|
||||
const einsAImmobilien = proxyquire('../lib/provider/einsAImmobilien', {
|
||||
'../../conf/config.json': mockConfig,
|
||||
'../lib/fredy': proxyquire('../lib/fredy', {
|
||||
'./services/store': mockStore,
|
||||
'./notification/notify': mockNotification
|
||||
})
|
||||
});
|
||||
|
||||
it('should test einsAImmobilien provider', async () => {
|
||||
return await new Promise(resolve => {
|
||||
einsAImmobilien.run(mockStats).then(() => {
|
||||
const immonetDbContent = einsAImmobilien._getStore()._db;
|
||||
|
||||
expect(immonetDbContent.einsAImmobilien).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) => {
|
||||
|
||||
/** 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');
|
||||
|
||||
/** 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;
|
||||
expect(notify.link).that.does.include('https://www.1a-immobilienmarkt.de');
|
||||
});
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,51 +0,0 @@
|
||||
const mockNotification = require('./mocks/mockNotification');
|
||||
const mockConfig = require('../conf/config.test');
|
||||
const mockStore = require('./mocks/mockStore');
|
||||
const mockStats = require('./mocks/mockStats');
|
||||
const proxyquire = require('proxyquire').noCallThru();
|
||||
const expect = require('chai').expect;
|
||||
|
||||
describe('#immonet testsuite()', () => {
|
||||
|
||||
const immonet = proxyquire('../lib/provider/immonet', {
|
||||
'../../conf/config.json': mockConfig,
|
||||
'../lib/fredy': proxyquire('../lib/fredy', {
|
||||
'./services/store': mockStore,
|
||||
'./notification/notify': mockNotification
|
||||
})
|
||||
});
|
||||
|
||||
it('should test immonet provider', async () => {
|
||||
return await new Promise(resolve => {
|
||||
immonet.run(mockStats).then(() => {
|
||||
const immonetDbContent = immonet._getStore()._db;
|
||||
|
||||
expect(immonetDbContent.immonet).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) => {
|
||||
/** 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(immonetDbContent.immonet[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.immonet.de');
|
||||
expect(notify.address).to.be.not.empty;
|
||||
});
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,51 +0,0 @@
|
||||
const mockNotification = require('./mocks/mockNotification');
|
||||
const mockConfig = require('../conf/config.test');
|
||||
const mockStats = require('./mocks/mockStats');
|
||||
const mockStore = require('./mocks/mockStore');
|
||||
const proxyquire = require('proxyquire').noCallThru();
|
||||
const expect = require('chai').expect;
|
||||
|
||||
describe('#immoscout testsuite()', () => {
|
||||
|
||||
const immoscout = proxyquire('../lib/provider/immoscout', {
|
||||
'../../conf/config.json': mockConfig,
|
||||
'../lib/fredy': proxyquire('../lib/fredy', {
|
||||
'./services/store': mockStore,
|
||||
'./notification/notify': mockNotification
|
||||
})
|
||||
});
|
||||
|
||||
it('should test immoscout provider', async () => {
|
||||
return await new Promise(resolve => {
|
||||
immoscout.run(mockStats).then(() => {
|
||||
const immoscoutDbContent = immoscout._getStore()._db;
|
||||
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();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,55 +0,0 @@
|
||||
const mockNotification = require('./mocks/mockNotification');
|
||||
const mockConfig = require('../conf/config.test');
|
||||
const mockStats = require('./mocks/mockStats');
|
||||
const mockStore = require('./mocks/mockStore');
|
||||
const proxyquire = require('proxyquire').noCallThru();
|
||||
const expect = require('chai').expect;
|
||||
|
||||
describe('#immowelt testsuite()', () => {
|
||||
|
||||
it('should test immowelt provider', async () => {
|
||||
|
||||
const immowelt = proxyquire('../lib/provider/immowelt', {
|
||||
'../../conf/config.json': mockConfig,
|
||||
'../lib/fredy': proxyquire('../lib/fredy', {
|
||||
'./services/store': mockStore,
|
||||
'./notification/notify': mockNotification
|
||||
})
|
||||
});
|
||||
|
||||
return await new Promise(resolve => {
|
||||
immowelt.run(mockStats).then(() => {
|
||||
const immoweltDbContent = immowelt._getStore()._db;
|
||||
expect(immoweltDbContent.immowelt).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) => {
|
||||
|
||||
/** 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(
|
||||
immoweltDbContent.immowelt[idx]
|
||||
);
|
||||
expect(notify.price).that.does.include('€');
|
||||
if(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.address).to.be.not.empty;
|
||||
});
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,48 +0,0 @@
|
||||
const mockNotification = require('./mocks/mockNotification');
|
||||
const mockConfig = require('../conf/config.test');
|
||||
const mockStore = require('./mocks/mockStore');
|
||||
const mockStats = require('./mocks/mockStats');
|
||||
const proxyquire = require('proxyquire').noCallThru();
|
||||
const expect = require('chai').expect;
|
||||
|
||||
describe('#kalaydo testsuite()', () => {
|
||||
|
||||
const kalaydo = proxyquire('../lib/provider/kalaydo', {
|
||||
'../../conf/config.json': mockConfig,
|
||||
'../lib/fredy': proxyquire('../lib/fredy', {
|
||||
'./services/store': mockStore,
|
||||
'./notification/notify': mockNotification
|
||||
})
|
||||
});
|
||||
|
||||
it('should test kalaydo provider', async () => {
|
||||
return await new Promise(resolve => {
|
||||
kalaydo.run(mockStats).then(() => {
|
||||
const kalaydoDbContent = kalaydo._getStore()._db;
|
||||
|
||||
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();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,51 +0,0 @@
|
||||
const mockNotification = require('./mocks/mockNotification');
|
||||
const mockConfig = require('../conf/config.test');
|
||||
const mockStats = require('./mocks/mockStats');
|
||||
const mockStore = require('./mocks/mockStore');
|
||||
const proxyquire = require('proxyquire').noCallThru();
|
||||
const expect = require('chai').expect;
|
||||
|
||||
describe('#kleinanzeigen testsuite()', () => {
|
||||
|
||||
it('should test kleinanzeigen provider', async () => {
|
||||
|
||||
const kleinanzeigen = proxyquire('../lib/provider/kleinanzeigen', {
|
||||
'../../conf/config.json': mockConfig,
|
||||
'../lib/fredy': proxyquire('../lib/fredy', {
|
||||
'./services/store': mockStore,
|
||||
'./notification/notify': mockNotification
|
||||
})
|
||||
});
|
||||
|
||||
return await new Promise(resolve => {
|
||||
kleinanzeigen.run(mockStats).then(() => {
|
||||
const kleinanzeigenDbContent = kleinanzeigen._getStore()._db;
|
||||
expect(kleinanzeigenDbContent.kleinanzeigen).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) => {
|
||||
|
||||
/** 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(
|
||||
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;
|
||||
});
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,5 +0,0 @@
|
||||
module.exports = {
|
||||
setLastScrape: () => {
|
||||
/*noop*/
|
||||
}
|
||||
};
|
||||
@@ -1,27 +1,52 @@
|
||||
const db = {};
|
||||
|
||||
exports.init = () => {
|
||||
return new Promise(resolve => {
|
||||
resolve();
|
||||
});
|
||||
};
|
||||
|
||||
exports.setKnownListings = (jobKey, providerId, listings) => {
|
||||
if (!Array.isArray(listings)) throw Error('Not a valid array');
|
||||
|
||||
db[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 = {};
|
||||
}
|
||||
constructor(name) {
|
||||
this._name = name;
|
||||
this._db = {};
|
||||
}
|
||||
|
||||
get warmup() {
|
||||
this._db = {};
|
||||
return new Promise(resolve => resolve());
|
||||
}
|
||||
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);
|
||||
});
|
||||
}
|
||||
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 bla() {}
|
||||
|
||||
get knownListings() {
|
||||
return this._db[this._name] || [];
|
||||
}
|
||||
get knownListings() {
|
||||
return this._db[this._name] || [];
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Store;
|
||||
*/
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
const mockNotification = require('./mocks/mockNotification');
|
||||
const mockConfig = require('../conf/config.test');
|
||||
const mockStore = require('./mocks/mockStore');
|
||||
const mockStats = require('./mocks/mockStats');
|
||||
const proxyquire = require('proxyquire').noCallThru();
|
||||
const expect = require('chai').expect;
|
||||
|
||||
describe('#neubauKompass testsuite()', () => {
|
||||
|
||||
const neubauKompass = proxyquire('../lib/provider/neubauKompass', {
|
||||
'../../conf/config.json': mockConfig,
|
||||
'../lib/fredy': proxyquire('../lib/fredy', {
|
||||
'./services/store': mockStore,
|
||||
'./notification/notify': mockNotification
|
||||
})
|
||||
});
|
||||
|
||||
it('should test neubauKompass provider', async () => {
|
||||
return await new Promise(resolve => {
|
||||
neubauKompass.run(mockStats).then(() => {
|
||||
const neubauKompassDbContent = neubauKompass._getStore()._db;
|
||||
expect(neubauKompassDbContent.neubauKompass).to.be.a('array');
|
||||
|
||||
const notificationObj = mockNotification.get();
|
||||
expect(notificationObj.serviceName).to.equal('neubauKompass');
|
||||
|
||||
notificationObj.payload.forEach((notify, idx) => {
|
||||
expect(notify).to.be.a('object');
|
||||
|
||||
/** check the actual structure **/
|
||||
expect(notify.id).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(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;
|
||||
});
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
45
test/provider/einsAImmobilien.test.js
Normal file
45
test/provider/einsAImmobilien.test.js
Normal file
@@ -0,0 +1,45 @@
|
||||
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/einsAImmobilien');
|
||||
|
||||
describe('#einsAImmobilien testsuite()', () => {
|
||||
provider.init(mockConfig.jobs.test1.provider.einsAImmobilien, [], []);
|
||||
const Fredy = proxyquire('../../lib/FredyRuntime', {
|
||||
'./services/store': 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');
|
||||
|
||||
const notificationObj = mockNotification.get();
|
||||
expect(notificationObj).to.be.a('object');
|
||||
expect(notificationObj.serviceName).to.equal('einsAImmobilien');
|
||||
|
||||
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');
|
||||
|
||||
/** 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;
|
||||
expect(notify.link).that.does.include('https://www.1a-immobilienmarkt.de');
|
||||
});
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
48
test/provider/immonet.test.js
Normal file
48
test/provider/immonet.test.js
Normal file
@@ -0,0 +1,48 @@
|
||||
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/immonet');
|
||||
|
||||
describe('#immonet testsuite()', () => {
|
||||
provider.init(mockConfig.jobs.test1.provider.immonet, [], []);
|
||||
const Fredy = proxyquire('../../lib/FredyRuntime', {
|
||||
'./services/store': 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');
|
||||
|
||||
const notificationObj = mockNotification.get();
|
||||
expect(notificationObj).to.be.a('object');
|
||||
expect(notificationObj.serviceName).to.equal('immonet');
|
||||
|
||||
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(immonetDbContent.immonet[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.immonet.de');
|
||||
expect(notify.address).to.be.not.empty;
|
||||
});
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
47
test/provider/immoscout.test.js
Normal file
47
test/provider/immoscout.test.js
Normal file
@@ -0,0 +1,47 @@
|
||||
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();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
49
test/provider/immowelt.test.js
Normal file
49
test/provider/immowelt.test.js
Normal file
@@ -0,0 +1,49 @@
|
||||
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/immowelt');
|
||||
|
||||
describe('#immowelt testsuite()', () => {
|
||||
it('should test immowelt provider', async () => {
|
||||
provider.init(mockConfig.jobs.test1.provider.immowelt, [], []);
|
||||
const Fredy = proxyquire('../../lib/FredyRuntime', {
|
||||
'./services/store': 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');
|
||||
|
||||
const notificationObj = mockNotification.get();
|
||||
expect(notificationObj).to.be.a('object');
|
||||
expect(notificationObj.serviceName).to.equal('immowelt');
|
||||
|
||||
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(immoweltDbContent.immowelt[idx]);
|
||||
expect(notify.price).that.does.include('€');
|
||||
if (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.address).to.be.not.empty;
|
||||
});
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
44
test/provider/kalaydo.test.js
Normal file
44
test/provider/kalaydo.test.js
Normal file
@@ -0,0 +1,44 @@
|
||||
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();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
45
test/provider/kleinanzeigen.test.js
Normal file
45
test/provider/kleinanzeigen.test.js
Normal file
@@ -0,0 +1,45 @@
|
||||
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/kleinanzeigen');
|
||||
|
||||
describe('#kleinanzeigen testsuite()', () => {
|
||||
it('should test kleinanzeigen provider', async () => {
|
||||
provider.init(mockConfig.jobs.test1.provider.kleinanzeigen, [], []);
|
||||
const Fredy = proxyquire('../../lib/FredyRuntime', {
|
||||
'./services/store': 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');
|
||||
|
||||
const notificationObj = mockNotification.get();
|
||||
expect(notificationObj).to.be.a('object');
|
||||
expect(notificationObj.serviceName).to.equal('kleinanzeigen');
|
||||
|
||||
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(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;
|
||||
});
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
44
test/provider/neubauKompass.test.js
Normal file
44
test/provider/neubauKompass.test.js
Normal file
@@ -0,0 +1,44 @@
|
||||
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/neubauKompass');
|
||||
|
||||
describe('#neubauKompass testsuite()', () => {
|
||||
provider.init(mockConfig.jobs.test1.provider.neubauKompass, [], []);
|
||||
const Fredy = proxyquire('../../lib/FredyRuntime', {
|
||||
'./services/store': 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');
|
||||
|
||||
const notificationObj = mockNotification.get();
|
||||
expect(notificationObj.serviceName).to.equal('neubauKompass');
|
||||
|
||||
notificationObj.payload.forEach((notify, idx) => {
|
||||
expect(notify).to.be.a('object');
|
||||
|
||||
/** check the actual structure **/
|
||||
expect(notify.id).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(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;
|
||||
});
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
const utils = require('../lib/utils');
|
||||
const utils = require('../../lib/utils');
|
||||
const assert = require('assert');
|
||||
|
||||
describe('utils', () => {
|
||||
39
test/provider/wgGesucht.test.js
Normal file
39
test/provider/wgGesucht.test.js
Normal file
@@ -0,0 +1,39 @@
|
||||
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/wgGesucht');
|
||||
|
||||
describe('#wgGesucht testsuite()', () => {
|
||||
provider.init(mockConfig.jobs.test1.provider.wgGesucht, [], []);
|
||||
const Fredy = proxyquire('../../lib/FredyRuntime', {
|
||||
'./services/store': 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');
|
||||
const notificationObj = mockNotification.get();
|
||||
expect(notificationObj.serviceName).to.equal('wgGesucht');
|
||||
notificationObj.payload.forEach(notify => {
|
||||
expect(notify).to.be.a('object');
|
||||
|
||||
/** check the actual structure **/
|
||||
|
||||
expect(notify.id).to.be.a('string');
|
||||
expect(notify.title).to.be.a('string');
|
||||
expect(notify.details).to.be.a('string');
|
||||
expect(notify.size).to.be.a('string');
|
||||
expect(notify.price).to.be.a('string');
|
||||
expect(notify.link).to.be.a('string');
|
||||
});
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,41 +0,0 @@
|
||||
const mockNotification = require('./mocks/mockNotification');
|
||||
const mockConfig = require('../conf/config.test');
|
||||
const mockStore = require('./mocks/mockStore');
|
||||
const mockStats = require('./mocks/mockStats');
|
||||
const proxyquire = require('proxyquire').noCallThru();
|
||||
const expect = require('chai').expect;
|
||||
|
||||
describe('#wgGesucht testsuite()', () => {
|
||||
|
||||
const wgGesucht = proxyquire('../lib/provider/wgGesucht', {
|
||||
'../../conf/config.json': mockConfig,
|
||||
'../lib/fredy': proxyquire('../lib/fredy', {
|
||||
'./services/store': mockStore,
|
||||
'./notification/notify': mockNotification
|
||||
})
|
||||
});
|
||||
|
||||
it('should test wgGesucht provider', async () => {
|
||||
return await new Promise(resolve => {
|
||||
wgGesucht.run(mockStats).then(() => {
|
||||
const wgGesuchtDbContent = wgGesucht._getStore()._db;
|
||||
expect(wgGesuchtDbContent.wgGesucht).to.be.a('array');
|
||||
const notificationObj = mockNotification.get();
|
||||
expect(notificationObj.serviceName).to.equal('wgGesucht');
|
||||
notificationObj.payload.forEach((notify, idx) => {
|
||||
expect(notify).to.be.a('object');
|
||||
|
||||
/** check the actual structure **/
|
||||
|
||||
expect(notify.id).to.be.a('string');
|
||||
expect(notify.title).to.be.a('string');
|
||||
expect(notify.details).to.be.a('string');
|
||||
expect(notify.description).to.be.a('string');
|
||||
expect(notify.link).to.be.a('string');
|
||||
|
||||
});
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user