Add deprecation warning with pointers to WMF's pages on the topic (#365)
[ores.git] / tests / test_score_request.py
blob3819682040e4f89eb5072b26e9bf46492ed68d9c
1 from ores.score_request import ScoreRequest
4 def test_score_request():
5 sr = ScoreRequest("foo", [1, 2, 3], ["bar", "baz"], ip='0.0.0.0')
7 assert sr.context_name == "foo"
8 assert sr.rev_ids == {1, 2, 3}
9 assert sr.model_names == {"bar", "baz"}
10 assert sr.precache is False
11 assert sr.include_features is False
12 assert sr.model_info is None
13 assert sr.ip == '0.0.0.0'
16 def test_score_request_serialization():
17 sr = ScoreRequest("foo", [1, 2, 3], ["bar", "baz"], ip='0.0.0.0')
18 actual = sr.to_json()
19 actual['model_names'].sort()
20 actual['rev_ids'].sort()
22 assert actual == {
23 'context': 'foo',
24 'include_features': False,
25 'injection_caches': {},
26 'ip': '0.0.0.0',
27 'model_info': None,
28 'model_names': ['bar', 'baz'],
29 'precache': False,
30 'rev_ids': [1, 2, 3]}
33 def test_score_request_deserialization():
34 sr = ScoreRequest("foo", [1, 2, 3], ["bar", "baz"], ip='0.0.0.0')
35 sr_new = ScoreRequest.from_json({
36 'context': 'foo',
37 'include_features': False,
38 'injection_caches': {},
39 'ip': '0.0.0.0',
40 'model_info': None,
41 'model_names': {'bar', 'baz'},
42 'precache': False,
43 'rev_ids': {1, 2, 3}})
45 assert sr.to_json() == sr_new.to_json()