-
-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #954 from openzim/ISNIT0/parsoid-slash-rewriting
🐛 rewrite '/'s in urls for Parsoid articles, not just MCS
- Loading branch information
Showing
2 changed files
with
69 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import test from 'blue-tape'; | ||
import { execute } from '../../src/mwoffliner.lib'; | ||
import { zimcheckAvailable, zimcheck } from '../util'; | ||
import rimraf from 'rimraf'; | ||
import { execPromise, writeFilePromise, mkdirPromise } from '../../src/util'; | ||
import { join } from 'path'; | ||
// import { ZimReader } from '@openzim/libzim'; | ||
// tslint:disable-next-line: no-var-requires | ||
require('dotenv').config(); | ||
|
||
const now = new Date(); | ||
const testId = join(process.cwd(), `mwo-test-${+now}`); | ||
|
||
const articleListUrl = join(testId, '/articleList'); | ||
|
||
test.only('Simple customMainPage', async (t) => { | ||
await execPromise(`redis-cli flushall`); | ||
await mkdirPromise(testId); | ||
|
||
const articleListLines = ` | ||
Book:Cancer | ||
Book:Ears_nose_throat | ||
Book:Eye_diseases`; | ||
|
||
await writeFilePromise(articleListUrl, articleListLines, 'utf8'); | ||
|
||
const outFiles = await execute({ | ||
mwUrl: `https://en.wikipedia.org`, | ||
adminEmail: `[email protected]`, | ||
articleList: articleListUrl, | ||
customMainPage: 'Wikipedia:WikiProject_Medicine/Open_Textbook_of_Medicine2', | ||
outputDirectory: testId, | ||
redis: process.env.REDIS, | ||
format: ['nopic'], | ||
}); | ||
|
||
t.equal(outFiles.length, 1, `Created 1 outputs`); | ||
|
||
for (const dump of outFiles) { | ||
if (dump.nopic) { | ||
t.equal(dump.status.articles.success, 4, 'nopic has 4 articles'); | ||
} | ||
|
||
if (await zimcheckAvailable()) { | ||
try { | ||
await zimcheck(dump.outFile); | ||
t.ok(true, `Zimcheck passes`); | ||
} catch (err) { | ||
t.ok(false, `Zimcheck passes`); | ||
} | ||
} else { | ||
console.log(`Zimcheck not installed, skipping test`); | ||
} | ||
} | ||
|
||
t.ok(true, 'Scraped customMainPage'); | ||
// TODO: clear test dir | ||
rimraf.sync(testId); | ||
|
||
const redisScan = await execPromise(`redis-cli --scan`); | ||
t.equal(redisScan, '', 'Redis has been cleared'); | ||
}); |