Repository: CartoDB/cartoframes
Pull request #1061 (2019-10-07 14:23:31)

Refactor docstrings documentation
I fixed some little issues related with the Dataset documentation


Patch:
diff --git a/cartoframes/data/dataset/dataset.py b/cartoframes/data/dataset/dataset.py
index 5f6171ff..bfcd947e 100644
--- a/cartoframes/data/dataset/dataset.py
+++ b/cartoframes/data/dataset/dataset.py
@@ -5,11 +5,8 @@ from ...auth import get_default_credentials
 from .registry.strategies_registry import StrategiesRegistry
 from .registry.dataframe_dataset import DataFrameDataset
 from .registry.table_dataset import TableDataset
+from .registry.base_dataset import BaseDataset
 from .dataset_info import DatasetInfo
-from ...utils.utils import GEOM_TYPE_POINT, GEOM_TYPE_LINE, GEOM_TYPE_POLYGON
-
-DOWNLOAD_RETRY_TIMES = 3
-
 
 class Dataset(object):
     """Generic data class for cartoframes data operations. A `Dataset` instance
@@ -62,7 +59,7 @@ class Dataset(object):
 
             Dataset('table_name')
 
-        Query usign CARTO stuff
+        Query usign CARTO
 
         .. code::
 
@@ -77,41 +74,20 @@ class Dataset(object):
             Dataset('select * from table_name WHERE ...')
     """
 
-    FAIL = TableDataset.FAIL
-    REPLACE = TableDataset.REPLACE
-    APPEND = TableDataset.APPEND
-
-    PRIVATE = DatasetInfo.PRIVATE
-    PUBLIC = DatasetInfo.PUBLIC
-    LINK = DatasetInfo.LINK
-
-    GEOM_TYPE_POINT = GEOM_TYPE_POINT
-    GEOM_TYPE_LINE = GEOM_TYPE_LINE
-    GEOM_TYPE_POLYGON = GEOM_TYPE_POLYGON
+    DOWNLOAD_RETRY_TIMES = 3
 
     def __init__(self, data, credentials=None, schema=None):
         self._registry = self._get_strategies_registry()
         self._strategy = self._init_strategy(data, credentials, schema)
 
-    def _init_strategy(self, data, credentials=None, schema=None):
-        credentials = credentials or get_default_credentials()
-        for strategy in self._registry.get_strategies():
-            if strategy.can_work_with(data):
-                return strategy.create(data, credentials, schema)
-
-        raise ValueError('We can not detect the Dataset type')
-
-    def _get_strategies_registry(self):
-        return StrategiesRegistry()
-
     @property
     def credentials(self):
-        """Dataset :py:class:`Context <cartoframes.auth.Context>`"""
+        """Dataset :py:class:`Credentials <cartoframes.auth.Credentials>`"""
         return self._strategy.credentials
 
     @credentials.setter
     def credentials(self, credentials):
-        """Set a new :py:class:`Context <cartoframes.auth.Context>` for a Dataset instance."""
+        """Set a new :py:class:`Credentials <cartoframes.auth.Credentials>` for a Dataset instance."""
         self._strategy.credentials = credentials
 
     @property
@@ -129,18 +105,11 @@ class Dataset(object):
         """Dataset query"""
         return self._strategy.query
 
-    def get_query(self):
-        return self._strategy.get_query()
-
     @property
     def dataframe(self):
-        """Dataset DataFrame"""
+        """Dataset dataframe"""
         return self._strategy.dataframe
 
-    def get_geodataframe(self):
-        """Converts DataFrame into GeoDataFrame if possible"""
-        return self._strategy.get_geodataframe()
-
     @property
     def dataset_info(self):
         """:py:class:`DatasetInfo <cartoframes.data.DatasetInfo>` associated with Dataset instance
@@ -172,37 +141,52 @@ class Dataset(object):
 
         return self._strategy.dataset_info
 
-    def update_dataset_info(self, privacy=None, table_name=None):
-        """Update/change Dataset privacy and name
+    def get_query(self):
+        """Get the computed query"""
 
-        Args:
-          privacy (str, optional): One of :py:attr:`DatasetInfo.PRIVATE`,
-            :py:attr:`DatasetInfo.PUBLIC` or :py:attr:`DatasetInfo.LINK`
-          table_name (str, optional): Name of the dataset on CARTO. After updating it,
-            the table_name will be changed too.
+        return self._strategy.get_query()
 
-        Example:
+    def get_geodataframe(self):
+        """Converts DataFrame into GeoDataFrame if possible"""
+        return self._strategy.get_geodataframe()
 
-            .. code::
+    def get_column_names(self, exclude=None):
+        """Get column names from a dataset"""
+        return self._strategy.get_column_names(exclude)
 
-                from cartoframes.data import Dataset, DatasetInfo
-                from cartoframes.auth import set_default_credentials
+    def get_table_names(self):
+        """Get table names used by Dataset instance"""
+        if self.is_local():
+            raise CartoException('Your data is not synchronized with CARTO. If you want to upload it to CARTO, '
+                                 'you should use: `Dataset.upload(table_name="new_table")` '
+                                 'Then, if you want to work with the remote data, use `Dataset("new_table")`')
 
-                set_default_credentials(
-                    base_url='https://your_user_name.carto.com/',
-                    api_key='your api key'
-                )
+        return self._strategy.get_table_names()
 
-                d = Dataset('tablename')
-                d.update_dataset_info(privacy=DatasetInfo.LINK)
+    def get_num_rows(self):
+        """Get the number of rows in the dataset"""
+        return self._strategy.get_num_rows()
 
-        """
-        return self._strategy.update_dataset_info(privacy, table_name)
+    def exists(self):
+        """Checks to see if table exists"""
+        return self._strategy.exists()
+
+    def is_public(self):
+        """Checks to see if table or table used by query has public privacy"""
+        return self._strategy.is_public()
+
+    def is_local(self):
+        """Checks if the Dataset is local (DataFrameDataset)"""
+        return isinstance(self._strategy, DataFrameDataset)
+
+    def is_remote(self):
+        """Checks if the Dataset is local (TableDataset or QueryDataset)"""
+        return not self.is_local()
 
     def download(self, limit=None, decode_geom=False, retry_times=DOWNLOAD_RETRY_TIMES):
         """Download / read a Dataset (table or query) from CARTO account
-        associated with the Dataset's instance of :py:class:`Context
-        <cartoframes.auth.Context>`.
+        associated with the Dataset's instance of :py:class:`Credentials
+        <cartoframes.auth.Credentials>`.
 
         Args:
             limit (int, optional):
@@ -212,7 +196,7 @@ class Dataset(object):
                 Decode Dataset geometries into Shapely geometries from EWKB encoding.
             retry_times (int, optional):
                 Number of time to retry the download in case it fails.
-                Default is Dataset.DOWNLOAD_RETRY_TIMES.
+                Default is 3.
 
         Example:
 
@@ -230,7 +214,64 @@ class Dataset(object):
 
         return self._strategy.download(limit, decode_geom, retry_times)
 
-    def upload(self, with_lnglat=None, if_exists=FAIL, table_name=None, schema=None, credentials=None):
+    IF_EXISTS_FAIL = BaseDataset.IF_EXISTS_FAIL
+    """'fail' option to avoid overwritting a table.
+
+    Example:
+
+        .. code::
+
+            from cartoframes.data import Dataset, DatasetInfo
+            from cartoframes.auth import set_default_credentials
+
+            set_default_credentials(
+                base_url='https://your_user_name.carto.com/',
+                api_key='your api key'
+            )
+
+            d = Dataset('tablename')
+            d.upload(if_exists=Dataset.IF_EXISTS_FAIL, table_name='new_table')
+    """
+
+    IF_EXISTS_REPLACE = BaseDataset.IF_EXISTS_REPLACE
+    """'replace' option to replace the table with the new one.
+
+    Example:
+
+        .. code::
+
+            from cartoframes.data import Dataset, DatasetInfo
+            from cartoframes.auth import set_default_credentials
+
+            set_default_credentials(
+                base_url='https://your_user_name.carto.com/',
+                api_key='your api key'
+            )
+
+            d = Dataset('tablename')
+            d.upload(if_exists=Dataset.IF_EXISTS_FAIL, table_name='new_table')
+    """
+
+    IF_EXISTS_APPEND = BaseDataset.IF_EXISTS_APPEND
+    """'append' option to append the new table in the existing table.
+
+    Example:
+
+        .. code::
+
+            from cartoframes.data import Dataset, DatasetInfo
+            from cartoframes.auth import set_default_credentials
+
+            set_default_credentials(
+                base_url='https://your_user_name.carto.com/',
+                api_key='your api key'
+            )
+
+            d = Dataset('tablename')
+            d.upload(if_exists=Dataset.IF_EXISTS_APPEND, table_name='new_table')
+    """
+
+    def upload(self, with_lnglat=None, if_exists=IF_EXISTS_FAIL, table_name=None, schema=None, credentials=None):
         r"""Upload Dataset to CARTO account associated with `credentials`.
 
         Args:
@@ -239,15 +280,16 @@ class Dataset(object):
               created upon upload to CARTO. Example input: `('long', 'lat')`.
               Defaults to `None`.
             if_exists (str, optional): Behavior for adding data from Dataset.
-              Options are 'fail', 'replace', or 'append'. Defaults to 'fail',
-              which means that the Dataset instance will not overwrite a
-              table of the same name if it exists. If the table does not exist,
-              it will be created.
+              Options are :py:attr:`Dataset.IF_EXISTS_FAIL`,
+              :py:attr:`Dataset.IF_EXISTS_REPLACE`, or :py:attr:`Dataset.IF_EXISTS_APPEND`.
+              Defaults to 'fail', which means that the Dataset instance
+              will not overwrite a table of the same name if it exists.
+              If the table does not exist, it will be created.
             table_name (str): Desired table name for the dataset on CARTO. If
               name does not conform to SQL naming conventions, it will be
               'normalized' (e.g., all lower case, adding `_` in place of spaces
               and other special characters.
-            credentials (:py:class:`Context <cartoframes.auth.Context>`, optional):
+            credentials (:py:class:`Credentials <cartoframes.auth.Credentials>`, optional):
               credentials of user account to send Dataset to. If not provided,
               a default credentials (if set with :py:meth:`set_default_credentials
               <cartoframes.auth.set_default_credentials>`) will attempted to be
@@ -316,39 +358,102 @@ class Dataset(object):
 
         return self._strategy.delete()
 
-    def exists(self):
-        """Checks to see if table exists"""
-        return self._strategy.exists()
+    PRIVACY_PRIVATE = DatasetInfo.PRIVACY_PRIVATE
+    """Dataset privacy for datasets that are private.
 
-    def is_public(self):
-        """Checks to see if table or table used by query has public privacy"""
-        return self._strategy.is_public()
+    Example:
 
-    def is_local(self):
-        """Checks if the Dataset is local (DataFrameDataset)"""
-        return isinstance(self._strategy, DataFrameDataset)
+        .. code::
 
-    def is_remote(self):
-        """Checks if the Dataset is local (TableDataset or QueryDataset)"""
-        return not self.is_local()
+            from cartoframes.data import Dataset, DatasetInfo
+            from cartoframes.auth import set_default_credentials
+
+            set_default_credentials(
+                base_url='https://your_user_name.carto.com/',
+                api_key='your api key'
+            )
+
+            d = Dataset('tablename')
+            d.update_dataset_info(privacy=Dataset.PRIVACY_PRIVATE)
+    """
+
+    PRIVACY_PUBLIC = DatasetInfo.PRIVACY_PUBLIC
+    """Dataset privacy for datasets that are public.
+
+    Example:
+
+        .. code::
+
+            from cartoframes.data import Dataset, DatasetInfo
+            from cartoframes.auth import set_default_credentials
+
+            set_default_credentials(
+                base_url='https://your_user_name.carto.com/',
+                api_key='your api key'
+            )
+
+            d = Dataset('tablename')
+            d.update_dataset_info(privacy=Dataset.PRIVACY_PUBLIC)
+    """
+
+    PRIVACY_LINK = DatasetInfo.PRIVACY_LINK
+    """Dataset privacy for datasets that are accessible by link.
+
+    Example:
+
+    .. code::
+
+        from cartoframes.data import Dataset, DatasetInfo
+        from cartoframes.auth import set_default_credentials
+
+        set_default_credentials(
+            base_url='https://your_user_name.carto.com/',
+            api_key='your api key'
+        )
+
+        d = Dataset('tablename')
+        d.update_dataset_info(privacy=Dataset.PRIVACY_LINK)
+    """
+
+    def update_dataset_info(self, privacy=None, table_name=None):
+        """Update/change Dataset privacy and name
+
+        Args:
+          privacy (str, optional): One of :py:attr:`Dataset.PRIVACY_PRIVATE`,
+            :py:attr:`Dataset.PRIVACY_PUBLIC` or :py:attr:`Dataset.PRIVACY_LINK`
+          table_name (str, optional): Name of the dataset on CARTO. After updating it,
+            the table_name will be changed too.
+
+        Example:
+
+            .. code::
+
+                from cartoframes.data import Dataset, DatasetInfo
+                from cartoframes.auth import set_default_credentials
+
+                set_default_credentials(
+                    base_url='https://your_user_name.carto.com/',
+                    api_key='your api key'
+                )
+
+                d = Dataset('tablename')
+                d.update_dataset_info(privacy=Dataset.PRIVACY_LINK)
+
+        """
+
+        return self._strategy.update_dataset_info(privacy, table_name)
 
     def compute_geom_type(self):
         """Compute the geometry type from the data"""
         return self._strategy.compute_geom_type()
 
-    def get_column_names(self, exclude=None):
-        """Get column names from a dataset"""
-        return self._strategy.get_column_names(exclude)
-
-    def get_table_names(self):
-        """Get table names used by Dataset instance"""
-        if self.is_local():
-            raise CartoException('Your data is not synchronized with CARTO. If you want to upload it to CARTO, '
-                                 'you should use: `Dataset.upload(table_name="new_table")` '
-                                 'Then, if you want to work with the remote data, use `Dataset("new_table")`')
+    def _init_strategy(self, data, credentials=None, schema=None):
+        credentials = credentials or get_default_credentials()
+        for strategy in self._registry.get_strategies():
+            if strategy.can_work_with(data):
+                return strategy.create(data, credentials, schema)
 
-        return self._strategy.get_table_names()
+        raise ValueError('We can not detect the Dataset type')
 
-    def get_num_rows(self):
-        """Get the number of rows in the dataset"""
-        return self._strategy.get_num_rows()
+    def _get_strategies_registry(self):
+        return StrategiesRegistry()
diff --git a/cartoframes/data/dataset/dataset_info.py b/cartoframes/data/dataset/dataset_info.py
index 1e6fa6a6..616f57bb 100644
--- a/cartoframes/data/dataset/dataset_info.py
+++ b/cartoframes/data/dataset/dataset_info.py
@@ -11,9 +11,14 @@ from ...utils.columns import normalize_name
 
 
 class DatasetInfo(object):
-    PRIVATE = 'PRIVATE'
-    PUBLIC = 'PUBLIC'
-    LINK = 'LINK'
+    PRIVACY_PRIVATE = 'PRIVATE'
+    """Dataset privacy for datasets that are private"""
+
+    PRIVACY_PUBLIC = 'PUBLIC'
+    """Dataset privacy for datasets that are public"""
+
+    PRIVACY_LINK = 'LINK'
+    """Dataset privacy for datasets that are accessible by link"""
 
     def __init__(self, context, table_name):
         self._metadata = self._get_metadata(context, table_name)
@@ -77,9 +82,9 @@ class DatasetInfo(object):
 
     def _validate_privacy(self, privacy):
         privacy = privacy.upper()
-        if privacy not in [self.PRIVATE, self.PUBLIC, self.LINK]:
+        if privacy not in [self.PRIVACY_PRIVATE, self.PRIVACY_PUBLIC, self.PRIVACY_LINK]:
             raise ValueError('Wrong privacy. The privacy: {p} is not valid. You can use: {o1}, {o2}, {o3}'.format(
-                p=privacy, o1=self.PRIVATE, o2=self.PUBLIC, o3=self.LINK))
+                p=privacy, o1=self.PRIVACY_PRIVATE, o2=self.PRIVACY_PUBLIC, o3=self.PRIVACY_LINK))
 
         if privacy != self._privacy:
             return True
diff --git a/cartoframes/data/dataset/registry/base_dataset.py b/cartoframes/data/dataset/registry/base_dataset.py
index 146bee14..f9efe4a1 100644
--- a/cartoframes/data/dataset/registry/base_dataset.py
+++ b/cartoframes/data/dataset/registry/base_dataset.py
@@ -16,9 +16,13 @@ from ....utils.columns import Column, normalize_name, dtypes, date_columns_names
 class BaseDataset():
     __metaclass__ = ABCMeta
 
-    FAIL = 'fail'
-    REPLACE = 'replace'
-    APPEND = 'append'
+    GEOM_TYPE_POINT = 'point'
+    GEOM_TYPE_LINE = 'line'
+    GEOM_TYPE_POLYGON = 'polygon'
+
+    IF_EXISTS_FAIL = 'fail'
+    IF_EXISTS_REPLACE = 'replace'
+    IF_EXISTS_APPEND = 'append'
 
     def __init__(self, credentials=None):
         self._verbose = 0
diff --git a/cartoframes/data/dataset/registry/dataframe_dataset.py b/cartoframes/data/dataset/registry/dataframe_dataset.py
index 5ed6dd3f..99b2b747 100644
--- a/cartoframes/data/dataset/registry/dataframe_dataset.py
+++ b/cartoframes/data/dataset/registry/dataframe_dataset.py
@@ -55,9 +55,9 @@ class DataFrameDataset(BaseDataset):
 
         dataframe_columns_info = DataframeColumnsInfo(self._df, with_lnglat)
 
-        if if_exists == BaseDataset.REPLACE or not self.exists():
+        if if_exists == BaseDataset.IF_EXISTS_REPLACE or not self.exists():
             self._create_table(dataframe_columns_info.columns)
-        elif if_exists == BaseDataset.FAIL:
+        elif if_exists == BaseDataset.IF_EXISTS_FAIL:
             raise self._already_exists_error()
 
         self._copyfrom(dataframe_columns_info, with_lnglat)
diff --git a/cartoframes/data/dataset/registry/query_dataset.py b/cartoframes/data/dataset/registry/query_dataset.py
index 1a05d524..d997a3ca 100644
--- a/cartoframes/data/dataset/registry/query_dataset.py
+++ b/cartoframes/data/dataset/registry/query_dataset.py
@@ -43,12 +43,12 @@ class QueryDataset(BaseDataset):
     def upload(self, if_exists, with_lnglat):
         self._is_ready_for_upload_validation()
 
-        if if_exists == BaseDataset.APPEND:
+        if if_exists == BaseDataset.IF_EXISTS_APPEND:
             raise CartoException('Error using append with a QueryDataset.'
                                  'It is not possible to append data to a query')
-        elif if_exists == BaseDataset.REPLACE or not self.exists():
+        elif if_exists == BaseDataset.IF_EXISTS_REPLACE or not self.exists():
             self._create_table_from_query()
-        elif if_exists == BaseDataset.FAIL:
+        elif if_exists == BaseDataset.IF_EXISTS_FAIL:
             raise self._already_exists_error()
 
     def delete(self):
diff --git a/cartoframes/data/observatory/dataset.py b/cartoframes/data/observatory/dataset.py
index 101a2564..8a2bc27e 100644
--- a/cartoframes/data/observatory/dataset.py
+++ b/cartoframes/data/observatory/dataset.py
@@ -7,7 +7,6 @@ from .repository.variable_group_repo import get_variable_group_repo
 
 
 class Dataset(CatalogEntity):
-
     entity_repo = get_dataset_repo()
 
     @property
diff --git a/cartoframes/data/services/geocoding.py b/cartoframes/data/services/geocoding.py
index 9e4bf977..5a8dd69b 100644
--- a/cartoframes/data/services/geocoding.py
+++ b/cartoframes/data/services/geocoding.py
@@ -378,7 +378,7 @@ class Geocoding(Service):
     def geocode(self, dataset, street,
                 city=None, state=None, country=None,
                 status=DEFAULT_STATUS,
-                table_name=None, if_exists=Dataset.FAIL,
+                table_name=None, if_exists=Dataset.IF_EXISTS_FAIL,
                 dry_run=False):
         """Geocode a dataset
 
diff --git a/cartoframes/viz/source.py b/cartoframes/viz/source.py
index e780dd02..3ee51a6f 100644
--- a/cartoframes/viz/source.py
+++ b/cartoframes/viz/source.py
@@ -2,6 +2,7 @@ from __future__ import absolute_import
 
 from . import defaults
 from ..data import Dataset
+from ..data.dataset.registry.base_dataset import BaseDataset
 from ..utils.utils import get_query_bounds, get_geodataframe_bounds, encode_geodataframe
 
 
@@ -109,7 +110,7 @@ class Source(object):
         self._init_source_dataset(bounds)
 
     def get_geom_type(self):
-        return self.dataset.compute_geom_type() or Dataset.GEOM_TYPE_POINT
+        return self.dataset.compute_geom_type() or BaseDataset.GEOM_TYPE_POINT
 
     def get_credentials(self):
         credentials = self.dataset.credentials
diff --git a/docs/cartoframes.rst b/docs/cartoframes.rst
index b7dbca68..07df879e 100644
--- a/docs/cartoframes.rst
+++ b/docs/cartoframes.rst
@@ -1,5 +1,6 @@
 .. include:: includes/introduction.rst
 .. include:: includes/auth.rst
+.. include:: includes/data_management.rst
 .. include:: includes/data_observatory.rst
 .. include:: includes/data_enrichment.rst
 .. include:: includes/data_services.rst
diff --git a/docs/includes/data_management.rst b/docs/includes/data_management.rst
new file mode 100644
index 00000000..4367a83b
--- /dev/null
+++ b/docs/includes/data_management.rst
@@ -0,0 +1,7 @@
+Data Management
+---------------
+
+.. automodule:: cartoframes.data
+    :members:
+    :member-order: bysource
+    :no-undoc-members:
\ No newline at end of file


Test patch:
diff --git a/test/data/dataset/test_dataset.py b/test/data/dataset/test_dataset.py
index 2c4ca842..9d87192e 100644
--- a/test/data/dataset/test_dataset.py
+++ b/test/data/dataset/test_dataset.py
@@ -151,14 +151,14 @@ class TestDataset(unittest.TestCase, _UserUrlLoader):
                    'or use if_exists="replace" to overwrite it').format(t=self.test_write_table, s='public')
         with self.assertRaises(CartoException, msg=err_msg):
             dataset.upload(table_name=self.test_write_table)
-        dataset.upload(table_name=self.test_write_table, if_exists=Dataset.REPLACE)
+        dataset.upload(table_name=self.test_write_table, if_exists=Dataset.IF_EXISTS_REPLACE)
 
     def test_dataset_upload_validation_fails_with_query_and_append(self):
         query = 'SELECT 1'
         dataset = Dataset(query, credentials=self.credentials)
         err_msg = 'Error using append with a query Dataset. It is not possible to append data to a query'
         with self.assertRaises(CartoException, msg=err_msg):
-            dataset.upload(table_name=self.test_write_table, if_exists=Dataset.APPEND)
+            dataset.upload(table_name=self.test_write_table, if_exists=Dataset.IF_EXISTS_APPEND)
 
     @unittest.skipIf(WILL_SKIP, 'no carto credentials, skipping this test')
     def test_dataset_download_validations(self):
@@ -193,7 +193,9 @@ class TestDataset(unittest.TestCase, _UserUrlLoader):
         df = dataset.download()
 
         dataset = Dataset(df)
-        dataset.upload(table_name=self.test_write_table, credentials=self.credentials, if_exists=Dataset.REPLACE)
+        dataset.upload(table_name=self.test_write_table,
+                       credentials=self.credentials,
+                       if_exists=Dataset.IF_EXISTS_REPLACE)
 
     def test_dataset_download_bool_null(self):
         self.assertNotExistsTable(self.test_write_table)
@@ -381,7 +383,9 @@ class TestDataset(unittest.TestCase, _UserUrlLoader):
         # avoid uploading the same cartodb_id
         df['cartodb_id'] += df['cartodb_id'].max() + 1
 
-        Dataset(df).upload(if_exists=Dataset.APPEND, table_name=self.test_write_table, credentials=self.credentials)
+        Dataset(df).upload(if_exists=Dataset.IF_EXISTS_APPEND,
+                           table_name=self.test_write_table,
+                           credentials=self.credentials)
 
         self.assertExistsTable(self.test_write_table)
 
@@ -397,7 +401,7 @@ class TestDataset(unittest.TestCase, _UserUrlLoader):
         self.test_write_table = dataset.table_name
 
         dataset = Dataset(df).upload(
-            if_exists=Dataset.REPLACE, table_name=self.test_write_table, credentials=self.credentials)
+            if_exists=Dataset.IF_EXISTS_REPLACE, table_name=self.test_write_table, credentials=self.credentials)
 
         self.assertExistsTable(self.test_write_table)
 
@@ -465,7 +469,7 @@ class TestDatasetInfo(unittest.TestCase):
     def test_dataset_info_should_work_from_table(self):
         table_name = 'fake_table'
         dataset = DatasetMock(table_name, credentials=self.credentials)
-        self.assertEqual(dataset.dataset_info.privacy, Dataset.PRIVATE)
+        self.assertEqual(dataset.dataset_info.privacy, Dataset.PRIVACY_PRIVATE)
 
     def test_dataset_get_privacy_from_new_table(self):
         query = 'SELECT 1'
@@ -473,7 +477,7 @@ class TestDatasetInfo(unittest.TestCase):
         dataset.upload(table_name='fake_table')
 
         dataset = DatasetMock('fake_table', credentials=self.credentials)
-        self.assertEqual(dataset.dataset_info.privacy, Dataset.PRIVATE)
+        self.assertEqual(dataset.dataset_info.privacy, Dataset.PRIVACY_PRIVATE)
 
     def test_dataset_set_privacy_to_new_table(self):
         query = 'SELECT 1'
@@ -481,8 +485,8 @@ class TestDatasetInfo(unittest.TestCase):
         dataset.upload(table_name='fake_table')
 
         dataset = DatasetMock('fake_table', credentials=self.credentials)
-        dataset.update_dataset_info(privacy=Dataset.PUBLIC)
-        self.assertEqual(dataset.dataset_info.privacy, Dataset.PUBLIC)
+        dataset.update_dataset_info(privacy=Dataset.PRIVACY_PUBLIC)
+        self.assertEqual(dataset.dataset_info.privacy, Dataset.PRIVACY_PUBLIC)
 
     def test_dataset_set_privacy_with_wrong_parameter(self):
         query = 'SELECT 1'
@@ -490,7 +494,7 @@ class TestDatasetInfo(unittest.TestCase):
         dataset.upload(table_name='fake_table')
         wrong_privacy = 'wrong_privacy'
         error_msg = 'Wrong privacy. The privacy: {p} is not valid. You can use: {o1}, {o2}, {o3}'.format(
-            p=wrong_privacy, o1=Dataset.PRIVATE, o2=Dataset.PUBLIC, o3=Dataset.LINK)
+            p=wrong_privacy, o1=Dataset.PRIVACY_PRIVATE, o2=Dataset.PRIVACY_PUBLIC, o3=Dataset.PRIVACY_LINK)
         with self.assertRaises(ValueError, msg=error_msg):
             dataset.update_dataset_info(privacy=wrong_privacy)
 
@@ -498,12 +502,12 @@ class TestDatasetInfo(unittest.TestCase):
         table_name = 'fake_table'
         dataset = DatasetMock(table_name, credentials=self.credentials)
         dataset_info = dataset.dataset_info
-        self.assertEqual(dataset_info.privacy, Dataset.PRIVATE)
-        privacy = Dataset.PUBLIC
+        self.assertEqual(dataset_info.privacy, Dataset.PRIVACY_PRIVATE)
+        privacy = Dataset.PRIVACY_PUBLIC
         error_msg = str(setting_value_exception('privacy', privacy))
         with self.assertRaises(CartoException, msg=error_msg):
             dataset_info.privacy = privacy
-        self.assertEqual(dataset_info.privacy, Dataset.PRIVATE)
+        self.assertEqual(dataset_info.privacy, Dataset.PRIVACY_PRIVATE)
 
     def test_dataset_info_from_dataframe(self):
         df = pd.DataFrame.from_dict({'test': [True, [1, 2]]})
@@ -520,7 +524,7 @@ class TestDatasetInfo(unittest.TestCase):
         dataset.upload(table_name='fake_table', credentials=self.credentials)
 
         dataset = DatasetMock('fake_table', credentials=self.credentials)
-        self.assertEqual(dataset.dataset_info.privacy, Dataset.PRIVATE)
+        self.assertEqual(dataset.dataset_info.privacy, Dataset.PRIVACY_PRIVATE)
 
     def test_dataset_info_from_query(self):
         query = 'SELECT 1'
diff --git a/test/mocks/dataset_mock.py b/test/mocks/dataset_mock.py
index 02a89b06..eb4242ff 100644
--- a/test/mocks/dataset_mock.py
+++ b/test/mocks/dataset_mock.py
@@ -6,13 +6,14 @@ from cartoframes.data import StrategiesRegistry
 from cartoframes.data.dataset.registry.dataframe_dataset import DataFrameDataset
 from cartoframes.data.dataset.registry.query_dataset import QueryDataset
 from cartoframes.data.dataset.registry.table_dataset import TableDataset
-from cartoframes.data import Dataset
+from cartoframes.data.dataset.registry.base_dataset import BaseDataset
 from cartoframes.data.dataset.dataset_info import DatasetInfo
+from cartoframes.data import Dataset
 
 
 class MetadataMock():
     def __init__(self):
-        self.privacy = DatasetInfo.PRIVATE
+        self.privacy = Dataset.PRIVACY_PRIVATE
         self.name = None
 
 
@@ -41,7 +42,7 @@ class DataFrameDatasetMock(DataFrameDataset):
         return True
 
     def compute_geom_type(self):
-        return Dataset.GEOM_TYPE_POINT
+        return BaseDataset.GEOM_TYPE_POINT
 
 
 class QueryDatasetMock(QueryDataset):
@@ -62,7 +63,7 @@ class QueryDatasetMock(QueryDataset):
         return True
 
     def compute_geom_type(self):
-        return Dataset.GEOM_TYPE_POINT
+        return BaseDataset.GEOM_TYPE_POINT
 
     def _get_read_query(self, table_columns, limit=None):
         return self._query
@@ -89,7 +90,7 @@ class TableDatasetMock(TableDataset):
         return True
 
     def compute_geom_type(self):
-        return Dataset.GEOM_TYPE_POINT
+        return BaseDataset.GEOM_TYPE_POINT
 
 
 class StrategiesRegistryMock(StrategiesRegistry):
@@ -102,4 +103,4 @@ class DatasetMock(Dataset):
         return StrategiesRegistryMock()
 
     def compute_geom_type(self):
-        return Dataset.GEOM_TYPE_POINT
+        return BaseDataset.GEOM_TYPE_POINT