6 def __init__(self
, error_out
=False):
7 self
.error_out
= error_out
9 def get(self
, url
, params
, headers
, verify
=False, stream
=False):
12 {"error": {"code": "an error", "message": "a message"}})
17 str(rev_id
): {model
: {"score": "my score"}
18 for model
in params
['models'].split("|")}
19 for rev_id
in params
['revids'].split("|")
27 def __init__(self
, doc
):
34 def test_fake_session():
35 session
= FakeSession(error_out
=True)
36 response
= session
.get(None, None, None)
42 session1
= api
.Session("myhost", session
=FakeSession())
43 scores
= list(session1
.score("context", ["foo", "bar"], range(0, 100)))
44 assert len(scores
) == 100
45 assert scores
[0] == {"foo": {"score": "my score"},
46 "bar": {"score": "my score"}}
49 def test_base_error():
50 session2
= api
.Session("myhost", session
=FakeSession(error_out
=True))
51 scores
= list(session2
.score("context", ["foo", "bar"], range(0, 100)))
52 assert len(scores
) == 100
53 assert scores
[0]['foo']['error'] == \
54 {'code': 'an error', 'message': 'a message'}