File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# -*- coding: utf-8 -*-
22
3- class Range (object ):
3+ from .data import DataDict
4+
5+ class Range (DataDict ):
46 def __init__ (self , field , json ):
5- self .max = float (json ['max' ])
6- self .min = float (json ['min' ])
7- self .nulls = int (json ['nulls' ])
7+ DataDict .__init__ (self )
88 self ._field = field
9+ self .append ('min' , float (json ['min' ]))
10+ self .append ('max' , float (json ['max' ]))
11+ self .append ('null' , int (json ['nulls' ]))
912
1013 def __repr__ (self ):
11- return 'OPUS API Range endpoints for field: {}' .format (self ._field )
14+ return 'OPUS API Range endpoints for field: `{}`\n ' .format (self ._field ) + \
15+ '\n ' .join (' - {} : {}' .format (key , value ) for key , value in self .items ())
Original file line number Diff line number Diff line change @@ -275,10 +275,10 @@ def test_api_range(api):
275275 assert responses .calls [0 ].request .url == 'http://localhost/meta/range/endpoints/ringradius1.json?target=Saturn'
276276 assert responses .calls [0 ].response .text == range_endpoints
277277
278- assert repr ( resp ) == 'OPUS API Range endpoints for field: ringradius1'
279- assert resp . min == 60000
280- assert resp . max == 1.29e+07
281- assert resp . nulls == 115573
278+ assert 'OPUS API Range endpoints for field: ` ringradius1`' in repr ( resp )
279+ assert resp [ ' min' ] == 60000
280+ assert resp [ ' max' ] == 1.29e+07
281+ assert resp [ 'null' ] == 115573
282282
283283
284284@responses .activate
You can’t perform that action at this time.
0 commit comments