def test_get_sizes(self): # Check normal size calculations b = Bounds.from_bbox_string('1,50,21,52') assert b.get_width() == 20 assert b.get_height() == 2 assert b.get_size() == 40 # Check longitude wraparound and height == 0 b = Bounds.from_bbox_string('170,50,-165,50') assert b.get_width() == 25 assert b.get_height() == 0 assert b.get_size() == 0
def test_get_sizes(): # Check normal size calculations b = Bounds.from_bbox_string("1,50,21,52") assert b.get_width() == 20 assert b.get_height() == 2 assert b.get_size() == 40 # Check longitude wraparound and height == 0 b = Bounds.from_bbox_string("170,50,-165,50") assert b.get_width() == 25 assert b.get_height() == 0 assert b.get_size() == 0
def test_get_sizes(self): # Check normal size calculations b = Bounds.from_bbox_string('1,50,21,52') eq_(b.get_width(), 20) eq_(b.get_height(), 2) eq_(b.get_size(), 40) # Check longitude wraparound and height == 0 b = Bounds.from_bbox_string('170,50,-165,50') eq_(b.get_width(), 25) eq_(b.get_height(), 0) eq_(b.get_size(), 0)
def test_from_bbox_string(self): # Check that strings with more or less than 4 components # raise ValueError assert_raises(ValueError, Bounds.from_bbox_string, '1,2,3') Bounds.from_bbox_string('1,2,3,4') assert_raises(ValueError, Bounds.from_bbox_string, '1,2,3,4,5') # Check that non-numeric values raise ValueError assert_raises(ValueError, Bounds.from_bbox_string, '1,a,3,4') # Check that BBox strings are parsed correctly b = Bounds.from_bbox_string('6.05,49.5,7,51.0') eq_(b.southwest.latitude, 49.5) eq_(b.southwest.longitude, 6.05) eq_(b.northeast.latitude, 51) eq_(b.northeast.longitude, 7)
def test_from_bbox_string(self): # Check that strings with more or less than 4 components # raise ValueError with pytest.raises(ValueError): Bounds.from_bbox_string('1,2,3') Bounds.from_bbox_string('1,2,3,4') with pytest.raises(ValueError): Bounds.from_bbox_string('1,2,3,4,5') # Check that non-numeric values raise ValueError with pytest.raises(ValueError): Bounds.from_bbox_string('1,a,3,4') # Check that BBox strings are parsed correctly b = Bounds.from_bbox_string('6.05,49.5,7,51.0') assert b.southwest.latitude == 49.5 assert b.southwest.longitude == 6.05 assert b.northeast.latitude == 51 assert b.northeast.longitude == 7
def test_from_bbox_string(): # Check that strings with more or less than 4 components # raise ValueError with pytest.raises(ValueError): Bounds.from_bbox_string("1,2,3") Bounds.from_bbox_string("1,2,3,4") with pytest.raises(ValueError): Bounds.from_bbox_string("1,2,3,4,5") # Check that non-numeric values raise ValueError with pytest.raises(ValueError): Bounds.from_bbox_string("1,a,3,4") # Check that BBox strings are parsed correctly b = Bounds.from_bbox_string("6.05,49.5,7,51.0") assert b.southwest.latitude == 49.5 assert b.southwest.longitude == 6.05 assert b.northeast.latitude == 51 assert b.northeast.longitude == 7
def _deserialize(self, value, attr, data): try: return Bounds.from_bbox_string(value) except ValueError as e: raise ValidationError(e.message)