From f5ff53f31a2a248a017161981f94089c08f2b654 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Wed, 23 Oct 2019 17:49:52 +0200 Subject: [PATCH 1/3] Refactor DO namespaces --- cartoframes/data/__init__.py | 4 +--- cartoframes/data/dataset/__init__.py | 1 - cartoframes/data/dataset/registry/__init__.py | 1 - cartoframes/data/enrichment/__init__.py | 6 ------ cartoframes/data/observatory/__init__.py | 6 +++++- cartoframes/data/observatory/catalog/__init__.py | 0 cartoframes/data/observatory/{ => catalog}/catalog.py | 0 cartoframes/data/observatory/{ => catalog}/category.py | 0 cartoframes/data/observatory/{ => catalog}/country.py | 0 cartoframes/data/observatory/{ => catalog}/dataset.py | 0 cartoframes/data/observatory/{ => catalog}/entity.py | 0 cartoframes/data/observatory/{ => catalog}/geography.py | 0 cartoframes/data/observatory/{ => catalog}/provider.py | 0 cartoframes/data/observatory/catalog/repository/__init__.py | 0 .../observatory/{ => catalog}/repository/category_repo.py | 0 .../data/observatory/{ => catalog}/repository/constants.py | 0 .../observatory/{ => catalog}/repository/country_repo.py | 0 .../observatory/{ => catalog}/repository/dataset_repo.py | 0 .../observatory/{ => catalog}/repository/entity_repo.py | 0 .../observatory/{ => catalog}/repository/geography_repo.py | 0 .../observatory/{ => catalog}/repository/provider_repo.py | 0 .../observatory/{ => catalog}/repository/repo_client.py | 0 .../{ => catalog}/repository/variable_group_repo.py | 0 .../observatory/{ => catalog}/repository/variable_repo.py | 0 .../data/observatory/{ => catalog}/subscription_info.py | 0 cartoframes/data/observatory/{ => catalog}/subscriptions.py | 0 cartoframes/data/observatory/{ => catalog}/summary.py | 0 cartoframes/data/observatory/{ => catalog}/utils.py | 0 cartoframes/data/observatory/{ => catalog}/variable.py | 0 .../data/observatory/{ => catalog}/variable_group.py | 0 cartoframes/data/observatory/enrichment/__init__.py | 0 .../data/{ => observatory}/enrichment/enrichment_service.py | 0 .../data/{ => observatory}/enrichment/points_enrichment.py | 0 .../{ => observatory}/enrichment/polygons_enrichment.py | 0 cartoframes/data/observatory/repository/__init__.py | 1 - 35 files changed, 6 insertions(+), 13 deletions(-) delete mode 100644 cartoframes/data/enrichment/__init__.py create mode 100644 cartoframes/data/observatory/catalog/__init__.py rename cartoframes/data/observatory/{ => catalog}/catalog.py (100%) rename cartoframes/data/observatory/{ => catalog}/category.py (100%) rename cartoframes/data/observatory/{ => catalog}/country.py (100%) rename cartoframes/data/observatory/{ => catalog}/dataset.py (100%) rename cartoframes/data/observatory/{ => catalog}/entity.py (100%) rename cartoframes/data/observatory/{ => catalog}/geography.py (100%) rename cartoframes/data/observatory/{ => catalog}/provider.py (100%) create mode 100644 cartoframes/data/observatory/catalog/repository/__init__.py rename cartoframes/data/observatory/{ => catalog}/repository/category_repo.py (100%) rename cartoframes/data/observatory/{ => catalog}/repository/constants.py (100%) rename cartoframes/data/observatory/{ => catalog}/repository/country_repo.py (100%) rename cartoframes/data/observatory/{ => catalog}/repository/dataset_repo.py (100%) rename cartoframes/data/observatory/{ => catalog}/repository/entity_repo.py (100%) rename cartoframes/data/observatory/{ => catalog}/repository/geography_repo.py (100%) rename cartoframes/data/observatory/{ => catalog}/repository/provider_repo.py (100%) rename cartoframes/data/observatory/{ => catalog}/repository/repo_client.py (100%) rename cartoframes/data/observatory/{ => catalog}/repository/variable_group_repo.py (100%) rename cartoframes/data/observatory/{ => catalog}/repository/variable_repo.py (100%) rename cartoframes/data/observatory/{ => catalog}/subscription_info.py (100%) rename cartoframes/data/observatory/{ => catalog}/subscriptions.py (100%) rename cartoframes/data/observatory/{ => catalog}/summary.py (100%) rename cartoframes/data/observatory/{ => catalog}/utils.py (100%) rename cartoframes/data/observatory/{ => catalog}/variable.py (100%) rename cartoframes/data/observatory/{ => catalog}/variable_group.py (100%) create mode 100644 cartoframes/data/observatory/enrichment/__init__.py rename cartoframes/data/{ => observatory}/enrichment/enrichment_service.py (100%) rename cartoframes/data/{ => observatory}/enrichment/points_enrichment.py (100%) rename cartoframes/data/{ => observatory}/enrichment/polygons_enrichment.py (100%) delete mode 100644 cartoframes/data/observatory/repository/__init__.py diff --git a/cartoframes/data/__init__.py b/cartoframes/data/__init__.py index edb1d5984..925b55dec 100644 --- a/cartoframes/data/__init__.py +++ b/cartoframes/data/__init__.py @@ -2,10 +2,8 @@ from .dataset.dataset import Dataset from .dataset.registry.strategies_registry import StrategiesRegistry -from .observatory.catalog import Catalog __all__ = [ 'Dataset', - 'StrategiesRegistry', - 'Catalog' + 'StrategiesRegistry' ] diff --git a/cartoframes/data/dataset/__init__.py b/cartoframes/data/dataset/__init__.py index c3961685a..e69de29bb 100644 --- a/cartoframes/data/dataset/__init__.py +++ b/cartoframes/data/dataset/__init__.py @@ -1 +0,0 @@ -from __future__ import absolute_import diff --git a/cartoframes/data/dataset/registry/__init__.py b/cartoframes/data/dataset/registry/__init__.py index c3961685a..e69de29bb 100644 --- a/cartoframes/data/dataset/registry/__init__.py +++ b/cartoframes/data/dataset/registry/__init__.py @@ -1 +0,0 @@ -from __future__ import absolute_import diff --git a/cartoframes/data/enrichment/__init__.py b/cartoframes/data/enrichment/__init__.py deleted file mode 100644 index 5eeee83e2..000000000 --- a/cartoframes/data/enrichment/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -from __future__ import absolute_import - -from .points_enrichment import enrich_points -from .polygons_enrichment import enrich_polygons - -__all__ = ['enrich_points', 'enrich_polygons'] diff --git a/cartoframes/data/observatory/__init__.py b/cartoframes/data/observatory/__init__.py index 0b7e1adbf..3ea96c6e4 100644 --- a/cartoframes/data/observatory/__init__.py +++ b/cartoframes/data/observatory/__init__.py @@ -7,6 +7,8 @@ from .geography import Geography from .provider import Provider from .variable import Variable +from .points_enrichment import enrich_points +from .polygons_enrichment import enrich_polygons __all__ = [ 'Catalog', @@ -15,5 +17,7 @@ 'CatalogDataset', 'Geography', 'Provider', - 'Variable' + 'Variable', + 'enrich_points', + 'enrich_polygons' ] diff --git a/cartoframes/data/observatory/catalog/__init__.py b/cartoframes/data/observatory/catalog/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/cartoframes/data/observatory/catalog.py b/cartoframes/data/observatory/catalog/catalog.py similarity index 100% rename from cartoframes/data/observatory/catalog.py rename to cartoframes/data/observatory/catalog/catalog.py diff --git a/cartoframes/data/observatory/category.py b/cartoframes/data/observatory/catalog/category.py similarity index 100% rename from cartoframes/data/observatory/category.py rename to cartoframes/data/observatory/catalog/category.py diff --git a/cartoframes/data/observatory/country.py b/cartoframes/data/observatory/catalog/country.py similarity index 100% rename from cartoframes/data/observatory/country.py rename to cartoframes/data/observatory/catalog/country.py diff --git a/cartoframes/data/observatory/dataset.py b/cartoframes/data/observatory/catalog/dataset.py similarity index 100% rename from cartoframes/data/observatory/dataset.py rename to cartoframes/data/observatory/catalog/dataset.py diff --git a/cartoframes/data/observatory/entity.py b/cartoframes/data/observatory/catalog/entity.py similarity index 100% rename from cartoframes/data/observatory/entity.py rename to cartoframes/data/observatory/catalog/entity.py diff --git a/cartoframes/data/observatory/geography.py b/cartoframes/data/observatory/catalog/geography.py similarity index 100% rename from cartoframes/data/observatory/geography.py rename to cartoframes/data/observatory/catalog/geography.py diff --git a/cartoframes/data/observatory/provider.py b/cartoframes/data/observatory/catalog/provider.py similarity index 100% rename from cartoframes/data/observatory/provider.py rename to cartoframes/data/observatory/catalog/provider.py diff --git a/cartoframes/data/observatory/catalog/repository/__init__.py b/cartoframes/data/observatory/catalog/repository/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/cartoframes/data/observatory/repository/category_repo.py b/cartoframes/data/observatory/catalog/repository/category_repo.py similarity index 100% rename from cartoframes/data/observatory/repository/category_repo.py rename to cartoframes/data/observatory/catalog/repository/category_repo.py diff --git a/cartoframes/data/observatory/repository/constants.py b/cartoframes/data/observatory/catalog/repository/constants.py similarity index 100% rename from cartoframes/data/observatory/repository/constants.py rename to cartoframes/data/observatory/catalog/repository/constants.py diff --git a/cartoframes/data/observatory/repository/country_repo.py b/cartoframes/data/observatory/catalog/repository/country_repo.py similarity index 100% rename from cartoframes/data/observatory/repository/country_repo.py rename to cartoframes/data/observatory/catalog/repository/country_repo.py diff --git a/cartoframes/data/observatory/repository/dataset_repo.py b/cartoframes/data/observatory/catalog/repository/dataset_repo.py similarity index 100% rename from cartoframes/data/observatory/repository/dataset_repo.py rename to cartoframes/data/observatory/catalog/repository/dataset_repo.py diff --git a/cartoframes/data/observatory/repository/entity_repo.py b/cartoframes/data/observatory/catalog/repository/entity_repo.py similarity index 100% rename from cartoframes/data/observatory/repository/entity_repo.py rename to cartoframes/data/observatory/catalog/repository/entity_repo.py diff --git a/cartoframes/data/observatory/repository/geography_repo.py b/cartoframes/data/observatory/catalog/repository/geography_repo.py similarity index 100% rename from cartoframes/data/observatory/repository/geography_repo.py rename to cartoframes/data/observatory/catalog/repository/geography_repo.py diff --git a/cartoframes/data/observatory/repository/provider_repo.py b/cartoframes/data/observatory/catalog/repository/provider_repo.py similarity index 100% rename from cartoframes/data/observatory/repository/provider_repo.py rename to cartoframes/data/observatory/catalog/repository/provider_repo.py diff --git a/cartoframes/data/observatory/repository/repo_client.py b/cartoframes/data/observatory/catalog/repository/repo_client.py similarity index 100% rename from cartoframes/data/observatory/repository/repo_client.py rename to cartoframes/data/observatory/catalog/repository/repo_client.py diff --git a/cartoframes/data/observatory/repository/variable_group_repo.py b/cartoframes/data/observatory/catalog/repository/variable_group_repo.py similarity index 100% rename from cartoframes/data/observatory/repository/variable_group_repo.py rename to cartoframes/data/observatory/catalog/repository/variable_group_repo.py diff --git a/cartoframes/data/observatory/repository/variable_repo.py b/cartoframes/data/observatory/catalog/repository/variable_repo.py similarity index 100% rename from cartoframes/data/observatory/repository/variable_repo.py rename to cartoframes/data/observatory/catalog/repository/variable_repo.py diff --git a/cartoframes/data/observatory/subscription_info.py b/cartoframes/data/observatory/catalog/subscription_info.py similarity index 100% rename from cartoframes/data/observatory/subscription_info.py rename to cartoframes/data/observatory/catalog/subscription_info.py diff --git a/cartoframes/data/observatory/subscriptions.py b/cartoframes/data/observatory/catalog/subscriptions.py similarity index 100% rename from cartoframes/data/observatory/subscriptions.py rename to cartoframes/data/observatory/catalog/subscriptions.py diff --git a/cartoframes/data/observatory/summary.py b/cartoframes/data/observatory/catalog/summary.py similarity index 100% rename from cartoframes/data/observatory/summary.py rename to cartoframes/data/observatory/catalog/summary.py diff --git a/cartoframes/data/observatory/utils.py b/cartoframes/data/observatory/catalog/utils.py similarity index 100% rename from cartoframes/data/observatory/utils.py rename to cartoframes/data/observatory/catalog/utils.py diff --git a/cartoframes/data/observatory/variable.py b/cartoframes/data/observatory/catalog/variable.py similarity index 100% rename from cartoframes/data/observatory/variable.py rename to cartoframes/data/observatory/catalog/variable.py diff --git a/cartoframes/data/observatory/variable_group.py b/cartoframes/data/observatory/catalog/variable_group.py similarity index 100% rename from cartoframes/data/observatory/variable_group.py rename to cartoframes/data/observatory/catalog/variable_group.py diff --git a/cartoframes/data/observatory/enrichment/__init__.py b/cartoframes/data/observatory/enrichment/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/cartoframes/data/enrichment/enrichment_service.py b/cartoframes/data/observatory/enrichment/enrichment_service.py similarity index 100% rename from cartoframes/data/enrichment/enrichment_service.py rename to cartoframes/data/observatory/enrichment/enrichment_service.py diff --git a/cartoframes/data/enrichment/points_enrichment.py b/cartoframes/data/observatory/enrichment/points_enrichment.py similarity index 100% rename from cartoframes/data/enrichment/points_enrichment.py rename to cartoframes/data/observatory/enrichment/points_enrichment.py diff --git a/cartoframes/data/enrichment/polygons_enrichment.py b/cartoframes/data/observatory/enrichment/polygons_enrichment.py similarity index 100% rename from cartoframes/data/enrichment/polygons_enrichment.py rename to cartoframes/data/observatory/enrichment/polygons_enrichment.py diff --git a/cartoframes/data/observatory/repository/__init__.py b/cartoframes/data/observatory/repository/__init__.py deleted file mode 100644 index c3961685a..000000000 --- a/cartoframes/data/observatory/repository/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from __future__ import absolute_import From 453e43bf5588afdb22a20c09aaf22bbe54e272cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Wed, 23 Oct 2019 18:16:13 +0200 Subject: [PATCH 2/3] Update relative paths --- cartoframes/data/observatory/__init__.py | 18 +++++++++--------- .../data/observatory/catalog/catalog.py | 2 +- .../data/observatory/catalog/category.py | 6 ++---- .../data/observatory/catalog/country.py | 1 - cartoframes/data/observatory/catalog/entity.py | 4 ++-- .../data/observatory/catalog/geography.py | 1 - .../catalog/repository/entity_repo.py | 2 +- .../catalog/repository/geography_repo.py | 3 ++- .../catalog/repository/repo_client.py | 4 ++-- .../enrichment/enrichment_service.py | 15 +++++++-------- 10 files changed, 26 insertions(+), 30 deletions(-) diff --git a/cartoframes/data/observatory/__init__.py b/cartoframes/data/observatory/__init__.py index 3ea96c6e4..efe2a3027 100644 --- a/cartoframes/data/observatory/__init__.py +++ b/cartoframes/data/observatory/__init__.py @@ -1,14 +1,14 @@ from __future__ import absolute_import -from .catalog import Catalog -from .category import Category -from .country import Country -from .dataset import CatalogDataset -from .geography import Geography -from .provider import Provider -from .variable import Variable -from .points_enrichment import enrich_points -from .polygons_enrichment import enrich_polygons +from .catalog.catalog import Catalog +from .catalog.category import Category +from .catalog.country import Country +from .catalog.dataset import CatalogDataset +from .catalog.geography import Geography +from .catalog.provider import Provider +from .catalog.variable import Variable +from .enrichment.points_enrichment import enrich_points +from .enrichment.polygons_enrichment import enrich_polygons __all__ = [ 'Catalog', diff --git a/cartoframes/data/observatory/catalog/catalog.py b/cartoframes/data/observatory/catalog/catalog.py index 3a715b224..fcdcedc50 100644 --- a/cartoframes/data/observatory/catalog/catalog.py +++ b/cartoframes/data/observatory/catalog/catalog.py @@ -8,7 +8,7 @@ from .subscriptions import Subscriptions from .repository.constants import COUNTRY_FILTER, CATEGORY_FILTER, GEOGRAPHY_FILTER -from ...auth import Credentials, defaults +from ....auth import Credentials, defaults class Catalog(object): diff --git a/cartoframes/data/observatory/catalog/category.py b/cartoframes/data/observatory/catalog/category.py index 20b62dc88..7e8c3dd6a 100644 --- a/cartoframes/data/observatory/catalog/category.py +++ b/cartoframes/data/observatory/catalog/category.py @@ -1,12 +1,10 @@ from __future__ import absolute_import -from cartoframes.data.observatory.repository.constants import CATEGORY_FILTER - -from cartoframes.data.observatory.repository.geography_repo import get_geography_repo - from .entity import CatalogEntity +from .repository.constants import CATEGORY_FILTER from .repository.category_repo import get_category_repo from .repository.dataset_repo import get_dataset_repo +from .repository.geography_repo import get_geography_repo class Category(CatalogEntity): diff --git a/cartoframes/data/observatory/catalog/country.py b/cartoframes/data/observatory/catalog/country.py index 53b87b5b8..9c701bea3 100644 --- a/cartoframes/data/observatory/catalog/country.py +++ b/cartoframes/data/observatory/catalog/country.py @@ -1,6 +1,5 @@ from __future__ import absolute_import - from .entity import CatalogEntity from .repository.geography_repo import get_geography_repo from .repository.country_repo import get_country_repo diff --git a/cartoframes/data/observatory/catalog/entity.py b/cartoframes/data/observatory/catalog/entity.py index 43c6736b7..75db6cbcb 100644 --- a/cartoframes/data/observatory/catalog/entity.py +++ b/cartoframes/data/observatory/catalog/entity.py @@ -5,8 +5,8 @@ from carto.exceptions import CartoException -from ..clients.bigquery_client import BigQueryClient -from ...auth import Credentials, defaults +from ...clients.bigquery_client import BigQueryClient +from ....auth import Credentials, defaults try: from abc import ABC diff --git a/cartoframes/data/observatory/catalog/geography.py b/cartoframes/data/observatory/catalog/geography.py index 038433234..1a11ce913 100644 --- a/cartoframes/data/observatory/catalog/geography.py +++ b/cartoframes/data/observatory/catalog/geography.py @@ -1,6 +1,5 @@ from __future__ import absolute_import - from .entity import CatalogEntity from .repository.dataset_repo import get_dataset_repo from .repository.geography_repo import get_geography_repo diff --git a/cartoframes/data/observatory/catalog/repository/entity_repo.py b/cartoframes/data/observatory/catalog/repository/entity_repo.py index 3d7af211b..a3a6bf733 100644 --- a/cartoframes/data/observatory/catalog/repository/entity_repo.py +++ b/cartoframes/data/observatory/catalog/repository/entity_repo.py @@ -1,6 +1,6 @@ from cartoframes.exceptions import DiscoveryException -from cartoframes.data.observatory.entity import CatalogList, is_slug_value from .repo_client import RepoClient +from ..entity import CatalogList, is_slug_value try: from abc import ABC, abstractmethod diff --git a/cartoframes/data/observatory/catalog/repository/geography_repo.py b/cartoframes/data/observatory/catalog/repository/geography_repo.py index 2c696f1f2..17ef01219 100644 --- a/cartoframes/data/observatory/catalog/repository/geography_repo.py +++ b/cartoframes/data/observatory/catalog/repository/geography_repo.py @@ -1,9 +1,10 @@ from __future__ import absolute_import import geopandas as gpd -from cartoframes.auth import Credentials from cartoframes.data import Dataset +from cartoframes.auth import Credentials + from .constants import COUNTRY_FILTER, CATEGORY_FILTER from .entity_repo import EntityRepository diff --git a/cartoframes/data/observatory/catalog/repository/repo_client.py b/cartoframes/data/observatory/catalog/repository/repo_client.py index 3d4a8063b..3cae1fdfc 100644 --- a/cartoframes/data/observatory/catalog/repository/repo_client.py +++ b/cartoframes/data/observatory/catalog/repository/repo_client.py @@ -1,7 +1,7 @@ from __future__ import absolute_import -from ...clients import SQLClient -from ....auth import Credentials +from ....clients import SQLClient +from .....auth import Credentials from ..subscriptions import get_subscription_ids diff --git a/cartoframes/data/observatory/enrichment/enrichment_service.py b/cartoframes/data/observatory/enrichment/enrichment_service.py index 2bac3e4d2..56ebd708b 100644 --- a/cartoframes/data/observatory/enrichment/enrichment_service.py +++ b/cartoframes/data/observatory/enrichment/enrichment_service.py @@ -3,14 +3,13 @@ from collections import defaultdict -from ...auth import get_default_credentials -from ...exceptions import EnrichmentException -from ...utils.geom_utils import (_compute_geometry_from_geom, geojson_to_wkt, - wkt_to_geojson) -from ..clients import bigquery_client -from ..dataset.dataset import Dataset -from ..observatory import Variable -from ..observatory import CatalogDataset +from ..catalog.variable import Variable +from ..catalog.dataset import CatalogDataset +from ...dataset.dataset import Dataset +from ...clients import bigquery_client +from ....auth import get_default_credentials +from ....exceptions import EnrichmentException +from ....utils.geom_utils import _compute_geometry_from_geom, geojson_to_wkt, wkt_to_geojson _ENRICHMENT_ID = 'enrichment_id' From 331afd376eab154548129dbde7d855d85367709d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Wed, 23 Oct 2019 18:16:41 +0200 Subject: [PATCH 3/3] Refactor DO structure in tests --- .../catalog/repository/category_repo.py | 2 +- .../catalog/repository/country_repo.py | 2 +- .../catalog/repository/dataset_repo.py | 2 +- .../catalog/repository/geography_repo.py | 2 +- .../catalog/repository/provider_repo.py | 2 +- .../catalog/repository/variable_group_repo.py | 2 +- .../catalog/repository/variable_repo.py | 2 +- tests/README.md | 2 +- .../{repository => catalog}/__init__.py | 0 .../observatory/{ => catalog}/examples.py | 16 ++++----- .../data/observatory/{ => catalog}/mocks.py | 0 .../catalog/repository/__init__.py | 0 .../repository/test_category_repo.py | 9 +++-- .../repository/test_country_repo.py | 8 ++--- .../repository/test_dataset_repo.py | 8 ++--- .../repository/test_geography_repo.py | 8 ++--- .../repository/test_provider_repo.py | 8 ++--- .../repository/test_repo_client.py | 2 +- .../repository/test_variable_group_repo.py | 8 ++--- .../repository/test_variable_repo.py | 8 ++--- .../observatory/{ => catalog}/test_catalog.py | 14 ++++---- .../{ => catalog}/test_category.py | 10 +++--- .../observatory/{ => catalog}/test_country.py | 12 +++---- .../observatory/{ => catalog}/test_dataset.py | 36 +++++++++---------- .../{ => catalog}/test_geography.py | 34 +++++++++--------- .../{ => catalog}/test_provider.py | 8 ++--- .../{ => catalog}/test_variable.py | 8 ++--- .../{ => catalog}/test_variable_group.py | 8 ++--- .../enrichment/test_service.py | 8 ++--- 29 files changed, 114 insertions(+), 115 deletions(-) rename tests/unit/data/observatory/{repository => catalog}/__init__.py (100%) rename tests/unit/data/observatory/{ => catalog}/examples.py (89%) rename tests/unit/data/observatory/{ => catalog}/mocks.py (100%) create mode 100644 tests/unit/data/observatory/catalog/repository/__init__.py rename tests/unit/data/observatory/{ => catalog}/repository/test_category_repo.py (93%) rename tests/unit/data/observatory/{ => catalog}/repository/test_country_repo.py (91%) rename tests/unit/data/observatory/{ => catalog}/repository/test_dataset_repo.py (95%) rename tests/unit/data/observatory/{ => catalog}/repository/test_geography_repo.py (95%) rename tests/unit/data/observatory/{ => catalog}/repository/test_provider_repo.py (88%) rename tests/unit/data/observatory/{ => catalog}/repository/test_repo_client.py (96%) rename tests/unit/data/observatory/{ => catalog}/repository/test_variable_group_repo.py (94%) rename tests/unit/data/observatory/{ => catalog}/repository/test_variable_repo.py (94%) rename tests/unit/data/observatory/{ => catalog}/test_catalog.py (93%) rename tests/unit/data/observatory/{ => catalog}/test_category.py (92%) rename tests/unit/data/observatory/{ => catalog}/test_country.py (91%) rename tests/unit/data/observatory/{ => catalog}/test_dataset.py (89%) rename tests/unit/data/observatory/{ => catalog}/test_geography.py (89%) rename tests/unit/data/observatory/{ => catalog}/test_provider.py (93%) rename tests/unit/data/observatory/{ => catalog}/test_variable.py (95%) rename tests/unit/data/observatory/{ => catalog}/test_variable_group.py (94%) rename tests/unit/data/{ => observatory}/enrichment/test_service.py (96%) diff --git a/cartoframes/data/observatory/catalog/repository/category_repo.py b/cartoframes/data/observatory/catalog/repository/category_repo.py index 7aacbb69a..e26c6a984 100644 --- a/cartoframes/data/observatory/catalog/repository/category_repo.py +++ b/cartoframes/data/observatory/catalog/repository/category_repo.py @@ -19,7 +19,7 @@ def __init__(self): @classmethod def _get_entity_class(cls): - from cartoframes.data.observatory.category import Category + from cartoframes.data.observatory.catalog.category import Category return Category def _get_rows(self, filters=None): diff --git a/cartoframes/data/observatory/catalog/repository/country_repo.py b/cartoframes/data/observatory/catalog/repository/country_repo.py index 44068f78c..b4da43760 100644 --- a/cartoframes/data/observatory/catalog/repository/country_repo.py +++ b/cartoframes/data/observatory/catalog/repository/country_repo.py @@ -19,7 +19,7 @@ def __init__(self): @classmethod def _get_entity_class(cls): - from cartoframes.data.observatory.country import Country + from cartoframes.data.observatory.catalog.country import Country return Country def _get_rows(self, filters=None): diff --git a/cartoframes/data/observatory/catalog/repository/dataset_repo.py b/cartoframes/data/observatory/catalog/repository/dataset_repo.py index 6ce050465..2ec2e2c45 100644 --- a/cartoframes/data/observatory/catalog/repository/dataset_repo.py +++ b/cartoframes/data/observatory/catalog/repository/dataset_repo.py @@ -28,7 +28,7 @@ def get_all(self, filters=None, credentials=None): @classmethod def _get_entity_class(cls): - from cartoframes.data.observatory.dataset import CatalogDataset + from cartoframes.data.observatory.catalog.dataset import CatalogDataset return CatalogDataset def _get_rows(self, filters=None): diff --git a/cartoframes/data/observatory/catalog/repository/geography_repo.py b/cartoframes/data/observatory/catalog/repository/geography_repo.py index 17ef01219..963267350 100644 --- a/cartoframes/data/observatory/catalog/repository/geography_repo.py +++ b/cartoframes/data/observatory/catalog/repository/geography_repo.py @@ -33,7 +33,7 @@ def get_all(self, filters=None, credentials=None): @classmethod def _get_entity_class(cls): - from cartoframes.data.observatory.geography import Geography + from cartoframes.data.observatory.catalog.geography import Geography return Geography def _get_rows(self, filters=None): diff --git a/cartoframes/data/observatory/catalog/repository/provider_repo.py b/cartoframes/data/observatory/catalog/repository/provider_repo.py index 7c3dfe535..4d3406e13 100644 --- a/cartoframes/data/observatory/catalog/repository/provider_repo.py +++ b/cartoframes/data/observatory/catalog/repository/provider_repo.py @@ -17,7 +17,7 @@ def __init__(self): @classmethod def _get_entity_class(cls): - from cartoframes.data.observatory.provider import Provider + from cartoframes.data.observatory.catalog.provider import Provider return Provider def _get_rows(self, filters=None): diff --git a/cartoframes/data/observatory/catalog/repository/variable_group_repo.py b/cartoframes/data/observatory/catalog/repository/variable_group_repo.py index 6db22584d..d2971b077 100644 --- a/cartoframes/data/observatory/catalog/repository/variable_group_repo.py +++ b/cartoframes/data/observatory/catalog/repository/variable_group_repo.py @@ -21,7 +21,7 @@ def __init__(self): @classmethod def _get_entity_class(cls): - from cartoframes.data.observatory.variable_group import VariableGroup + from cartoframes.data.observatory.catalog.variable_group import VariableGroup return VariableGroup def _get_rows(self, filters=None): diff --git a/cartoframes/data/observatory/catalog/repository/variable_repo.py b/cartoframes/data/observatory/catalog/repository/variable_repo.py index ecb37abb3..21e19c4b3 100644 --- a/cartoframes/data/observatory/catalog/repository/variable_repo.py +++ b/cartoframes/data/observatory/catalog/repository/variable_repo.py @@ -20,7 +20,7 @@ def __init__(self): @classmethod def _get_entity_class(cls): - from cartoframes.data.observatory.variable import Variable + from cartoframes.data.observatory.catalog.variable import Variable return Variable def _get_rows(self, filters=None): diff --git a/tests/README.md b/tests/README.md index fc6061869..eb8ab0b57 100644 --- a/tests/README.md +++ b/tests/README.md @@ -35,7 +35,7 @@ tox -e e2e ### Linter -We use `flake8` in CI because it's standard, fast and compatible with GitHub tools like Hound. However, we use also `pylint`for a deeper lint analysis with `tox -e pylint`. +We use `flake8` in CI because it's standard, fast and compatible with GitHub tools like Hound. However, we use also `pylint`for a deeper lint analysis with `tox -e lint`. ### Testing diff --git a/tests/unit/data/observatory/repository/__init__.py b/tests/unit/data/observatory/catalog/__init__.py similarity index 100% rename from tests/unit/data/observatory/repository/__init__.py rename to tests/unit/data/observatory/catalog/__init__.py diff --git a/tests/unit/data/observatory/examples.py b/tests/unit/data/observatory/catalog/examples.py similarity index 89% rename from tests/unit/data/observatory/examples.py rename to tests/unit/data/observatory/catalog/examples.py index c5ecfc327..c8dcef16a 100644 --- a/tests/unit/data/observatory/examples.py +++ b/tests/unit/data/observatory/catalog/examples.py @@ -1,11 +1,11 @@ -from cartoframes.data.observatory.variable import Variable -from cartoframes.data.observatory.dataset import CatalogDataset -from cartoframes.data.observatory.category import Category -from cartoframes.data.observatory.geography import Geography -from cartoframes.data.observatory.country import Country -from cartoframes.data.observatory.provider import Provider -from cartoframes.data.observatory.variable_group import VariableGroup -from cartoframes.data.observatory.entity import CatalogList +from cartoframes.data.observatory.catalog.variable import Variable +from cartoframes.data.observatory.catalog.dataset import CatalogDataset +from cartoframes.data.observatory.catalog.category import Category +from cartoframes.data.observatory.catalog.geography import Geography +from cartoframes.data.observatory.catalog.country import Country +from cartoframes.data.observatory.catalog.provider import Provider +from cartoframes.data.observatory.catalog.variable_group import VariableGroup +from cartoframes.data.observatory.catalog.entity import CatalogList db_country1 = {'id': 'esp'} db_country2 = {'id': 'usa'} diff --git a/tests/unit/data/observatory/mocks.py b/tests/unit/data/observatory/catalog/mocks.py similarity index 100% rename from tests/unit/data/observatory/mocks.py rename to tests/unit/data/observatory/catalog/mocks.py diff --git a/tests/unit/data/observatory/catalog/repository/__init__.py b/tests/unit/data/observatory/catalog/repository/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/unit/data/observatory/repository/test_category_repo.py b/tests/unit/data/observatory/catalog/repository/test_category_repo.py similarity index 93% rename from tests/unit/data/observatory/repository/test_category_repo.py rename to tests/unit/data/observatory/catalog/repository/test_category_repo.py index 8a12e4f5f..3ea964f07 100644 --- a/tests/unit/data/observatory/repository/test_category_repo.py +++ b/tests/unit/data/observatory/catalog/repository/test_category_repo.py @@ -1,11 +1,10 @@ import pytest -from cartoframes.data.observatory.category import Category - from cartoframes.exceptions import DiscoveryException -from cartoframes.data.observatory.entity import CatalogList -from cartoframes.data.observatory.repository.category_repo import CategoryRepository -from cartoframes.data.observatory.repository.repo_client import RepoClient +from cartoframes.data.observatory.catalog.category import Category +from cartoframes.data.observatory.catalog.entity import CatalogList +from cartoframes.data.observatory.catalog.repository.category_repo import CategoryRepository +from cartoframes.data.observatory.catalog.repository.repo_client import RepoClient from ..examples import test_category1, test_categories, db_category1, db_category2 try: diff --git a/tests/unit/data/observatory/repository/test_country_repo.py b/tests/unit/data/observatory/catalog/repository/test_country_repo.py similarity index 91% rename from tests/unit/data/observatory/repository/test_country_repo.py rename to tests/unit/data/observatory/catalog/repository/test_country_repo.py index 7276ec834..a0ed31843 100644 --- a/tests/unit/data/observatory/repository/test_country_repo.py +++ b/tests/unit/data/observatory/catalog/repository/test_country_repo.py @@ -1,10 +1,10 @@ import pytest from cartoframes.exceptions import DiscoveryException -from cartoframes.data.observatory.entity import CatalogList -from cartoframes.data.observatory.country import Country -from cartoframes.data.observatory.repository.country_repo import CountryRepository -from cartoframes.data.observatory.repository.repo_client import RepoClient +from cartoframes.data.observatory.catalog.entity import CatalogList +from cartoframes.data.observatory.catalog.country import Country +from cartoframes.data.observatory.catalog.repository.country_repo import CountryRepository +from cartoframes.data.observatory.catalog.repository.repo_client import RepoClient from ..examples import test_countries, test_country1, db_country1, db_country2 try: diff --git a/tests/unit/data/observatory/repository/test_dataset_repo.py b/tests/unit/data/observatory/catalog/repository/test_dataset_repo.py similarity index 95% rename from tests/unit/data/observatory/repository/test_dataset_repo.py rename to tests/unit/data/observatory/catalog/repository/test_dataset_repo.py index f2e769632..8aa205550 100644 --- a/tests/unit/data/observatory/repository/test_dataset_repo.py +++ b/tests/unit/data/observatory/catalog/repository/test_dataset_repo.py @@ -3,10 +3,10 @@ from cartoframes.auth import Credentials from cartoframes.exceptions import DiscoveryException -from cartoframes.data.observatory.dataset import CatalogDataset -from cartoframes.data.observatory.entity import CatalogList -from cartoframes.data.observatory.repository.dataset_repo import DatasetRepository -from cartoframes.data.observatory.repository.repo_client import RepoClient +from cartoframes.data.observatory.catalog.entity import CatalogList +from cartoframes.data.observatory.catalog.dataset import CatalogDataset +from cartoframes.data.observatory.catalog.repository.dataset_repo import DatasetRepository +from cartoframes.data.observatory.catalog.repository.repo_client import RepoClient from ..examples import test_dataset1, test_datasets, db_dataset1, db_dataset2 try: diff --git a/tests/unit/data/observatory/repository/test_geography_repo.py b/tests/unit/data/observatory/catalog/repository/test_geography_repo.py similarity index 95% rename from tests/unit/data/observatory/repository/test_geography_repo.py rename to tests/unit/data/observatory/catalog/repository/test_geography_repo.py index dfb23453d..2009d2a25 100644 --- a/tests/unit/data/observatory/repository/test_geography_repo.py +++ b/tests/unit/data/observatory/catalog/repository/test_geography_repo.py @@ -2,10 +2,10 @@ from cartoframes.auth import Credentials from cartoframes.exceptions import DiscoveryException -from cartoframes.data.observatory.entity import CatalogList -from cartoframes.data.observatory.geography import Geography -from cartoframes.data.observatory.repository.geography_repo import GeographyRepository -from cartoframes.data.observatory.repository.repo_client import RepoClient +from cartoframes.data.observatory.catalog.entity import CatalogList +from cartoframes.data.observatory.catalog.geography import Geography +from cartoframes.data.observatory.catalog.repository.geography_repo import GeographyRepository +from cartoframes.data.observatory.catalog.repository.repo_client import RepoClient from ..examples import test_geography1, test_geographies, db_geography1, db_geography2 try: diff --git a/tests/unit/data/observatory/repository/test_provider_repo.py b/tests/unit/data/observatory/catalog/repository/test_provider_repo.py similarity index 88% rename from tests/unit/data/observatory/repository/test_provider_repo.py rename to tests/unit/data/observatory/catalog/repository/test_provider_repo.py index 8ac37095d..e4cbe6ac0 100644 --- a/tests/unit/data/observatory/repository/test_provider_repo.py +++ b/tests/unit/data/observatory/catalog/repository/test_provider_repo.py @@ -1,10 +1,10 @@ import pytest from cartoframes.exceptions import DiscoveryException -from cartoframes.data.observatory.entity import CatalogList -from cartoframes.data.observatory.provider import Provider -from cartoframes.data.observatory.repository.provider_repo import ProviderRepository -from cartoframes.data.observatory.repository.repo_client import RepoClient +from cartoframes.data.observatory.catalog.entity import CatalogList +from cartoframes.data.observatory.catalog.provider import Provider +from cartoframes.data.observatory.catalog.repository.provider_repo import ProviderRepository +from cartoframes.data.observatory.catalog.repository.repo_client import RepoClient from ..examples import test_provider1, test_providers, db_provider1, db_provider2 try: diff --git a/tests/unit/data/observatory/repository/test_repo_client.py b/tests/unit/data/observatory/catalog/repository/test_repo_client.py similarity index 96% rename from tests/unit/data/observatory/repository/test_repo_client.py rename to tests/unit/data/observatory/catalog/repository/test_repo_client.py index 3d4333905..edb313fd2 100644 --- a/tests/unit/data/observatory/repository/test_repo_client.py +++ b/tests/unit/data/observatory/catalog/repository/test_repo_client.py @@ -1,5 +1,5 @@ from cartoframes.data.clients import SQLClient -from cartoframes.data.observatory.repository.repo_client import RepoClient +from cartoframes.data.observatory.catalog.repository.repo_client import RepoClient from ..examples import db_dataset1, db_dataset2 diff --git a/tests/unit/data/observatory/repository/test_variable_group_repo.py b/tests/unit/data/observatory/catalog/repository/test_variable_group_repo.py similarity index 94% rename from tests/unit/data/observatory/repository/test_variable_group_repo.py rename to tests/unit/data/observatory/catalog/repository/test_variable_group_repo.py index 87798c182..6d1304843 100644 --- a/tests/unit/data/observatory/repository/test_variable_group_repo.py +++ b/tests/unit/data/observatory/catalog/repository/test_variable_group_repo.py @@ -1,10 +1,10 @@ import pytest from cartoframes.exceptions import DiscoveryException -from cartoframes.data.observatory.entity import CatalogList -from cartoframes.data.observatory.variable_group import VariableGroup -from cartoframes.data.observatory.repository.variable_group_repo import VariableGroupRepository -from cartoframes.data.observatory.repository.repo_client import RepoClient +from cartoframes.data.observatory.catalog.entity import CatalogList +from cartoframes.data.observatory.catalog.variable_group import VariableGroup +from cartoframes.data.observatory.catalog.repository.variable_group_repo import VariableGroupRepository +from cartoframes.data.observatory.catalog.repository.repo_client import RepoClient from ..examples import test_variable_group1, test_variables_groups, db_variable_group1, db_variable_group2 try: diff --git a/tests/unit/data/observatory/repository/test_variable_repo.py b/tests/unit/data/observatory/catalog/repository/test_variable_repo.py similarity index 94% rename from tests/unit/data/observatory/repository/test_variable_repo.py rename to tests/unit/data/observatory/catalog/repository/test_variable_repo.py index 82dbb0217..7e612848a 100644 --- a/tests/unit/data/observatory/repository/test_variable_repo.py +++ b/tests/unit/data/observatory/catalog/repository/test_variable_repo.py @@ -1,10 +1,10 @@ import pytest from cartoframes.exceptions import DiscoveryException -from cartoframes.data.observatory.entity import CatalogList -from cartoframes.data.observatory.variable import Variable -from cartoframes.data.observatory.repository.variable_repo import VariableRepository -from cartoframes.data.observatory.repository.repo_client import RepoClient +from cartoframes.data.observatory.catalog.entity import CatalogList +from cartoframes.data.observatory.catalog.variable import Variable +from cartoframes.data.observatory.catalog.repository.variable_repo import VariableRepository +from cartoframes.data.observatory.catalog.repository.repo_client import RepoClient from ..examples import test_variable1, test_variables, db_variable1, db_variable2 try: diff --git a/tests/unit/data/observatory/test_catalog.py b/tests/unit/data/observatory/catalog/test_catalog.py similarity index 93% rename from tests/unit/data/observatory/test_catalog.py rename to tests/unit/data/observatory/catalog/test_catalog.py index d24c7d4ed..4eaa8cda0 100644 --- a/tests/unit/data/observatory/test_catalog.py +++ b/tests/unit/data/observatory/catalog/test_catalog.py @@ -1,13 +1,13 @@ import pytest from cartoframes.auth import Credentials -from cartoframes.data.observatory.dataset import CatalogDataset -from cartoframes.data.observatory.geography import Geography -from cartoframes.data.observatory.country import Country -from cartoframes.data.observatory.category import Category -from cartoframes.data.observatory.catalog import Catalog -from cartoframes.data.observatory.subscriptions import Subscriptions -from cartoframes.data.observatory.repository.geography_repo import GeographyRepository +from cartoframes.data.observatory.catalog.dataset import CatalogDataset +from cartoframes.data.observatory.catalog.geography import Geography +from cartoframes.data.observatory.catalog.country import Country +from cartoframes.data.observatory.catalog.category import Category +from cartoframes.data.observatory.catalog.catalog import Catalog +from cartoframes.data.observatory.catalog.subscriptions import Subscriptions +from cartoframes.data.observatory.catalog.repository.geography_repo import GeographyRepository from .examples import test_country2, test_country1, test_category1, test_category2, test_dataset1, test_dataset2, \ test_geographies, test_datasets, test_categories, test_countries, test_geography1, test_geography2 diff --git a/tests/unit/data/observatory/test_category.py b/tests/unit/data/observatory/catalog/test_category.py similarity index 92% rename from tests/unit/data/observatory/test_category.py rename to tests/unit/data/observatory/catalog/test_category.py index 9228276bd..4e30ba771 100644 --- a/tests/unit/data/observatory/test_category.py +++ b/tests/unit/data/observatory/catalog/test_category.py @@ -1,10 +1,10 @@ import pandas as pd -from cartoframes.data.observatory.repository.geography_repo import GeographyRepository -from cartoframes.data.observatory.category import Category -from cartoframes.data.observatory.repository.category_repo import CategoryRepository -from cartoframes.data.observatory.repository.dataset_repo import DatasetRepository -from cartoframes.data.observatory.entity import CatalogList +from cartoframes.data.observatory.catalog.category import Category +from cartoframes.data.observatory.catalog.repository.dataset_repo import DatasetRepository +from cartoframes.data.observatory.catalog.repository.category_repo import CategoryRepository +from cartoframes.data.observatory.catalog.repository.geography_repo import GeographyRepository +from cartoframes.data.observatory.catalog.entity import CatalogList from .examples import test_category1, test_datasets, test_categories, db_category1, test_category2, db_category2, \ test_geographies diff --git a/tests/unit/data/observatory/test_country.py b/tests/unit/data/observatory/catalog/test_country.py similarity index 91% rename from tests/unit/data/observatory/test_country.py rename to tests/unit/data/observatory/catalog/test_country.py index 0fbaae4b5..fdc094125 100644 --- a/tests/unit/data/observatory/test_country.py +++ b/tests/unit/data/observatory/catalog/test_country.py @@ -1,11 +1,11 @@ import pandas as pd -from cartoframes.data.observatory.repository.category_repo import CategoryRepository -from cartoframes.data.observatory.entity import CatalogList -from cartoframes.data.observatory.country import Country -from cartoframes.data.observatory.repository.geography_repo import GeographyRepository -from cartoframes.data.observatory.repository.dataset_repo import DatasetRepository -from cartoframes.data.observatory.repository.country_repo import CountryRepository +from cartoframes.data.observatory.catalog.country import Country +from cartoframes.data.observatory.catalog.entity import CatalogList +from cartoframes.data.observatory.catalog.repository.country_repo import CountryRepository +from cartoframes.data.observatory.catalog.repository.dataset_repo import DatasetRepository +from cartoframes.data.observatory.catalog.repository.category_repo import CategoryRepository +from cartoframes.data.observatory.catalog.repository.geography_repo import GeographyRepository from .examples import test_country1, test_datasets, test_countries, test_geographies, db_country1, test_country2, \ db_country2, test_categories diff --git a/tests/unit/data/observatory/test_dataset.py b/tests/unit/data/observatory/catalog/test_dataset.py similarity index 89% rename from tests/unit/data/observatory/test_dataset.py rename to tests/unit/data/observatory/catalog/test_dataset.py index b9da53493..afdd0c488 100644 --- a/tests/unit/data/observatory/test_dataset.py +++ b/tests/unit/data/observatory/catalog/test_dataset.py @@ -6,12 +6,12 @@ from carto.exceptions import CartoException from cartoframes.auth import Credentials -from cartoframes.data.observatory.entity import CatalogList -from cartoframes.data.observatory.dataset import CatalogDataset -from cartoframes.data.observatory.repository.variable_repo import VariableRepository -from cartoframes.data.observatory.repository.variable_group_repo import VariableGroupRepository -from cartoframes.data.observatory.repository.dataset_repo import DatasetRepository -from cartoframes.data.observatory.subscription_info import SubscriptionInfo +from cartoframes.data.observatory.catalog.entity import CatalogList +from cartoframes.data.observatory.catalog.dataset import CatalogDataset +from cartoframes.data.observatory.catalog.repository.variable_repo import VariableRepository +from cartoframes.data.observatory.catalog.repository.variable_group_repo import VariableGroupRepository +from cartoframes.data.observatory.catalog.repository.dataset_repo import DatasetRepository +from cartoframes.data.observatory.catalog.subscription_info import SubscriptionInfo from .examples import test_dataset1, test_datasets, test_variables, test_variables_groups, db_dataset1, test_dataset2, \ db_dataset2, test_subscription_info from .mocks import BigQueryClientMock @@ -248,7 +248,7 @@ def test_datasets_are_exported_as_dataframe(self): assert sliced_dataset.equals(dataset.to_series()) @patch.object(DatasetRepository, 'get_by_id') - @patch('cartoframes.data.observatory.entity._get_bigquery_client') + @patch('cartoframes.data.observatory.catalog.entity._get_bigquery_client') def test_dataset_download(self, mocked_bq_client, mocked_repo): # mock dataset mocked_repo.return_value = test_dataset1 @@ -267,7 +267,7 @@ def test_dataset_download(self, mocked_bq_client, mocked_repo): assert response == file_path @patch.object(DatasetRepository, 'get_by_id') - @patch('cartoframes.data.observatory.entity._get_bigquery_client') + @patch('cartoframes.data.observatory.catalog.entity._get_bigquery_client') def test_dataset_download_raises_with_nonpurchased(self, mocked_bq_client, mocked_repo): # mock dataset mocked_repo.return_value = test_dataset1 @@ -283,9 +283,9 @@ def test_dataset_download_raises_with_nonpurchased(self, mocked_bq_client, mocke with pytest.raises(CartoException): dataset.download(credentials) - @patch('cartoframes.data.observatory.subscriptions.get_subscription_ids') - @patch('cartoframes.data.observatory.utils.display_subscription_form') - @patch('cartoframes.data.observatory.utils.display_existing_subscription_message') + @patch('cartoframes.data.observatory.catalog.subscriptions.get_subscription_ids') + @patch('cartoframes.data.observatory.catalog.utils.display_subscription_form') + @patch('cartoframes.data.observatory.catalog.utils.display_existing_subscription_message') def test_dataset_subscribe(self, mock_display_message, mock_display_form, mock_subscription_ids): # Given expected_id = db_dataset1['id'] @@ -302,9 +302,9 @@ def test_dataset_subscribe(self, mock_display_message, mock_display_form, mock_s mock_display_form.assert_called_once_with(expected_id, 'dataset', credentials) assert not mock_display_message.called - @patch('cartoframes.data.observatory.subscriptions.get_subscription_ids') - @patch('cartoframes.data.observatory.utils.display_subscription_form') - @patch('cartoframes.data.observatory.utils.display_existing_subscription_message') + @patch('cartoframes.data.observatory.catalog.subscriptions.get_subscription_ids') + @patch('cartoframes.data.observatory.catalog.utils.display_subscription_form') + @patch('cartoframes.data.observatory.catalog.utils.display_existing_subscription_message') def test_dataset_subscribe_existing(self, mock_display_message, mock_display_form, mock_subscription_ids): # Given expected_id = db_dataset1['id'] @@ -321,8 +321,8 @@ def test_dataset_subscribe_existing(self, mock_display_message, mock_display_for mock_display_message.assert_called_once_with(expected_id, 'dataset') assert not mock_display_form.called - @patch('cartoframes.data.observatory.subscriptions.get_subscription_ids') - @patch('cartoframes.data.observatory.utils.display_subscription_form') + @patch('cartoframes.data.observatory.catalog.subscriptions.get_subscription_ids') + @patch('cartoframes.data.observatory.catalog.utils.display_subscription_form') @patch('cartoframes.auth.defaults.get_default_credentials') def test_dataset_subscribe_default_credentials(self, mocked_credentials, mock_display_form, mock_subscription_ids): # Given @@ -349,7 +349,7 @@ def test_dataset_subscribe_wrong_credentials(self): # Then assert str(e.value) == '`credentials` must be a Credentials class instance' - @patch('cartoframes.data.observatory.subscription_info.fetch_subscription_info') + @patch('cartoframes.data.observatory.catalog.subscription_info.fetch_subscription_info') def test_dataset_subscription_info(self, mock_fetch): # Given mock_fetch.return_value = test_subscription_info @@ -374,7 +374,7 @@ def test_dataset_subscription_info(self, mock_fetch): 'subscription_list_price, tos, tos_link, ' + \ 'licenses, licenses_link, rights' - @patch('cartoframes.data.observatory.subscription_info.fetch_subscription_info') + @patch('cartoframes.data.observatory.catalog.subscription_info.fetch_subscription_info') @patch('cartoframes.auth.defaults.get_default_credentials') def test_dataset_subscription_info_default_credentials(self, mocked_credentials, mock_fetch): # Given diff --git a/tests/unit/data/observatory/test_geography.py b/tests/unit/data/observatory/catalog/test_geography.py similarity index 89% rename from tests/unit/data/observatory/test_geography.py rename to tests/unit/data/observatory/catalog/test_geography.py index 43ffca905..93f8dd43d 100644 --- a/tests/unit/data/observatory/test_geography.py +++ b/tests/unit/data/observatory/catalog/test_geography.py @@ -6,11 +6,11 @@ from carto.exceptions import CartoException from cartoframes.auth import Credentials -from cartoframes.data.observatory.entity import CatalogList -from cartoframes.data.observatory.geography import Geography -from cartoframes.data.observatory.repository.geography_repo import GeographyRepository -from cartoframes.data.observatory.repository.dataset_repo import DatasetRepository -from cartoframes.data.observatory.subscription_info import SubscriptionInfo +from cartoframes.data.observatory.catalog.entity import CatalogList +from cartoframes.data.observatory.catalog.geography import Geography +from cartoframes.data.observatory.catalog.repository.geography_repo import GeographyRepository +from cartoframes.data.observatory.catalog.repository.dataset_repo import DatasetRepository +from cartoframes.data.observatory.catalog.subscription_info import SubscriptionInfo from .examples import test_geography1, test_geographies, test_datasets, db_geography1, \ test_geography2, db_geography2, test_subscription_info from .mocks import BigQueryClientMock @@ -225,7 +225,7 @@ def test_geographies_are_exported_as_dataframe(self): assert sliced_geography.equals(geography.to_series()) @patch.object(GeographyRepository, 'get_by_id') - @patch('cartoframes.data.observatory.entity._get_bigquery_client') + @patch('cartoframes.data.observatory.catalog.entity._get_bigquery_client') def test_geography_download(self, mocked_bq_client, mocked_repo): # mock geography mocked_repo.return_value = test_geography1 @@ -244,7 +244,7 @@ def test_geography_download(self, mocked_bq_client, mocked_repo): assert response == file_path @patch.object(GeographyRepository, 'get_by_id') - @patch('cartoframes.data.observatory.entity._get_bigquery_client') + @patch('cartoframes.data.observatory.catalog.entity._get_bigquery_client') def test_geography_download_raises_with_nonpurchased(self, mocked_bq_client, mocked_repo): # mock geography mocked_repo.return_value = test_geography1 @@ -260,9 +260,9 @@ def test_geography_download_raises_with_nonpurchased(self, mocked_bq_client, moc with pytest.raises(CartoException): geography.download(credentials) - @patch('cartoframes.data.observatory.subscriptions.get_subscription_ids') - @patch('cartoframes.data.observatory.utils.display_subscription_form') - @patch('cartoframes.data.observatory.utils.display_existing_subscription_message') + @patch('cartoframes.data.observatory.catalog.subscriptions.get_subscription_ids') + @patch('cartoframes.data.observatory.catalog.utils.display_subscription_form') + @patch('cartoframes.data.observatory.catalog.utils.display_existing_subscription_message') def test_geography_subscribe(self, mock_display_message, mock_display_form, mock_subscription_ids): # Given expected_id = db_geography1['id'] @@ -279,9 +279,9 @@ def test_geography_subscribe(self, mock_display_message, mock_display_form, mock mock_display_form.assert_called_once_with(expected_id, 'geography', credentials) assert not mock_display_message.called - @patch('cartoframes.data.observatory.subscriptions.get_subscription_ids') - @patch('cartoframes.data.observatory.utils.display_subscription_form') - @patch('cartoframes.data.observatory.utils.display_existing_subscription_message') + @patch('cartoframes.data.observatory.catalog.subscriptions.get_subscription_ids') + @patch('cartoframes.data.observatory.catalog.utils.display_subscription_form') + @patch('cartoframes.data.observatory.catalog.utils.display_existing_subscription_message') def test_geography_subscribe_existing(self, mock_display_message, mock_display_form, mock_subscription_ids): # Given expected_id = db_geography1['id'] @@ -298,8 +298,8 @@ def test_geography_subscribe_existing(self, mock_display_message, mock_display_f mock_display_message.assert_called_once_with(expected_id, 'geography') assert not mock_display_form.called - @patch('cartoframes.data.observatory.subscriptions.get_subscription_ids') - @patch('cartoframes.data.observatory.utils.display_subscription_form') + @patch('cartoframes.data.observatory.catalog.subscriptions.get_subscription_ids') + @patch('cartoframes.data.observatory.catalog.utils.display_subscription_form') @patch('cartoframes.auth.defaults.get_default_credentials') def test_geography_subscribe_default_credentials( self, mocked_credentials, mock_display_form, mock_subscription_ids): @@ -327,7 +327,7 @@ def test_geography_subscribe_wrong_credentials(self): # Then assert str(e.value) == '`credentials` must be a Credentials class instance' - @patch('cartoframes.data.observatory.subscription_info.fetch_subscription_info') + @patch('cartoframes.data.observatory.catalog.subscription_info.fetch_subscription_info') def test_geography_subscription_info(self, mock_fetch): # Given mock_fetch.return_value = test_subscription_info @@ -352,7 +352,7 @@ def test_geography_subscription_info(self, mock_fetch): 'subscription_list_price, tos, tos_link, ' + \ 'licenses, licenses_link, rights' - @patch('cartoframes.data.observatory.subscription_info.fetch_subscription_info') + @patch('cartoframes.data.observatory.catalog.subscription_info.fetch_subscription_info') @patch('cartoframes.auth.defaults.get_default_credentials') def test_geography_subscription_info_default_credentials(self, mocked_credentials, mock_fetch): # Given diff --git a/tests/unit/data/observatory/test_provider.py b/tests/unit/data/observatory/catalog/test_provider.py similarity index 93% rename from tests/unit/data/observatory/test_provider.py rename to tests/unit/data/observatory/catalog/test_provider.py index b3280388c..b13575ef0 100644 --- a/tests/unit/data/observatory/test_provider.py +++ b/tests/unit/data/observatory/catalog/test_provider.py @@ -1,9 +1,9 @@ import pandas as pd -from cartoframes.data.observatory.entity import CatalogList -from cartoframes.data.observatory.provider import Provider -from cartoframes.data.observatory.repository.provider_repo import ProviderRepository -from cartoframes.data.observatory.repository.dataset_repo import DatasetRepository +from cartoframes.data.observatory.catalog.entity import CatalogList +from cartoframes.data.observatory.catalog.provider import Provider +from cartoframes.data.observatory.catalog.repository.provider_repo import ProviderRepository +from cartoframes.data.observatory.catalog.repository.dataset_repo import DatasetRepository from .examples import test_datasets, test_provider1, test_providers, db_provider1, test_provider2, db_provider2 try: diff --git a/tests/unit/data/observatory/test_variable.py b/tests/unit/data/observatory/catalog/test_variable.py similarity index 95% rename from tests/unit/data/observatory/test_variable.py rename to tests/unit/data/observatory/catalog/test_variable.py index 71f1ddc3a..5f8cd9455 100644 --- a/tests/unit/data/observatory/test_variable.py +++ b/tests/unit/data/observatory/catalog/test_variable.py @@ -1,9 +1,9 @@ import pandas as pd -from cartoframes.data.observatory.entity import CatalogList -from cartoframes.data.observatory.variable import Variable -from cartoframes.data.observatory.repository.variable_repo import VariableRepository -from cartoframes.data.observatory.repository.dataset_repo import DatasetRepository +from cartoframes.data.observatory.catalog.entity import CatalogList +from cartoframes.data.observatory.catalog.variable import Variable +from cartoframes.data.observatory.catalog.repository.variable_repo import VariableRepository +from cartoframes.data.observatory.catalog.repository.dataset_repo import DatasetRepository from .examples import test_datasets, test_variable1, test_variables, db_variable1, test_variable2, db_variable2 try: diff --git a/tests/unit/data/observatory/test_variable_group.py b/tests/unit/data/observatory/catalog/test_variable_group.py similarity index 94% rename from tests/unit/data/observatory/test_variable_group.py rename to tests/unit/data/observatory/catalog/test_variable_group.py index 1abf749b4..95a0f4948 100644 --- a/tests/unit/data/observatory/test_variable_group.py +++ b/tests/unit/data/observatory/catalog/test_variable_group.py @@ -1,9 +1,9 @@ import pandas as pd -from cartoframes.data.observatory.entity import CatalogList -from cartoframes.data.observatory.variable_group import VariableGroup -from cartoframes.data.observatory.repository.variable_repo import VariableRepository -from cartoframes.data.observatory.repository.variable_group_repo import VariableGroupRepository +from cartoframes.data.observatory.catalog.entity import CatalogList +from cartoframes.data.observatory.catalog.variable_group import VariableGroup +from cartoframes.data.observatory.catalog.repository.variable_repo import VariableRepository +from cartoframes.data.observatory.catalog.repository.variable_group_repo import VariableGroupRepository from .examples import test_variables_groups, test_variable_group1, test_variables, db_variable_group1, \ test_variable_group2, db_variable_group2 diff --git a/tests/unit/data/enrichment/test_service.py b/tests/unit/data/observatory/enrichment/test_service.py similarity index 96% rename from tests/unit/data/enrichment/test_service.py rename to tests/unit/data/observatory/enrichment/test_service.py index 8d435e8cf..27269d6d6 100644 --- a/tests/unit/data/enrichment/test_service.py +++ b/tests/unit/data/observatory/enrichment/test_service.py @@ -1,10 +1,10 @@ import pandas as pd from shapely.geometry.point import Point -from cartoframes.data.enrichment.enrichment_service import _prepare_data, _upload_dataframe, _enrichment_queries, \ - _execute_enrichment, _get_bigquery_client -from cartoframes.data.enrichment.points_enrichment import _prepare_sql as _prepare_sql_by_points -from cartoframes.data.enrichment.polygons_enrichment import _prepare_sql as _prepare_sql_by_polygons +from cartoframes.data.observatory.enrichment.enrichment_service import _prepare_data, _upload_dataframe, \ + _enrichment_queries, _execute_enrichment, _get_bigquery_client +from cartoframes.data.observatory.enrichment.points_enrichment import _prepare_sql as _prepare_sql_by_points +from cartoframes.data.observatory.enrichment.polygons_enrichment import _prepare_sql as _prepare_sql_by_polygons from cartoframes.data import Dataset from cartoframes.data.clients.bigquery_client import BigQueryClient