Changeset 3743 for framework

Show
Ignore:
Timestamp:
03/07/11 10:12:03 (15 months ago)
Author:
elemoine
Message:

add tests to verify that Boolean columns/properties are dealt with correctly, no functional change

Location:
framework/server/trunk/mapfish/tests
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • framework/server/trunk/mapfish/tests/test_decorators.py

    r3659 r3743  
    5050        return Feature(id=1, 
    5151                       geometry=Point(1, 2), 
    52                        properties={"key": "val"} 
     52                       properties={"strkey": "strval", "boolkey": True} 
    5353                       ) 
    5454 
     
    6565        return Feature(id=1, 
    6666                       geometry=Point(1, 2), 
    67                        properties={"key": "val"} 
     67                       properties={"strkey": "strval", "boolkey": True} 
    6868                       ) 
    6969 
     
    8888        assert response.status == 200 
    8989        assert response.response.content_type == 'application/json' 
    90         assert response.body == '{"geometry": {"type": "Point", "coordinates": [1.0, 2.0]}, "type": "Feature", "properties": {"key": "val"}, "id": 1}' 
     90        assert response.body == '{"geometry": {"type": "Point", "coordinates": [1.0, 2.0]}, "type": "Feature", "properties": {"boolkey": true, "strkey": "strval"}, "id": 1}' 
    9191 
    9292    def test_feature_collection(self): 
     
    101101        assert response.status == 200 
    102102        assert response.response.content_type == 'text/javascript' 
    103         assert response.body == 'jsfunc({"geometry": {"type": "Point", "coordinates": [1.0, 2.0]}, "type": "Feature", "properties": {"key": "val"}, "id": 1});' 
     103        assert response.body == 'jsfunc({"geometry": {"type": "Point", "coordinates": [1.0, 2.0]}, "type": "Feature", "properties": {"boolkey": true, "strkey": "strval"}, "id": 1});' 
  • framework/server/trunk/mapfish/tests/test_postgis.py

    r3715 r3743  
    3333 
    3434from sqlalchemy.ext.declarative import declarative_base 
    35 from sqlalchemy import (create_engine, MetaData, Column, Integer, Numeric) 
     35from sqlalchemy import (create_engine, MetaData, Column, Integer, Numeric, Boolean) 
    3636from sqlalchemy import orm 
    3737 
     
    6060    spot_id = Column(Integer, primary_key=True) 
    6161    spot_height = Column(Numeric(asdecimal=False)) 
     62    spot_goodness = Column(Boolean) 
    6263    spot_location = GeometryColumn(Point(2)) 
    6364 
     
    8384        # Insert some points into the database 
    8485        session.add_all([ 
    85             Spot(spot_height=420.40, spot_location='POINT(0 0)'), 
    86             Spot(spot_height=102.34, spot_location='POINT(10 10)'), 
    87             Spot(spot_height=388.62, spot_location='POINT(10 11)'), 
    88             Spot(spot_height=1454.66, spot_location='POINT(40 34)'), 
    89             Spot(spot_height=54.66, spot_location='POINT(5 5)'), 
    90             Spot(spot_height=333.12, spot_location='POINT(2 3)'), 
    91             Spot(spot_height=783.55, spot_location='POINT(38 34)'), 
    92             Spot(spot_height=3454.67, spot_location='POINT(-134 45)'), 
    93             Spot(spot_height=6454.23, spot_location=None) 
     86            Spot(spot_height=420.40, spot_location='POINT(0 0)', spot_goodness=True), 
     87            Spot(spot_height=102.34, spot_location='POINT(10 10)', spot_goodness=True), 
     88            Spot(spot_height=388.62, spot_location='POINT(10 11)', spot_goodness=True), 
     89            Spot(spot_height=1454.66, spot_location='POINT(40 34)', spot_goodness=True), 
     90            Spot(spot_height=54.66, spot_location='POINT(5 5)', spot_goodness=True), 
     91            Spot(spot_height=333.12, spot_location='POINT(2 3)', spot_goodness=True), 
     92            Spot(spot_height=783.55, spot_location='POINT(38 34)', spot_goodness=True), 
     93            Spot(spot_height=3454.67, spot_location='POINT(-134 45)', spot_goodness=True), 
     94            Spot(spot_height=6454.23, spot_location=None, spot_goodness=False) 
    9495            ]) 
    9596         
     
    107108         
    108109        request = FakeRequest({}) 
    109         request.body = '{"type": "FeatureCollection", "features": [{"type": "Feature", "properties": {"spot_height": 12.0}, "geometry": {"type": "Point", "coordinates": [45, 5]}}]}' 
     110        request.body = '{"type": "FeatureCollection", "features": [{"type": "Feature", "properties": {"spot_height": 12.0, "spot_goodness": true}, "geometry": {"type": "Point", "coordinates": [45, 5]}}]}' 
    110111         
    111112        response = FakeResponse() 
     
    117118        eq_(feature0.geometry.coordinates, (45.0, 5.0)) 
    118119        eq_(feature0.properties["spot_height"], 12) 
     120        eq_(feature0.properties["spot_goodness"], True) 
    119121 
    120122        new_spot = session.query(Spot).filter(Spot.spot_height==12.0).one() 
    121123        ok_(new_spot is not None) 
    122124        eq_(session.scalar(new_spot.spot_location.wkt), u'POINT(45 5)') 
     125        eq_(new_spot.spot_goodness, True) 
    123126         
    124127 
     
    329332        eq_(feature.geometry.coordinates, (0.0, 0.0)) 
    330333        eq_(feature.properties["spot_height"], 420.39999999999998) 
     334        eq_(feature.properties["spot_goodness"], True) 
    331335 
    332336