Skip to content
Snippets Groups Projects
Commit 390e7609 authored by Adam Williamson's avatar Adam Williamson Committed by Adam Williamson
Browse files

test_listing: add test_list_invalid to improve test coverage


This covers the `if self.result_member not in data['query']`
branch of `set_iter`.

Signed-off-by: default avatarAdam Williamson <awilliam@redhat.com>
parent 8fdfde0c
No related branches found
No related tags found
No related merge requests found
......@@ -192,7 +192,33 @@ class TestList(unittest.TestCase):
return_values=('title', 'ns'))
mock_site.get.side_effect = [{}]
vals = [x for x in lst]
assert len(vals) == 0
@mock.patch('mwclient.client.Site')
def test_list_invalid(self, mock_site):
# Test that we handle the response for a list that doesn't
# exist correctly (set an empty iterator, then stop
# iterating)
mock_site.api_limit = 500
lst = List(mock_site, 'allpagess', 'ap')
mock_site.get.side_effect = [
{
'batchcomplete': '',
'warnings': {
'main': {'*': 'Unrecognized parameter: aplimit.'},
'query': {'*': 'Unrecognized value for parameter "list": allpagess'}
},
'query': {
'userinfo': {
'id': 0,
'name': 'DEAD:BEEF:CAFE',
'anon': ''
}
}
}
]
vals = [x for x in lst]
assert len(vals) == 0
@mock.patch('mwclient.client.Site')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment