-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
41 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,31 @@ | ||
"""Tests for cursor""" | ||
from nose.tools import * | ||
import os | ||
from habanero import Crossref | ||
cr = Crossref() | ||
|
||
def test_cursor_works(): | ||
def test_cursor(): | ||
"cursor works - basic test" | ||
res = cr.works(query = "widget", cursor = "*", cursor_max = 10) | ||
assert dict == res.__class__ | ||
assert dict == res['message'].__class__ | ||
assert 4 == len(res) | ||
assert 6 == len(res['message']) | ||
|
||
def test_cursor_max(): | ||
"cursor works - cursor_max works" | ||
res1 = cr.works(query = "widget", cursor = "*", cursor_max = 60) | ||
items1 = [ z['message']['items'] for z in res1 ] | ||
items1 = [ item for sublist in items1 for item in sublist ] | ||
res2 = cr.works(query = "widget", cursor = "*", cursor_max = 40) | ||
items2 = [ z['message']['items'] for z in res2 ] | ||
items2 = [ item for sublist in items2 for item in sublist ] | ||
assert list == res1.__class__ | ||
assert list == res2.__class__ | ||
assert 60 == len(items1) | ||
assert 40 == len(items2) | ||
|
||
@raises(Exception) | ||
def test_cursor_fails(): | ||
"cursor works - fails well" | ||
cr.works(query = "widget", cursor = "thing") |
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