Skip to content

Commit 0a6f243

Browse files
committed
Added test_page_get_query_continue for #129
1 parent 4604edd commit 0a6f243

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

tests/query_plcontinue.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# -*- coding:utf-8 -*-
2+
3+
query = 'https://en.wikipedia.org/w/api.php?action=query&formatversion=2&pllimit=500&prop=links&list=random&titles=List_of_programming_languages'
4+
5+
response = r"""
6+
{
7+
"continue": {
8+
"plcontinue": "144146|0|Perl_Data_Language",
9+
"continue": "||"
10+
},
11+
"query": {
12+
"pages": [
13+
{
14+
"pageid": 144146,
15+
"ns": 0,
16+
"title": "List of programming languages",
17+
"links": [
18+
{
19+
"ns": 0,
20+
"title": "A++"
21+
}
22+
]
23+
}
24+
],
25+
"random": [
26+
{
27+
"id": 123,
28+
"ns": 0,
29+
"title": "RANDOM"
30+
}
31+
]
32+
}
33+
}
34+
"""
35+
36+
cache = {'query': query,
37+
'response': response,
38+
'info': {'content-type': 'TEST', 'status': 200}}

tests/test_basic.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from . import parse_91
2424
from . import parse_109
2525
from . import query
26+
from . import query_plcontinue
2627
from . import querymore
2728
from . import querymore_blcontinue
2829
from . import random_query
@@ -500,8 +501,25 @@ def test_page_get_more(self):
500501

501502
self.assertTrue('requests' not in page.data)
502503

504+
def test_page_get_query_continue(self):
505+
page = wptools.page('TEST', skip=SKIP_FLAG, silent=SILENT_FLAG)
506+
507+
page.cache['query'] = query.cache
508+
page._set_data('query')
509+
self.assertEqual(len(page.data['links']), 384)
510+
511+
page.cache = {'query': query_plcontinue.cache}
512+
page._set_data('query')
513+
self.assertTrue('continue' in page.data)
514+
self.assertEqual(page.data['continue'],
515+
{'plcontinue': u'144146|0|Perl_Data_Language'})
516+
self.assertEqual(len(page.data['links']), 385)
517+
518+
qry = page._query('query', wptools.query.WPToolsQuery())
519+
self.assertTrue(qry.endswith('&plcontinue=144146|0|Perl_Data_Language'))
520+
503521
def test_page_get_more_continue(self):
504-
page = wptools.page('TEST', silent=SILENT_FLAG)
522+
page = wptools.page('TEST', skip=SKIP_FLAG, silent=SILENT_FLAG)
505523

506524
page.cache['querymore'] = querymore.cache
507525
page._set_data('querymore')

0 commit comments

Comments
 (0)