def test_locations_must_have_valid_states(mockdata): with raises(ValueError): Location(street_name='Brookford St', cross_street1='Mass Ave', cross_street2='None', city='Cambridge', state='JK', zip_code='54340')
def test_locations_can_be_saved_with_valid_zip_codes(mockdata): zip_code = '03456' city = 'Cambridge' lo = Location(street_name='Brookford St', cross_street1='Mass Ave', cross_street2='None', city=city, state='MA', zip_code=zip_code) db.session.add(lo) db.session.commit() saved = Location.query.filter_by(zip_code=zip_code, city=city) assert saved is not None
def test_locations_can_be_saved_with_valid_states(mockdata): state = 'AZ' city = 'Cambridge' lo = Location(street_name='Brookford St', cross_street1='Mass Ave', cross_street2='None', city=city, state=state, zip_code='54340') db.session.add(lo) db.session.commit() saved = Location.query.filter_by(city=city, state=state).first() assert saved is not None