Repository: great-expectations/great_expectations

Issue:
Use cleaner solution for non-truncating division in python 2
Prefer `from __future__ import division` to `1.*x/y`


Discussion:
Done inline during improve_partitions push.

Resolving patch:
diff --git a/great_expectations/data_context/cloud_constants.py b/great_expectations/data_context/cloud_constants.py
new file mode 100644
--- /dev/null
+++ b/great_expectations/data_context/cloud_constants.py
@@ -0,0 +1,3 @@
+from typing_extensions import Final
+
+CLOUD_DEFAULT_BASE_URL: Final[str] = "https://api.greatexpectations.io/"
diff --git a/great_expectations/data_context/data_context/cloud_data_context.py b/great_expectations/data_context/data_context/cloud_data_context.py
--- a/great_expectations/data_context/data_context/cloud_data_context.py
+++ b/great_expectations/data_context/data_context/cloud_data_context.py
@@ -11,6 +11,7 @@
 from great_expectations import __version__
 from great_expectations.core import ExpectationSuite
 from great_expectations.core.serializer import JsonConfigSerializer
+from great_expectations.data_context.cloud_constants import CLOUD_DEFAULT_BASE_URL
 from great_expectations.data_context.data_context.abstract_data_context import (
     AbstractDataContext,
 )
@@ -246,7 +247,7 @@ def _get_ge_cloud_config_dict(
                 conf_file_section="ge_cloud_config",
                 conf_file_option="base_url",
             )
-            or "https://app.greatexpectations.io/"
+            or CLOUD_DEFAULT_BASE_URL
         )
         ge_cloud_organization_id = (
             ge_cloud_organization_id
diff --git a/great_expectations/data_context/store/ge_cloud_store_backend.py b/great_expectations/data_context/store/ge_cloud_store_backend.py
--- a/great_expectations/data_context/store/ge_cloud_store_backend.py
+++ b/great_expectations/data_context/store/ge_cloud_store_backend.py
@@ -8,6 +8,7 @@
 import requests
 
 from great_expectations.core.http import create_session
+from great_expectations.data_context.cloud_constants import CLOUD_DEFAULT_BASE_URL
 from great_expectations.data_context.store.store_backend import StoreBackend
 from great_expectations.data_context.types.refs import GeCloudResourceRef
 from great_expectations.data_context.types.resource_identifiers import GeCloudIdentifier
@@ -176,12 +177,10 @@ class GeCloudStoreBackend(StoreBackend, metaclass=ABCMeta):
         }
     )
 
-    DEFAULT_BASE_URL = "https://app.greatexpectations.io/"
-
     def __init__(
         self,
         ge_cloud_credentials: Dict,
-        ge_cloud_base_url: str = DEFAULT_BASE_URL,
+        ge_cloud_base_url: str = CLOUD_DEFAULT_BASE_URL,
         ge_cloud_resource_type: Optional[Union[str, GeCloudRESTResource]] = None,
         ge_cloud_resource_name: Optional[str] = None,
         suppress_store_backend_id: bool = True,


Test patch:
diff --git a/tests/data_context/store/test_ge_cloud_store_backend.py b/tests/data_context/store/test_ge_cloud_store_backend.py
--- a/tests/data_context/store/test_ge_cloud_store_backend.py
+++ b/tests/data_context/store/test_ge_cloud_store_backend.py
@@ -16,6 +16,7 @@
 
 import pytest
 
+from great_expectations.data_context.cloud_constants import CLOUD_DEFAULT_BASE_URL
 from great_expectations.data_context.store.ge_cloud_store_backend import (
     GeCloudRESTResource,
     GeCloudStoreBackend,
@@ -30,7 +31,7 @@ def construct_ge_cloud_store_backend(
     ge_cloud_access_token: str,
 ) -> Callable[[GeCloudRESTResource], GeCloudStoreBackend]:
     def _closure(resource_type: GeCloudRESTResource) -> GeCloudStoreBackend:
-        ge_cloud_base_url = "https://app.greatexpectations.io/"
+        ge_cloud_base_url = CLOUD_DEFAULT_BASE_URL
         ge_cloud_credentials = {
             "access_token": ge_cloud_access_token,
             "organization_id": "51379b8b-86d3-4fe7-84e9-e1a52f4a414c",
@@ -197,7 +198,7 @@ def test_construct_json_payload(
             organization_id=organization_id,
             attributes_key=attributes_key,
             attributes_value=attributes_value,
-            **kwargs
+            **kwargs,
         )
         == expected
     )
@@ -227,7 +228,7 @@ def test_set(
         store_backend.set(("checkpoint", ""), my_simple_checkpoint_config_serialized)
         mock_post.assert_called_with(
             mock.ANY,  # requests.Session object
-            "https://app.greatexpectations.io/organizations/51379b8b-86d3-4fe7-84e9-e1a52f4a414c/checkpoints",
+            f"{CLOUD_DEFAULT_BASE_URL}organizations/51379b8b-86d3-4fe7-84e9-e1a52f4a414c/checkpoints",
             json={
                 "data": {
                     "type": "checkpoint",
@@ -271,7 +272,7 @@ def test_list_keys(
         store_backend.list_keys()
         mock_get.assert_called_with(
             mock.ANY,  # requests.Session object
-            "https://app.greatexpectations.io/organizations/51379b8b-86d3-4fe7-84e9-e1a52f4a414c/checkpoints",
+            f"{CLOUD_DEFAULT_BASE_URL}organizations/51379b8b-86d3-4fe7-84e9-e1a52f4a414c/checkpoints",
         )
 
 
@@ -296,7 +297,7 @@ def test_remove_key(
         )
         mock_delete.assert_called_with(
             mock.ANY,  # requests.Session object
-            "https://app.greatexpectations.io/organizations/51379b8b-86d3-4fe7-84e9-e1a52f4a414c/checkpoints/0ccac18e-7631"
+            f"{CLOUD_DEFAULT_BASE_URL}organizations/51379b8b-86d3-4fe7-84e9-e1a52f4a414c/checkpoints/0ccac18e-7631"
             "-4bdd"
             "-8a42-3c35cce574c6",
             json={
@@ -403,7 +404,7 @@ def test_config_property_and_defaults(
     assert store_backend.config == {
         "class_name": "GeCloudStoreBackend",
         "fixed_length_key": True,
-        "ge_cloud_base_url": "https://app.greatexpectations.io/",
+        "ge_cloud_base_url": CLOUD_DEFAULT_BASE_URL,
         "ge_cloud_resource_type": GeCloudRESTResource.CHECKPOINT,
         "manually_initialize_store_backend_id": "",
         "module_name": "great_expectations.data_context.store.ge_cloud_store_backend",
diff --git a/tests/data_context/test_data_context_ge_cloud_mode.py b/tests/data_context/test_data_context_ge_cloud_mode.py
--- a/tests/data_context/test_data_context_ge_cloud_mode.py
+++ b/tests/data_context/test_data_context_ge_cloud_mode.py
@@ -3,7 +3,7 @@
 import pytest
 
 from great_expectations.data_context import BaseDataContext, DataContext
-from great_expectations.data_context.store import GeCloudStoreBackend
+from great_expectations.data_context.cloud_constants import CLOUD_DEFAULT_BASE_URL
 from great_expectations.exceptions import DataContextError, GeCloudError
 
 
@@ -86,7 +86,7 @@ def test_data_context_in_cloud_mode_passes_base_url_to_store_backend(
     context: BaseDataContext = empty_base_data_context_in_cloud_mode_custom_base_url
 
     # Assertions that the context fixture is set up properly
-    assert not context.ge_cloud_config.base_url == GeCloudStoreBackend.DEFAULT_BASE_URL
+    assert not context.ge_cloud_config.base_url == CLOUD_DEFAULT_BASE_URL
     assert not context.ge_cloud_config.base_url == ge_cloud_base_url
     assert (
         not context.ge_cloud_config.base_url == "https://app.test.greatexpectations.io"
@@ -95,7 +95,7 @@ def test_data_context_in_cloud_mode_passes_base_url_to_store_backend(
     # The DatasourceStore should not have the default base_url or commonly used test base urls
     assert (
         not context._datasource_store.store_backend.config["ge_cloud_base_url"]
-        == GeCloudStoreBackend.DEFAULT_BASE_URL
+        == CLOUD_DEFAULT_BASE_URL
     )
     assert (
         not context._datasource_store.store_backend.config["ge_cloud_base_url"]
diff --git a/tests/data_context/test_data_context_variables.py b/tests/data_context/test_data_context_variables.py
--- a/tests/data_context/test_data_context_variables.py
+++ b/tests/data_context/test_data_context_variables.py
@@ -35,6 +35,9 @@
 from great_expectations.data_context.types.resource_identifiers import (
     ConfigurationIdentifier,
 )
+from tests.integration.usage_statistics.test_integration_usage_statistics import (
+    USAGE_STATISTICS_QA_URL,
+)
 
 yaml = YAMLHandler()
 
@@ -67,7 +70,7 @@ def data_context_config_dict() -> dict:
         "anonymous_usage_statistics": AnonymizedUsageStatisticsConfig(
             enabled=True,
             data_context_id="6a52bdfa-e182-455b-a825-e69f076e67d6",
-            usage_statistics_url="https://app.greatexpectations.io/",
+            usage_statistics_url=USAGE_STATISTICS_QA_URL,
         ),
         "notebooks": None,
         "concurrency": None,