-
-
Notifications
You must be signed in to change notification settings - Fork 74
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 #1919 from openzim/namespace-blacklist
Don't mirror 'Story' namespace
- Loading branch information
Showing
3 changed files
with
45 additions
and
12 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
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 |
---|---|---|
|
@@ -9,26 +9,32 @@ import { jest } from '@jest/globals' | |
|
||
jest.setTimeout(10000) | ||
|
||
describe('mwApi', () => { | ||
beforeAll(startRedis) | ||
afterAll(stopRedis) | ||
beforeAll(async () => { | ||
MediaWiki.reset() | ||
await startRedis() | ||
}) | ||
afterAll(stopRedis) | ||
|
||
const initMW = async (downloader: Downloader) => { | ||
await MediaWiki.getMwMetaData(downloader) | ||
await MediaWiki.hasCoordinates(downloader) | ||
await MediaWiki.hasWikimediaDesktopRestApi() | ||
await MediaWiki.hasVisualEditorApi() | ||
|
||
await MediaWiki.getNamespaces([], downloader) | ||
} | ||
|
||
describe('mwApi', () => { | ||
let downloader: Downloader | ||
|
||
beforeEach(async () => { | ||
await RedisStore.articleDetailXId.flush() | ||
|
||
MediaWiki.base = 'https://en.wikipedia.org' | ||
MediaWiki.getCategories = true | ||
|
||
downloader = new Downloader({ uaString: `${config.userAgent} ([email protected])`, speed: 1, reqTimeout: 1000 * 60, webp: false, optimisationCacheUrl: '' }) | ||
|
||
await MediaWiki.getMwMetaData(downloader) | ||
await MediaWiki.hasCoordinates(downloader) | ||
await MediaWiki.hasWikimediaDesktopRestApi() | ||
await MediaWiki.hasVisualEditorApi() | ||
|
||
await MediaWiki.getNamespaces([], downloader) | ||
await initMW(downloader) | ||
}) | ||
|
||
test('MWApi Article Ids', async () => { | ||
|
@@ -116,3 +122,25 @@ describe('mwApi', () => { | |
expect(interWikiTitle).toBeNull() | ||
}) | ||
}) | ||
|
||
describe('Test blacklisted NSs', () => { | ||
let downloader: Downloader | ||
|
||
beforeEach(async () => { | ||
await RedisStore.articleDetailXId.flush() | ||
|
||
MediaWiki.base = 'https://id.wikipedia.org' | ||
MediaWiki.getCategories = true | ||
|
||
downloader = new Downloader({ uaString: `${config.userAgent} ([email protected])`, speed: 1, reqTimeout: 1000 * 60, webp: false, optimisationCacheUrl: '' }) | ||
|
||
await initMW(downloader) | ||
}) | ||
|
||
test('Prevent blacklisted namespaces to mirroring', async () => { | ||
const aIds = ['Story:Satelit_Oberon', 'London'] | ||
await getArticleIds(downloader, 'Main_Page', aIds) | ||
|
||
expect(MediaWiki.namespacesToMirror).not.toContain('Story') | ||
}) | ||
}) |