Skip to content

Commit

Permalink
Merge pull request #180 from CartoDB/add-encode-geom-test-check
Browse files Browse the repository at this point in the history
adds another check
  • Loading branch information
andy-esch committed Aug 5, 2017
2 parents b61a482 + cf21ce7 commit f65f888
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions test/test_context.py
Expand Up @@ -402,7 +402,6 @@ def test_drop_tables_query(self):
def test_add_encoded_geom(self):
"""context._add_encoded_geom"""
from cartoframes.context import _add_encoded_geom, _encode_geom
# import shapely
cc = cartoframes.CartoContext(base_url=self.baseurl,
api_key=self.apikey)

Expand All @@ -419,10 +418,9 @@ def test_add_encoded_geom(self):
# geometry column should equal the_geom after function call
self.assertTrue(df['the_geom'].equals(df['geometry'].apply(_encode_geom)))

# try another way
# don't specify geometry column (should exist since decode_geom==True)
df = cc.read(self.test_read_table, limit=5,
decode_geom=True)

df['geometry'] = df['geometry'].apply(lambda x: x.buffer(0.2))

# the_geom should reflect encoded 'geometry' column
Expand All @@ -431,6 +429,12 @@ def test_add_encoded_geom(self):
# geometry column should equal the_geom after function call
self.assertTrue(df['the_geom'].equals(df['geometry'].apply(_encode_geom)))

df = cc.read(self.test_read_table, limit=5)

# raise error if 'geometry' column does not exist
with self.assertRaises(KeyError):
_add_encoded_geom(df, None)

def test_decode_geom(self):
"""context._decode_geom"""
from cartoframes.context import _decode_geom
Expand Down

0 comments on commit f65f888

Please sign in to comment.