gradient 2.99.3__tar.gz → 2.99.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {gradient-2.99.3 → gradient-2.99.4}/PKG-INFO +1 -1
- gradient-2.99.4/gradient/main.py +5 -0
- gradient-2.99.4/gradient/version.py +1 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient.egg-info/PKG-INFO +1 -1
- {gradient-2.99.3 → gradient-2.99.4}/gradient.egg-info/SOURCES.txt +1 -3
- gradient-2.99.3/gradient/main.py +0 -8
- gradient-2.99.3/gradient/version.py +0 -1
- gradient-2.99.3/gradient/version_checker.py +0 -135
- gradient-2.99.3/tests/unit/test_version_checker.py +0 -95
- {gradient-2.99.3 → gradient-2.99.4}/LICENSE.txt +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/README.md +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/__init__.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/__main__.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/__init__.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/archivers.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/clients/__init__.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/clients/base_client.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/clients/clusters.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/clients/dataset_client.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/clients/dataset_tag_client.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/clients/dataset_version_client.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/clients/http_client.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/clients/machine_types_client.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/clients/machines_client.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/clients/model_client.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/clients/notebook_client.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/clients/project_client.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/clients/sdk_client.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/clients/secret_client.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/clients/storage_provider_client.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/clients/workflow_client.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/config.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/constants.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/graphql.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/logger.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/models/__init__.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/models/artifact.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/models/cluster.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/models/dataset.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/models/dataset_tag.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/models/dataset_version.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/models/log.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/models/machine.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/models/model.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/models/notebook.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/models/pagination.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/models/project.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/models/secret.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/models/storage_provider.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/models/tag.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/models/vm_type.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/models/workflows.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/repositories/__init__.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/repositories/clusters.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/repositories/common.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/repositories/dataset_tags.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/repositories/dataset_versions.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/repositories/datasets.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/repositories/gradient_deployments.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/repositories/machine_types.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/repositories/machines.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/repositories/models.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/repositories/notebooks.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/repositories/projects.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/repositories/secrets.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/repositories/storage_providers.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/repositories/tags.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/repositories/workflows.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/s3_downloader.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/s3_uploader.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/sdk_exceptions.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/serializers/__init__.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/serializers/artifact.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/serializers/base.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/serializers/cluster.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/serializers/dataset.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/serializers/dataset_tag.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/serializers/dataset_version.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/serializers/log.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/serializers/machine.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/serializers/model.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/serializers/notebook.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/serializers/project.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/serializers/secret.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/serializers/storage_provider.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/serializers/tag.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/serializers/utils.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/serializers/vm_type.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/serializers/workflows.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/utils.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/api_sdk/validation_messages.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/cli/__init__.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/cli/auth.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/cli/cli.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/cli/cli_types.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/cli/clusters.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/cli/common.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/cli/datasets.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/cli/gradient_deployments.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/cli/machine_types.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/cli/machines.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/cli/models.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/cli/notebooks.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/cli/projects.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/cli/secrets.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/cli/storage_providers.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/cli/utils/__init__.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/cli/utils/flag_with_value.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/cli/validators.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/cli/workflows.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/cli_constants.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/clilogger.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/cliutils.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/commands/__init__.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/commands/clusters.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/commands/common.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/commands/datasets.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/commands/helpers.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/commands/login.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/commands/machine_types.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/commands/machines.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/commands/models.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/commands/notebooks.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/commands/projects.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/commands/secrets.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/commands/storage_providers.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/commands/workflows.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/config.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/exceptions.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient/login.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient.egg-info/dependency_links.txt +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient.egg-info/entry_points.txt +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient.egg-info/requires.txt +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/gradient.egg-info/top_level.txt +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/setup.cfg +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/setup.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/tests/functional/__init__.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/tests/functional/test_clusters.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/tests/functional/test_datasets.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/tests/functional/test_machines.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/tests/functional/test_models.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/tests/functional/test_notebooks.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/tests/functional/test_projects.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/tests/functional/test_secrets.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/tests/functional/test_storage_providers.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/tests/functional/test_tags.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/tests/unit/__init__.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/tests/unit/test_archiver_class.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/tests/unit/test_tags_support_mixin.py +0 -0
- {gradient-2.99.3 → gradient-2.99.4}/tests/unit/test_utils.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
version = "2.99.4"
|
|
@@ -12,7 +12,6 @@ gradient/exceptions.py
|
|
|
12
12
|
gradient/login.py
|
|
13
13
|
gradient/main.py
|
|
14
14
|
gradient/version.py
|
|
15
|
-
gradient/version_checker.py
|
|
16
15
|
gradient.egg-info/PKG-INFO
|
|
17
16
|
gradient.egg-info/SOURCES.txt
|
|
18
17
|
gradient.egg-info/dependency_links.txt
|
|
@@ -143,5 +142,4 @@ tests/functional/test_tags.py
|
|
|
143
142
|
tests/unit/__init__.py
|
|
144
143
|
tests/unit/test_archiver_class.py
|
|
145
144
|
tests/unit/test_tags_support_mixin.py
|
|
146
|
-
tests/unit/test_utils.py
|
|
147
|
-
tests/unit/test_version_checker.py
|
|
145
|
+
tests/unit/test_utils.py
|
gradient-2.99.3/gradient/main.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
version = "2.99.3"
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import sys
|
|
3
|
-
from platform import system
|
|
4
|
-
import json
|
|
5
|
-
|
|
6
|
-
import six
|
|
7
|
-
import requests
|
|
8
|
-
from packaging.version import Version
|
|
9
|
-
|
|
10
|
-
from gradient.clilogger import CliLogger
|
|
11
|
-
from gradient.version import version
|
|
12
|
-
|
|
13
|
-
logger = CliLogger()
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
class PackageNotFoundError(Exception):
|
|
17
|
-
pass
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
class VersionChecker(object):
|
|
21
|
-
def is_up_to_date(self, module_name, current_version):
|
|
22
|
-
version_in_repository = self.get_version_from_repository(module_name)
|
|
23
|
-
|
|
24
|
-
up_to_date = Version(current_version) >= Version(version_in_repository)
|
|
25
|
-
return up_to_date, version_in_repository
|
|
26
|
-
|
|
27
|
-
def get_version_from_repository(
|
|
28
|
-
self, module_name, repository_url="https://pypi.org/pypi"
|
|
29
|
-
):
|
|
30
|
-
# Use PyPI JSON API instead of XML-RPC
|
|
31
|
-
json_url = f"{repository_url}/{module_name}/json"
|
|
32
|
-
|
|
33
|
-
try:
|
|
34
|
-
response = requests.get(json_url, timeout=5)
|
|
35
|
-
response.raise_for_status()
|
|
36
|
-
data = response.json()
|
|
37
|
-
except (requests.RequestException, json.JSONDecodeError) as e:
|
|
38
|
-
raise PackageNotFoundError(
|
|
39
|
-
"Package {} not found or API error: {}".format(module_name, str(e))
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
# Get all release versions
|
|
43
|
-
releases = data.get("releases", {})
|
|
44
|
-
if not releases:
|
|
45
|
-
raise PackageNotFoundError(
|
|
46
|
-
"No releases found for package {}".format(module_name)
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
# Get all version numbers
|
|
50
|
-
versions = list(releases.keys())
|
|
51
|
-
if not versions:
|
|
52
|
-
raise PackageNotFoundError(
|
|
53
|
-
"No versions found for package {}".format(module_name)
|
|
54
|
-
)
|
|
55
|
-
|
|
56
|
-
# Filter to only include versions < 3.0 (v2 versions only)
|
|
57
|
-
v2_versions = []
|
|
58
|
-
for v in versions:
|
|
59
|
-
try:
|
|
60
|
-
if Version(v) < Version("3.0.0"):
|
|
61
|
-
v2_versions.append(v)
|
|
62
|
-
except Exception:
|
|
63
|
-
# Skip invalid version strings
|
|
64
|
-
continue
|
|
65
|
-
|
|
66
|
-
if not v2_versions:
|
|
67
|
-
# If no v2 versions found, raise exception to skip the check
|
|
68
|
-
raise PackageNotFoundError(
|
|
69
|
-
"No v2 versions found for package {}".format(module_name)
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
# Sort v2_versions to get the latest one (highest version number)
|
|
73
|
-
v2_versions.sort(key=lambda x: Version(x), reverse=True)
|
|
74
|
-
return v2_versions[0]
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
class GradientVersionChecker(object):
|
|
78
|
-
@classmethod
|
|
79
|
-
def look_for_new_version_with_timeout(cls):
|
|
80
|
-
if not cls._should_check_version():
|
|
81
|
-
return
|
|
82
|
-
|
|
83
|
-
if not system() == "Linux":
|
|
84
|
-
cls.look_for_new_version()
|
|
85
|
-
return
|
|
86
|
-
|
|
87
|
-
import signal
|
|
88
|
-
|
|
89
|
-
class TimeoutError(Exception):
|
|
90
|
-
pass
|
|
91
|
-
|
|
92
|
-
def handler(signum, frame):
|
|
93
|
-
raise TimeoutError
|
|
94
|
-
|
|
95
|
-
signal.signal(signal.SIGALRM, handler)
|
|
96
|
-
signal.alarm(1)
|
|
97
|
-
|
|
98
|
-
try:
|
|
99
|
-
cls.look_for_new_version()
|
|
100
|
-
except TimeoutError:
|
|
101
|
-
pass
|
|
102
|
-
|
|
103
|
-
signal.alarm(0)
|
|
104
|
-
|
|
105
|
-
@staticmethod
|
|
106
|
-
def look_for_new_version():
|
|
107
|
-
vc = VersionChecker()
|
|
108
|
-
try:
|
|
109
|
-
up_to_date, version_from_repository = vc.is_up_to_date("gradient", version)
|
|
110
|
-
except Exception as e:
|
|
111
|
-
logger.debug(e)
|
|
112
|
-
return
|
|
113
|
-
|
|
114
|
-
if not up_to_date:
|
|
115
|
-
msg = (
|
|
116
|
-
"Warning: this version of the Gradient CLI ({current_version}) is out of date. "
|
|
117
|
-
"Some functionality might not be supported until you upgrade. \n\n"
|
|
118
|
-
"The latest v2 version is {version_from_repository}.\n"
|
|
119
|
-
'Run `pip install -U "gradient<3.0"` to upgrade to the latest v2 version\n'
|
|
120
|
-
"Note: v3+ will be the DigitalOcean Gradient SDK. Pin to v2 to avoid breaking changes.\n".format(
|
|
121
|
-
current_version=version
|
|
122
|
-
)
|
|
123
|
-
)
|
|
124
|
-
logger.warning(msg)
|
|
125
|
-
|
|
126
|
-
@staticmethod
|
|
127
|
-
def _should_check_version():
|
|
128
|
-
if not hasattr(sys.stdin, "isatty"):
|
|
129
|
-
return False
|
|
130
|
-
if not sys.stdin.isatty() or not sys.stdout.isatty():
|
|
131
|
-
return False
|
|
132
|
-
if os.getenv("PAPERSPACE_CLI_DEV") == "true":
|
|
133
|
-
return False
|
|
134
|
-
|
|
135
|
-
return True
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import mock
|
|
2
|
-
import pytest
|
|
3
|
-
|
|
4
|
-
from gradient import version_checker
|
|
5
|
-
from gradient.version import version
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
@mock.patch("gradient.version_checker.GradientVersionChecker._should_check_version")
|
|
9
|
-
@mock.patch("gradient.version_checker.VersionChecker.is_up_to_date")
|
|
10
|
-
@mock.patch("gradient.version_checker.logger")
|
|
11
|
-
def test_should_check_for_new_gradient_version_and_print_proper_warning_when_current_version_is_old(
|
|
12
|
-
logger_patched, is_up_to_date_patched, should_check_patched):
|
|
13
|
-
should_check_patched.return_value = True
|
|
14
|
-
is_up_to_date_patched.return_value = (False, "1.2.3")
|
|
15
|
-
|
|
16
|
-
version_checker.GradientVersionChecker.look_for_new_version()
|
|
17
|
-
|
|
18
|
-
is_up_to_date_patched.assert_called_once()
|
|
19
|
-
logger_patched.warning.assert_called_once_with(
|
|
20
|
-
"Warning: this version of the Gradient CLI ({}) is out of date. "
|
|
21
|
-
"Some functionality might not be supported until you upgrade. \n\n"
|
|
22
|
-
"Run `pip install -U gradient` to upgrade\n".format(version))
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
@mock.patch("gradient.version_checker.GradientVersionChecker._should_check_version")
|
|
26
|
-
@mock.patch("gradient.version_checker.VersionChecker.is_up_to_date")
|
|
27
|
-
@mock.patch("gradient.version_checker.logger")
|
|
28
|
-
def test_should_check_for_new_gradient_version_and_not_print_anything_when_current_version_is_latest(
|
|
29
|
-
logger_patched, is_up_to_date_patched, should_check_patched):
|
|
30
|
-
should_check_patched.return_value = True
|
|
31
|
-
is_up_to_date_patched.return_value = (True, "1.2.3")
|
|
32
|
-
|
|
33
|
-
version_checker.GradientVersionChecker.look_for_new_version()
|
|
34
|
-
|
|
35
|
-
is_up_to_date_patched.assert_called_once()
|
|
36
|
-
logger_patched.warning.assert_not_called()
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
@mock.patch("gradient.version_checker.xmlrpclib.ServerProxy")
|
|
40
|
-
def test_should_return_package_version_when_get_version_was_run(sever_proxy_class_patched):
|
|
41
|
-
pypi_patched = mock.MagicMock()
|
|
42
|
-
pypi_patched.package_releases.return_value = ["1.2.3"]
|
|
43
|
-
sever_proxy_class_patched.return_value = pypi_patched
|
|
44
|
-
|
|
45
|
-
vc = version_checker.VersionChecker()
|
|
46
|
-
latest_version = vc.get_version_from_repository("some_module_name")
|
|
47
|
-
|
|
48
|
-
sever_proxy_class_patched.assert_called_with("http://pypi.python.org/pypi")
|
|
49
|
-
assert latest_version == "1.2.3"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
@mock.patch("gradient.version_checker.xmlrpclib.ServerProxy")
|
|
53
|
-
def test_should_raise_proper_exception_when_get_version_was_run_and_package_was_not_found(sever_proxy_class_patched):
|
|
54
|
-
pypi_patched = mock.MagicMock()
|
|
55
|
-
pypi_patched.package_releases.return_value = []
|
|
56
|
-
sever_proxy_class_patched.return_value = pypi_patched
|
|
57
|
-
|
|
58
|
-
vc = version_checker.VersionChecker()
|
|
59
|
-
with pytest.raises(version_checker.PackageNotFoundError):
|
|
60
|
-
vc.get_version_from_repository("some_module_name")
|
|
61
|
-
|
|
62
|
-
sever_proxy_class_patched.assert_called_with("http://pypi.python.org/pypi")
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
@mock.patch("gradient.version_checker.VersionChecker.get_version_from_repository")
|
|
66
|
-
def test_should_return_true_when_current_version_equals_latest_from_pypi(get_version_patched):
|
|
67
|
-
get_version_patched.return_value = "1.2.3"
|
|
68
|
-
|
|
69
|
-
vc = version_checker.VersionChecker()
|
|
70
|
-
up_to_date, version_in_repository = vc.is_up_to_date("some_module_name", "1.2.3")
|
|
71
|
-
|
|
72
|
-
assert up_to_date
|
|
73
|
-
assert version_in_repository == "1.2.3"
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
@mock.patch("gradient.version_checker.VersionChecker.get_version_from_repository")
|
|
77
|
-
def test_should_return_true_when_current_version_is_higher_than_latest_from_pypi(get_version_patched):
|
|
78
|
-
get_version_patched.return_value = "1.2.3"
|
|
79
|
-
|
|
80
|
-
vc = version_checker.VersionChecker()
|
|
81
|
-
up_to_date, version_in_repository = vc.is_up_to_date("some_module_name", "1.2.4a0")
|
|
82
|
-
|
|
83
|
-
assert up_to_date
|
|
84
|
-
assert version_in_repository == "1.2.3"
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
@mock.patch("gradient.version_checker.VersionChecker.get_version_from_repository")
|
|
88
|
-
def test_should_return_false_when_current_version_is_lower_than_latest_from_pypi(get_version_patched):
|
|
89
|
-
get_version_patched.return_value = "1.2.3"
|
|
90
|
-
|
|
91
|
-
vc = version_checker.VersionChecker()
|
|
92
|
-
up_to_date, version_in_repository = vc.is_up_to_date("some_module_name", "1.2.1")
|
|
93
|
-
|
|
94
|
-
assert not up_to_date
|
|
95
|
-
assert version_in_repository == "1.2.3"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|