Skip to content

Commit

Permalink
[AT-4406] Drop auth.env (#533)
Browse files Browse the repository at this point in the history
* Drop auth.env

* Apply hooks

* Version and CHANGELOG.md
  • Loading branch information
javidq authored Mar 14, 2024
1 parent 00af083 commit bdc8046
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 30 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ You can check your current version with the following command:

For more information, see [UP42 Python package description](https://pypi.org/project/up42-py/).

## 0.37.0a13

**March 15, 2024**

- Dropped unneeded `auth::env` property and the corresponding tests.


## 0.37.0a12

**March 14, 2024**
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "up42-py"
version = "0.37.0a12"
version = "0.37.0a13"
description = "Python SDK for UP42, the geospatial marketplace and developer platform."
authors = ["UP42 GmbH <[email protected]>"]
license = "https://github.com/up42/up42-py/blob/master/LICENSE"
Expand Down
10 changes: 1 addition & 9 deletions tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import requests_mock as req_mock

from up42 import auth as up42_auth
from up42 import host, utils
from up42 import utils

from .fixtures import fixtures_globals as constants

Expand All @@ -15,12 +15,9 @@ def test_auth_kwargs():
auth = up42_auth.Auth(
project_id=constants.PROJECT_ID,
project_api_key=constants.PROJECT_APIKEY,
env="abc",
authenticate=False,
retry=False,
)
assert auth.env == "abc"
assert host.DOMAIN == "abc"
assert not auth.authenticate


Expand All @@ -41,11 +38,6 @@ def test_should_not_authenticate_with_config_file_if_not_requested():
up42_auth.Auth(cfg_file=fp, authenticate=False)


def test_should_set_api_host_domain_with_environment(auth_mock: up42_auth.Auth):
auth_mock.env = "abc"
assert host.DOMAIN == "abc"


def test_get_workspace(auth_mock: up42_auth.Auth):
assert auth_mock.workspace_id == constants.WORKSPACE_ID

Expand Down
16 changes: 1 addition & 15 deletions up42/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,7 @@ def __init__(
}
credentials_dict = {key: value for key, value in credentials_dict.items() if value}

if "env" in kwargs:
self.env = kwargs["env"]

try:
self.authenticate: bool = kwargs["authenticate"]
except KeyError:
self.authenticate = True
self.authenticate: bool = kwargs.get("authenticate", True)

if project_id:
self.project_id = project_id
Expand Down Expand Up @@ -159,14 +153,6 @@ def _get_token_project_based(self):

self.token = token_response["data"]["accessToken"]

@property
def env(self):
return host.DOMAIN

@env.setter
def env(self, value: str):
host.DOMAIN = value

def _get_workspace(self) -> None:
"""Get user id belonging to authenticated account."""
url = host.endpoint("/users/me")
Expand Down
4 changes: 1 addition & 3 deletions up42/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ def __init__(self, auth: Auth, project_id: str):
self._info = self.info

def __repr__(self):
env = ", env: dev" if self.auth.env == "dev" else ""
return (
f"Project(name: {self._info['name']}, project_id: {self.project_id}, "
f"description: {self._info['description']}, createdAt: {self._info['createdAt']}"
f"{env})"
f"description: {self._info['description']}, createdAt: {self._info['createdAt']})"
)

@property
Expand Down
3 changes: 1 addition & 2 deletions up42/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ def __init__(self, auth: up42_auth.Auth):
self.workspace_id = auth.workspace_id

def __repr__(self):
env = ", env: dev" if self.auth.env == "dev" else ""
return f"Storage(workspace_id: {self.workspace_id}{env})"
return f"Storage(workspace_id: {self.workspace_id})"

@property
def pystac_client(self):
Expand Down

0 comments on commit bdc8046

Please sign in to comment.