Commit a2ca395c authored by Alexandra Rogova's avatar Alexandra Rogova

added content compression test script

parent 96bd16ab
const puppeteer = require('puppeteer');
const args = require("yargs")
.usage("Usage : download_content.js -file file_path")
.demandOption(['file'])
.alias("f", "file")
.describe("file", "file containing content, data must follow the CSV standard")
.nargs("file", 1)
.argv;
(async () => {
var browser = await puppeteer.launch({headless: false});
var page = await browser.newPage();
await page.goto('https://softinst115787.host.vifib.net/public/unit_tests/download_content.html');
const [fileChooser] = await Promise.all([
page.waitForFileChooser(),
page.click('input#load')
]);
await fileChooser.accept([args.file]);
})();
const puppeteer = require('puppeteer');
const randomstring = require("randomstring");
const tmp = require('tmp');
const fs = require('fs');
const args = require("yargs")
.usage("Usage : download_content_random.js -p number of random paragraphs to add to the index")
.demandOption(['paragraphs'])
.alias("p", "paragraphs")
.describe("paragraphs", "Number of random paragraphs to generate")
.nargs("prom", 1)
.argv;
function gen_rdm_string (length){
return randomstring.generate({
length: length,
charset: 'alphabetic'
});
}
function gen_rdm_sentence (word_count, word_length){
var tmp_word_array = [];
for (var i = 0; i<word_count; i+=1){
tmp_word_array[i] = gen_rdm_string(word_length);
}
return tmp_word_array.join(" ");
}
function gen_rdm_paragraph (sentence_count, words_per_sentence, word_length){
var tmp_sentence_array = [];
for (var i=0; i<sentence_count; i+=1){
tmp_sentence_array[i] = gen_rdm_sentence(words_per_sentence, word_length);
}
return tmp_sentence_array.join(". ");
}
function gen_random_content (){
var tmp_para_array = [];
for(var i=0; i<args.p; i+=1){
tmp_para_array[i] = gen_rdm_paragraph(6, 15, 5);
}
var tmp_file = tmp.fileSync();
fs.writeFileSync(tmp_file.name, tmp_para_array.join("\n"));
return tmp_file.name;
}
(async () => {
var file_path = gen_random_content();
var browser = await puppeteer.launch({headless: false});
var page = await browser.newPage();
await page.goto('https://softinst115787.host.vifib.net/public/unit_tests/download_content.html');
const [fileChooser] = await Promise.all([
page.waitForFileChooser(),
page.click('input#load')
]);
await fileChooser.accept([file_path]);
})();
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment