def test_geojson_is_correct(self): f = Feature(coordinates=[-90, D('171.0')], properties={'record_id': 'my_id'}, strict_lon_validation=True) stringy = f.to_json() self.failUnlessEqual( stringy, '{"geometry": {"type": "Point", "coordinates": [171.0, -90]}, "type": "Feature", "id": null, "properties": {"record_id": "my_id", "private": false}}' )
def test_get_feature(self): handle = 'SG_abcdefghijklmnopqrstuv' resultfeature = Feature((D('11.03'), D('10.03')), simplegeohandle=handle) mockhttp = mock.Mock() mockhttp.request.return_value = ({ 'status': '200', 'content-type': 'application/json', }, resultfeature.to_json()) self.client.places.http = mockhttp res = self.client.places.get_feature(handle) self.assertEqual(mockhttp.method_calls[0][0], 'request') self.assertEqual( mockhttp.method_calls[0][1][0], 'http://api.simplegeo.com:80/%s/features/%s.json' % (API_VERSION, handle)) self.assertEqual(mockhttp.method_calls[0][1][1], 'GET') self.failUnless(isinstance(res, Feature), res) self.assertEqual(res.to_json(), resultfeature.to_json())
def test_get_feature(self): handle = 'SG_abcdefghijklmnopqrstuv' resultfeature = Feature((D('11.03'), D('10.03')), simplegeohandle=handle) mockhttp = mock.Mock() mockhttp.request.return_value = ({'status': '200', 'content-type': 'application/json', }, resultfeature.to_json()) self.client.places.http = mockhttp res = self.client.places.get_feature(handle) self.assertEqual(mockhttp.method_calls[0][0], 'request') self.assertEqual(mockhttp.method_calls[0][1][0], 'http://api.simplegeo.com:80/%s/features/%s.json' % (API_VERSION, handle)) self.assertEqual(mockhttp.method_calls[0][1][1], 'GET') self.failUnless(isinstance(res, Feature), res) self.assertEqual(res.to_json(), resultfeature.to_json())
def test_geojson_is_correct(self): f = Feature(coordinates=[-90, D('171.0')], properties={'record_id': 'my_id'}, strict_lon_validation=True) stringy = f.to_json() self.failUnlessEqual(stringy, '{"geometry": {"type": "Point", "coordinates": [171.0, -90]}, "type": "Feature", "id": null, "properties": {"record_id": "my_id", "private": false}}')