Adjusting tests to function based on new classification format etc.

This commit is contained in:
Marina Samuel 2015-01-16 16:09:30 -05:00
Родитель c6898000fb
Коммит 1c0893867d
9 изменённых файлов: 108 добавлений и 602 удалений

Просмотреть файл

@ -44,10 +44,10 @@ let categoryComputingNoRank = JSON.parse(JSON.stringify(categoryComputing)); //
delete categoryComputingNoRank['rank'];
exports.dayAnnotatedThreeChartProcessorConsumeResults = {
"lwca": {
"58-cat": {
"_type": "lwca",
"_namespace": "58-cat",
"rules": {
"dfr_rules": {
"_type": "rules",
"_namespace": "dfr_rules",
"maxDay": "16361",
"minDay": "16358",
"categories": {

Просмотреть файл

@ -46,7 +46,7 @@ exports.testUtils = {
return false;
},
getWorker : function getWorker({namespace, domainRules, textModel, urlStopWords,
getWorker : function getWorker({namespace, domainRules, urlStopWords,
listener, regionCode, domain_rules, host_rules, path_rules,
words_tree, ignore_words, ignore_domains, ignore_exts, bad_domain_specific}) {
let worker = new ChromeWorker(data.url("interests/interestsWorker.js"));
@ -59,7 +59,6 @@ exports.testUtils = {
workerRegionCode: regionCode || 'en-US',
interestsDataType: "dfr",
interestsData: domainRules,
interestsClassifierModel: textModel,
interestsUrlStopwords: urlStopWords,
domain_rules: domain_rules,
host_rules: host_rules,

Просмотреть файл

@ -7,24 +7,8 @@
exports.dayAnnotatedOne = {
"15914": {
"combined": {
"58-cat": {
"computers": [1, 1, 1, 1],
},
"edrules": {
"Android": [1, 1],
},
},
"keywords": {
"58-cat": {
"computers": [1, 1],
},
"edrules": {
"Android": [1],
},
},
"rules": {
"58-cat": {
"dfr_rules": {
"uncategorized": [1, 1],
},
"edrules": {
@ -36,500 +20,23 @@ exports.dayAnnotatedOne = {
exports.dayAnnotatedTwo = {
"15915": {
"combined": {
"58-cat": {
"banking": [
1,
1,
1
],
"blogging": [
1,
1
],
"business": [
1,
1
],
"computers": [
1,
1,
1,
1,
1,
3,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
3,
1,
1,
1
],
"consumer-electronics": [
1,
1
],
"dance": [
1
],
"discounts": [
1
],
"education": [
1
],
"entertainment": [
1
],
"family": [
1,
1
],
"food": [
1
],
"government": [
1,
1,
1
],
"image-sharing": [
2
],
"maps": [
1
],
"marketing": [
1
],
"music": [
1,
1
],
"news": [
1,
1
],
"politics": [
1
],
"reference": [
1,
1,
1,
1
],
"science": [
1
],
"shopping": [
1
],
"society": [
1,
1
],
"sports": [
1
],
"technology": [
2,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
],
"uncategorized": [
1,
3
],
"video-games": [
1,
1,
1,
1,
1
],
"weather": [
1
]
},
"edrules": {
"Android": [
1,
1,
1,
1
],
"Apple": [
1
],
"Business": [
1,
1,
1,
1,
1
],
"Do-It-Yourself": [
1,
3,
1,
1,
1,
1,
1,
1,
2
],
"Entrepreneur": [
1,
1,
3
],
"Fashion-Men": [
1,
1
],
"Golf": [
1
],
"Home-Design": [
2,
1
],
"Humor": [
1
],
"Music": [
1,
1,
1
],
"Photography": [
1
],
"Politics": [
1,
1,
1
],
"Programming": [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
1
],
"Science": [
1,
1
],
"Sports": [
1
],
"Technology": [
2,
2,
4,
1,
1,
2,
1,
1,
1
],
"Television": [
1,
1
],
"Video-Games": [
1,
1,
1
]
}
},
"keywords": {
"58-cat": {
"banking": [
1,
1,
1
],
"blogging": [
1
],
"business": [
1,
1
],
"career": [
1,
1
],
"computers": [
2,
2,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
3,
1,
1,
1
],
"consumer-electronics": [
3,
1
],
"discounts": [
1
],
"education": [
1
],
"entertainment": [
1
],
"family": [
1,
1
],
"food": [
1
],
"games": [
1,
1
],
"government": [
1,
1,
1
],
"home": [
1
],
"maps": [
1
],
"marketing": [
1,
1
],
"music": [
1,
1,
1
],
"news": [
1,
1
],
"photography": [
1
],
"politics": [
2,
1
],
"reference": [
1,
1
],
"reviews": [
1
],
"science": [
1
],
"shopping": [
1
],
"society": [
1
],
"technology": [
2,
4,
1,
1,
2,
1,
1,
1,
1,
1,
1
],
"video-games": [
1,
1,
1,
1
],
"weather": [
1
]
},
"edrules": {
"Android": [
1,
1,
1,
1
],
"Apple": [
1
],
"Business": [
1,
1,
1,
1,
1
],
"Do-It-Yourself": [
1,
3,
1,
1,
1,
1,
1,
1,
2
],
"Entrepreneur": [
1,
1,
3
],
"Fashion-Men": [
1,
1
],
"Golf": [
1
],
"Home-Design": [
2,
1
],
"Humor": [
1
],
"Music": [
1,
1,
1
],
"Photography": [
1
],
"Politics": [
1,
1,
1
],
"Programming": [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
1
],
"Science": [
1,
1
],
"Sports": [
1
],
"Technology": [
2,
2,
4,
1,
1,
2,
1,
1,
1
],
"Television": [
1,
1
],
"Video-Games": [
1,
1,
1
]
}
},
"rules": {
"58-cat": {
"dfr_rules": {
"blogging": [
1,
1
],
1
],
"computers": [
1,
1,
1,
1,
3,
1,
1,
1,
1
],
1,
1,
1,
3,
1,
1,
1,
1
],
"consumer-electronics": [
1
],
@ -561,25 +68,25 @@ exports.dayAnnotatedTwo = {
],
"technology": [
1,
1,
1,
1,
1,
1,
1
],
1,
1,
1,
1,
1,
1
],
"uncategorized": [
1,
3
],
3
],
"video-games": [
1,
1,
1
],
1,
1
],
"weather": [
1
]
]
},
"edrules": {
"Programming": [
@ -587,9 +94,9 @@ exports.dayAnnotatedTwo = {
],
"Technology": [
1,
1,
1
]
1,
1
]
}
}
}
@ -597,8 +104,8 @@ exports.dayAnnotatedTwo = {
exports.dayAnnotatedThree = {
"16361": {
"lwca": {
"58-cat": {
"rules": {
"dfr_rules": {
"technology & computing": {
"hosts": {
"mozilla.org": 1,
@ -623,8 +130,8 @@ exports.dayAnnotatedThree = {
}
},
"16358": {
"lwca": {
"58-cat": {
"rules": {
"dfr_rules": {
"technology & computing": {
"hosts": {
"dxr.mozilla.org": 1,

Просмотреть файл

@ -32,10 +32,10 @@ exports["test controller history submission completes"] = function test_Controll
let today = DateUtils.today();
let microNow = Date.now() * 1000;
yield testUtils.promiseAddVisits({uri: NetUtil.newURI("http://www.autoblog.com/"), visitDate: microNow - 4*MICROS_PER_DAY});
yield testUtils.promiseAddVisits({uri: NetUtil.newURI("http://www.autoblog.com/"), visitDate: microNow - 3*MICROS_PER_DAY});
yield testUtils.promiseAddVisits({uri: NetUtil.newURI("http://www.autoblog.com/"), visitDate: microNow - 2*MICROS_PER_DAY});
yield testUtils.promiseAddVisits({uri: NetUtil.newURI("http://www.autoblog.com/"), visitDate: microNow});
yield testUtils.promiseAddVisits({uri: NetUtil.newURI("http://www.theweathernetwork.com/weather"), visitDate: microNow - 4*MICROS_PER_DAY});
yield testUtils.promiseAddVisits({uri: NetUtil.newURI("http://www.theweathernetwork.com/weather"), visitDate: microNow - 3*MICROS_PER_DAY});
yield testUtils.promiseAddVisits({uri: NetUtil.newURI("http://www.theweathernetwork.com/weather"), visitDate: microNow - 2*MICROS_PER_DAY});
yield testUtils.promiseAddVisits({uri: NetUtil.newURI("http://www.theweathernetwork.com/weather"), visitDate: microNow});
// step one day into future to flush the DayBuffer
let testController = setupTestController();
@ -76,7 +76,7 @@ exports["test controller history submission completes"] = function test_Controll
exports["test stop and start"] = function test_StopAndStart(assert, done) {
Task.spawn(function() {
try {
let hostArray = ["www.autoblog.com",
let hostArray = ["www.theweathernetwork.com/weather",
"www.thehill.com",
"www.rivals.com",
"www.mysql.com",
@ -95,8 +95,8 @@ exports["test stop and start"] = function test_StopAndStart(assert, done) {
let processDeferred;
processDeferred = oldPromise.defer();
testController._streamObjects.chartDataProcessorBolt.setEmitCallback(bolt => {
let minDay = bolt.storage.chartData.genericChartData.lwca["58-cat"].minDay;
let maxDay = bolt.storage.chartData.genericChartData.lwca["58-cat"].maxDay;
let minDay = bolt.storage.chartData.genericChartData.rules.edrules.minDay;
let maxDay = bolt.storage.chartData.genericChartData.rules.edrules.maxDay;
let numDays = maxDay - minDay + 1;
if (numDays == 60) {
processDeferred.resolve();
@ -136,7 +136,7 @@ exports["test stop and start"] = function test_StopAndStart(assert, done) {
exports["test clear storage"] = function test_ClearStorage(assert, done) {
Task.spawn(function() {
try {
let hostArray = ["www.autoblog.com",
let hostArray = ["www.theweathernetwork.com/weather",
"www.thehill.com",
"www.rivals.com",
"www.mysql.com",

Просмотреть файл

@ -57,7 +57,7 @@ function daysPostEpochToDate(dayCount) {
exports["test read all"] = function test_readAll(assert, done) {
Task.spawn(function() {
yield testUtils.promiseClearHistory();
yield testUtils.addVisits("www.w3schools.com",20);
yield testUtils.addVisits("www.autoblog.com",20);
let storageBackend = {};
let streamObjects = initStream(storageBackend);
@ -72,16 +72,16 @@ exports["test read all"] = function test_readAll(assert, done) {
streamObjects.stream.flush(); // flush out the last day
yield assertDeferred.promise;
let datum = storageBackend.chartData.genericChartData.lwca["58-cat"].categories.education.days;
let datum = storageBackend.chartData.genericChartData.rules.edrules.categories.Autos.days;
let dates = Object.keys(datum);
assert.equal(dates.length, 21, "There are 21 days processed");
assert.deepEqual(datum[today + ""],
{"x":daysPostEpochToDate(today),"size":1,"domainList":{"w3schools.com":1}},
{"x":daysPostEpochToDate(today),"size":1,"domainList":{"autoblog.com":1}},
"Test expected data for today");
assert.deepEqual(datum[(today-19) + ""],
{"x":daysPostEpochToDate(today-19),"size":1,"domainList":{"w3schools.com":1}},
{"x":daysPostEpochToDate(today-19),"size":1,"domainList":{"autoblog.com":1}},
"Test expected data for today - 19");
assert.equal(testUtils.tsToDay(historyReader.getLastTimeStamp()), today);
}).then(done);
@ -90,7 +90,7 @@ exports["test read all"] = function test_readAll(assert, done) {
exports["test read from given timestamp"] = function test_readFromGivenTimestamp(assert, done) {
Task.spawn(function() {
yield testUtils.promiseClearHistory();
yield testUtils.addVisits("www.w3schools.com",20);
yield testUtils.addVisits("www.autoblog.com",20);
let storageBackend = {};
let streamObjects = initStream(storageBackend);
@ -101,22 +101,22 @@ exports["test read from given timestamp"] = function test_readFromGivenTimestamp
let assertDeferred = oldPromise.defer();
streamObjects.chartDataProcessorBolt.setEmitCallback(bolt => {
if (bolt.storage.chartData.genericChartData.lwca["58-cat"].categories.education.days[today]) {
if (bolt.storage.chartData.genericChartData.rules.edrules.categories.Autos.days[today]) {
assertDeferred.resolve();
}
});
streamObjects.stream.flush(); // flush out the last day
yield assertDeferred.promise;
let datum = storageBackend.chartData.genericChartData.lwca["58-cat"].categories.education.days;
let datum = storageBackend.chartData.genericChartData.rules.edrules.categories.Autos.days;
let dates = Object.keys(datum);
assert.equal(dates.length,11);
assert.deepEqual(datum[today + ""],
{"x":daysPostEpochToDate(today),"size":1,"domainList":{"w3schools.com":1}},
{"x":daysPostEpochToDate(today),"size":1,"domainList":{"autoblog.com":1}},
"Test expected data for today");
assert.deepEqual(datum[(today-9) + ""],
{"x":daysPostEpochToDate(today-9),"size":1,"domainList":{"w3schools.com":1}},
{"x":daysPostEpochToDate(today-9),"size":1,"domainList":{"autoblog.com":1}},
"Test expected data for today - 9");
assert.deepEqual(datum[(today-10) + ""], undefined,
@ -129,7 +129,7 @@ exports["test read from given timestamp"] = function test_readFromGivenTimestamp
exports["test chunk size 1"] = function test_ChunkSize1(assert, done) {
Task.spawn(function() {
yield testUtils.promiseClearHistory();
yield testUtils.addVisits("www.w3schools.com",20);
yield testUtils.addVisits("www.autoblog.com",20);
let storageBackend = {};
let streamObjects = initStream(storageBackend);
@ -140,7 +140,7 @@ exports["test chunk size 1"] = function test_ChunkSize1(assert, done) {
let assertDeferred = oldPromise.defer();
streamObjects.chartDataProcessorBolt.setEmitCallback(bolt => {
if (bolt.storage.chartData.genericChartData.lwca["58-cat"].categories.education.days[today]) {
if (bolt.storage.chartData.genericChartData.rules.edrules.categories.Autos.days[today]) {
assertDeferred.resolve();
}
});
@ -148,7 +148,7 @@ exports["test chunk size 1"] = function test_ChunkSize1(assert, done) {
yield assertDeferred.promise;
streamObjects.chartDataProcessorBolt.setEmitCallback(undefined);
let datum = storageBackend.chartData.genericChartData.lwca["58-cat"].categories.education.days;;
let datum = storageBackend.chartData.genericChartData.rules.edrules.categories.Autos.days;;
assert.equal(testUtils.tsToDay(historyReader.getLastTimeStamp()), today);
// now set chunksize to 1 and read from same id
@ -159,7 +159,7 @@ exports["test chunk size 1"] = function test_ChunkSize1(assert, done) {
assertDeferred = oldPromise.defer();
streamObjects.chartDataProcessorBolt.setEmitCallback(bolt => {
if (bolt.storage.chartData.genericChartData.lwca["58-cat"].categories.education.days[today]) {
if (bolt.storage.chartData.genericChartData.rules.edrules.categories.Autos.days[today]) {
assertDeferred.resolve();
}
});
@ -167,7 +167,7 @@ exports["test chunk size 1"] = function test_ChunkSize1(assert, done) {
yield assertDeferred.promise;
streamObjects.chartDataProcessorBolt.setEmitCallback(undefined);
let newDatum = storageBackend.chartData.genericChartData.lwca["58-cat"].categories.education.days;
let newDatum = storageBackend.chartData.genericChartData.rules.edrules.categories.Autos.days;
assert.deepEqual(datum, newDatum);
assert.equal(testUtils.tsToDay(historyReader.getLastTimeStamp()), today);
}).then(done);
@ -177,12 +177,12 @@ exports["test accumulation"] = function test_Accumulation(assert, done) {
Task.spawn(function() {
let microNow = Date.now() * 1000;
yield testUtils.promiseClearHistory();
yield testUtils.promiseAddVisits({uri: NetUtil.newURI("http://www.w3schools.com/"), visitDate: microNow - 4*MICROS_PER_DAY});
yield testUtils.promiseAddVisits({uri: NetUtil.newURI("http://www.w3schools.com/"), visitDate: microNow - 3*MICROS_PER_DAY});
yield testUtils.promiseAddVisits({uri: NetUtil.newURI("http://www.w3schools.com/"), visitDate: microNow - 3*MICROS_PER_DAY});
yield testUtils.promiseAddVisits({uri: NetUtil.newURI("http://www.w3schools.com/"), visitDate: microNow - 2*MICROS_PER_DAY});
yield testUtils.promiseAddVisits({uri: NetUtil.newURI("http://www.w3schools.com/"), visitDate: microNow - 2*MICROS_PER_DAY});
yield testUtils.promiseAddVisits({uri: NetUtil.newURI("http://www.w3schools.com/"), visitDate: microNow - 2*MICROS_PER_DAY});
yield testUtils.promiseAddVisits({uri: NetUtil.newURI("http://autoblog.com"), visitDate: microNow - 4*MICROS_PER_DAY});
yield testUtils.promiseAddVisits({uri: NetUtil.newURI("http://autoblog.com"), visitDate: microNow - 3*MICROS_PER_DAY});
yield testUtils.promiseAddVisits({uri: NetUtil.newURI("http://autoblog.com"), visitDate: microNow - 3*MICROS_PER_DAY});
yield testUtils.promiseAddVisits({uri: NetUtil.newURI("http://autoblog.com"), visitDate: microNow - 2*MICROS_PER_DAY});
yield testUtils.promiseAddVisits({uri: NetUtil.newURI("http://autoblog.com"), visitDate: microNow - 2*MICROS_PER_DAY});
yield testUtils.promiseAddVisits({uri: NetUtil.newURI("http://autoblog.com"), visitDate: microNow - 2*MICROS_PER_DAY});
let storageBackend = {};
let streamObjects = initStream(storageBackend);
@ -192,22 +192,22 @@ exports["test accumulation"] = function test_Accumulation(assert, done) {
let assertDeferred = oldPromise.defer();
streamObjects.chartDataProcessorBolt.setEmitCallback(bolt => {
if (bolt.storage.chartData.genericChartData.lwca["58-cat"].categories.education.days[today-2]) {
if (bolt.storage.chartData.genericChartData.rules.edrules.categories.Autos.days[today-2]) {
assertDeferred.resolve();
}
});
streamObjects.stream.flush(); // flush out the last day
yield assertDeferred.promise;
let datum = storageBackend.chartData.genericChartData.lwca["58-cat"].categories.education.days;
let datum = storageBackend.chartData.genericChartData.rules.edrules.categories.Autos.days;
let dates = Object.keys(datum);
assert.equal(dates.length,3);
assert.deepEqual(datum[(today-3) + ""],
{"x":daysPostEpochToDate(today-3),"size":1,"domainList":{"w3schools.com":1}});
{"x":daysPostEpochToDate(today-3),"size":1,"domainList":{"autoblog.com":1}});
assert.deepEqual(datum[(today-2) + ""],
{"x":daysPostEpochToDate(today-2),"size":2,"domainList":{"w3schools.com":2}});
{"x":daysPostEpochToDate(today-2),"size":2,"domainList":{"autoblog.com":2}});
assert.deepEqual(datum[(today-1) + ""],
{"x":daysPostEpochToDate(today-1),"size":3,"domainList":{"w3schools.com":3}});
{"x":daysPostEpochToDate(today-1),"size":3,"domainList":{"autoblog.com":3}});
done();
}).then(done);
}
@ -215,7 +215,7 @@ exports["test accumulation"] = function test_Accumulation(assert, done) {
exports["test stop and restart"] = function test_StopAndRestart(assert, done) {
Task.spawn(function() {
try {
let hostArray = ["www.w3schools.com",
let hostArray = ["www.autoblog.com",
"www.amazon.com",
"www.doordash.com",
"www.api.jquery.com",
@ -245,8 +245,8 @@ exports["test stop and restart"] = function test_StopAndRestart(assert, done) {
// block until today's data has been flushed
processDeferred = oldPromise.defer();
streamObjects.chartDataProcessorBolt.setEmitCallback(bolt => {
let minDay = bolt.storage.chartData.genericChartData.lwca["58-cat"].minDay;
let maxDay = bolt.storage.chartData.genericChartData.lwca["58-cat"].maxDay;
let minDay = bolt.storage.chartData.genericChartData.rules.edrules.minDay;
let maxDay = bolt.storage.chartData.genericChartData.rules.edrules.maxDay;
let numDays = maxDay - minDay + 1;
if (numDays == 61) {
processDeferred.resolve();
@ -257,7 +257,7 @@ exports["test stop and restart"] = function test_StopAndRestart(assert, done) {
streamObjects.chartDataProcessorBolt.setEmitCallback(undefined);
let allTheData = storageBackend;
let categories = storageBackend.chartData.genericChartData.lwca["58-cat"].categories;
let categories = storageBackend.chartData.genericChartData.rules.edrules.categories;
assert.deepEqual(Object.keys(categories).length, 2);
for (let category in categories) {
@ -301,8 +301,8 @@ exports["test stop and restart"] = function test_StopAndRestart(assert, done) {
// wait until data is flushed
processDeferred = oldPromise.defer();
streamObjects.chartDataProcessorBolt.setEmitCallback(bolt => {
let minDay = bolt.storage.chartData.genericChartData.lwca["58-cat"].minDay;
let maxDay = bolt.storage.chartData.genericChartData.lwca["58-cat"].maxDay;
let minDay = bolt.storage.chartData.genericChartData.rules.edrules.minDay;
let maxDay = bolt.storage.chartData.genericChartData.rules.edrules.maxDay;
let numDays = maxDay - minDay + 1;
if (numDays == 61) {
processDeferred.resolve();
@ -314,8 +314,8 @@ exports["test stop and restart"] = function test_StopAndRestart(assert, done) {
streamObjects.chartDataProcessorBolt.setEmitCallback(undefined);
// the content from the torture test and the single run is the same
assert.deepEqual(storageBackend.chartData.genericChartData.lwca["58-cat"].categories,
allTheData.chartData.genericChartData.lwca["58-cat"].categories);
assert.deepEqual(storageBackend.chartData.genericChartData.rules.edrules.categories,
allTheData.chartData.genericChartData.rules.edrules.categories);
} catch(ex) {
console.error(ex);
}

Просмотреть файл

@ -37,7 +37,7 @@ let matchTests = [
info: "Match Test 1 (Rules): sina.com.cn",
url: "http://foo.bar.sina.com.cn/video?kw=aa",
title: "电视剧影视频道",
expectedInterests: [{"type":"rules","interests":["News","Video","TV Series"]}],
expectedInterests: [{"type":"rules","interests":[{"category":"News","subcat":"general"},{"category":"Video","subcat":"general"},{"category":"TV Series","subcat":"general"}]}],
}];
exports["test default matcher"] = function test_default_matcher(assert, done) {

Просмотреть файл

@ -80,103 +80,103 @@ let matchTests = [
info: "Match Test 1 (Rules): mozilla.org",
url: "http://www.mozilla.org",
title: "Hello World",
expectedInterests: [{"type":"rules","interests":["computers"]}],
expectedInterests: [{"type":"rules","interests":[{"category":"computers","subcat":"general"}]}],
},
{
info: "Match Test 2 (Rules): weather gov",
url: "http://nws.noaa.gov",
title: "Hello World",
expectedInterests: [{"type":"rules","interests":["government","weather","science"]}],
expectedInterests: [{"type":"rules","interests":[{"category":"government","subcat":"general"},{"category":"weather","subcat":"general"},{"category":"science","subcat":"general"}]}],
},
{
info: "Match Test 3 (Rules): mail.google.com example",
url: "https://mail.google.com/mail/u/0/?ui=2&shva=1#inbox?compose=13e0005db4a0d0d4",
title: "",
expectedInterests: [{"type":"rules","interests":[]}],
expectedInterests: [{"type":"rules","interests":[{"category":"uncategorized","subcat":"dummy"}]}],
},
{
info: "Match Test 4 (Rules): www.news.com home url",
url: "https://www.news.com",
title: "",
expectedInterests: [{"type":"rules","interests":["news","news_home"]}],
expectedInterests: [{"type":"rules","interests":[{"category":"news","subcat":"general"},{"category":"news_home","subcat":"general"}]}],
},
{
info: "Match Test 5 (Rules): www.news.com page url",
url: "https://www.news.com/page_url",
title: "",
expectedInterests: [{"type":"rules","interests":["news"]}],
expectedInterests: [{"type":"rules","interests":[{"category":"news","subcat":"general"}]}],
},
{
info: "Match Test 6 (Rules): www.news.com query url",
url: "https://www.news.com?page=1",
title: "",
expectedInterests: [{"type":"rules","interests":["news","news_home"]}],
expectedInterests: [{"type":"rules","interests":[{"category":"news","subcat":"general"},{"category":"news_home","subcat":"general"}]}],
},
{
info: "Match Test 7 (Rules): www.testpathdomain.com query url",
url: "https://www.testpathdomain.com/CODE?qw=aa",
title: "CPlusPlus programming",
expectedInterests: [{"type":"rules","interests":["programming","oop"]}],
expectedInterests: [{"type":"rules","interests":[{"category":"programming","subcat":"general"},{"category":"oop","subcat":"general"}]}],
},
{
info: "Match Test 8 (Rules): www.stack.com query url",
url: "https://www.stack.com/code/js?qw=aa",
title: "js programming",
expectedInterests: [{"type":"rules","interests":["js"]}],
expectedInterests: [{"type":"rules","interests":[{"category":"js","subcat":"general"}]}],
},
{
info: "Match Test 9 (Rules): __ANY golf",
url: "https://www.stack.com/golf/js?qw=aa",
title: "js programming",
expectedInterests: [{"type":"rules","interests":["golf"]}],
expectedInterests: [{"type":"rules","interests":[{"category":"golf","subcat":"general"}]}],
},
{
info: "Match Test 10 (Rules): .app",
url: "https://app.dev.google.com/",
title: "js programming",
expectedInterests: [{"type":"rules","interests":["app"]}],
expectedInterests: [{"type":"rules","interests":[{"category":"app","subcat":"general"}]}],
},
{
info: "Match Test 11 (Rules): real_estate",
url: "https://dev.google.com/real_estate/",
title: "js programming",
expectedInterests: [{"type":"rules","interests":["real estate"]}],
expectedInterests: [{"type":"rules","interests":[{"category":"real estate","subcat":"general"}]}],
},
{
info: "Match Test 12 (Rules): golf subdomain",
url: "https://golf.google.com/golf",
title: "tornament",
expectedInterests: [{"type":"rules","interests":["golf","tiger"]}],
expectedInterests: [{"type":"rules","interests":[{"category":"golf","subcat":"general"},{"category":"tiger","subcat":"general"}]}],
},
{
info: "Match Test 13 (Rules): frontline bigram",
url: "https://google.com",
title: "front line",
expectedInterests: [{"type":"rules","interests":["test"]}],
expectedInterests: [{"type":"rules","interests":[{"category":"test","subcat":"general"}]}],
},
{
info: "Match Test 14 (Rules): travel in subdomain",
url: "https://travel.google.com",
title: "travel",
expectedInterests: [{"type":"rules","interests":["travel"]}],
expectedInterests: [{"type":"rules","interests":[{"category":"travel","subcat":"general"}]}],
},
{
info: "Match Test 14 (Rules): travel in path",
url: "https://google.com/travel",
title: "travel",
expectedInterests: [{"type":"rules","interests":["travel"]}],
expectedInterests: [{"type":"rules","interests":[{"category":"travel","subcat":"general"}]}],
},
{
info: "Match Test 14 (Rules): travel in query",
url: "https://google.com/search?q=travel",
title: "travel",
expectedInterests: [{"type":"rules","interests":["travel"]}],
expectedInterests: [{"type":"rules","interests":[{"category":"travel","subcat":"general"}]}],
},
{
info: "Match Test 14 (Rules): travel in title",
url: "https://google.com/search?q=foo",
title: "travel",
expectedInterests: [{"type":"rules","interests":[]}],
expectedInterests: [{"type":"rules","interests":[{"category":"uncategorized","subcat":"dummy"}]}],
},
];

Просмотреть файл

@ -23,12 +23,10 @@ exports["test interest classifier"] = function test_UrlClassifier(assert, done)
let urlClassifier = new UrlClassifier(workers);
let results = yield urlClassifier.classifyPage("http://www.autoblog.com/","Drive honda");
assert.equal(Object.keys(results).length, workers.length);
assert.deepEqual(results["58-cat"].results,
[{"type": "lwca", interests: ["uncategorized"], subcat: "dummy"},
{"type":"rules","interests":["cars"]}
]);
assert.deepEqual(results["edrules"].results,
[{"type":"rules","interests":["Autos"]}]);
assert.deepEqual(results.edrules.results,
[{"type": "rules", interests: [{category: "Autos", subcat: "general"}]}]);
assert.deepEqual(results.dfr_rules.results,
[{"type": "rules", interests: [{category: "uncategorized", subcat: "dummy"}]}]);
// test for an error
yield urlClassifier.classifyPage("not a url").then(result => {
assert.ok(false);
@ -39,8 +37,10 @@ exports["test interest classifier"] = function test_UrlClassifier(assert, done)
// classify only the text
results = yield urlClassifier.classifyPage(null, "iphone, ipad, apple, product, phone");
assert.deepEqual(results["edrules"].results,
[{"type":"rules","interests":[]}]);
assert.deepEqual(results.edrules.results,
[{"type": "rules", interests: [{category: "uncategorized", subcat: "dummy"}]}]);
assert.deepEqual(results.dfr_rules.results,
[{"type": "rules", interests: [{category: "uncategorized", subcat: "dummy"}]}]);
}).then(done);
}

Просмотреть файл

@ -27,9 +27,9 @@ let interestMessage = {
"metaData": {},
"language": "en",
"messageId": "resubmit",
"namespace": "58-cat",
"namespace": "edrules",
"results": [
{"type":"lwca","interests":["Education"]},
{"type":"rules","interests": [{category: "Education", subcat: "general"}]},
],
"visitIDs": {},
};
@ -123,7 +123,7 @@ exports["test ignore latest day visit unless flush"] = function test_TodayVisits
doAssert = function(message) {
assertDeferred.resolve();
assert.ok(message.hasOwnProperty(today), "today's count should be present");
assert.equal(message[today]["lwca"]["58-cat"]["Education"]["hosts"]["w3schools.com"], 3, "today's visit count should have accumulated");
assert.equal(message[today].rules.edrules["Education"]["hosts"]["w3schools.com"], 3, "today's visit count should have accumulated");
}
dateVisits = {};
dateVisits[today] = 2; // assertion checks if 2 is added to the 1 count set before