-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PT-5013] Move webhooks out of base (#617)
* Move webhooks related code from base.py * Bump version
- Loading branch information
Showing
7 changed files
with
129 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "up42-py" | ||
version = "1.0.4a3" | ||
version = "1.0.4a5" | ||
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" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,68 @@ | ||
from unittest import mock | ||
|
||
import pytest | ||
|
||
import up42 | ||
from up42 import catalog, storage, tasking | ||
|
||
from .fixtures import fixtures_globals as constants | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def workspace(auth_mock): | ||
with mock.patch("up42.base.workspace") as workspace_mock: | ||
workspace_mock.auth = auth_mock | ||
workspace_mock.id = constants.WORKSPACE_ID | ||
yield | ||
|
||
|
||
@pytest.fixture(name="webhooks") | ||
def _webhooks(auth_mock): | ||
with mock.patch("up42.webhooks.Webhooks") as webhooks_class_mock: | ||
yield webhooks_class_mock.return_value | ||
webhooks_class_mock.assert_called_with(auth=auth_mock, workspace_id=constants.WORKSPACE_ID) | ||
|
||
|
||
def test_should_initialize_objects( | ||
auth_mock, | ||
order_mock, | ||
asset_mock, | ||
): | ||
with mock.patch("up42.base.workspace") as workspace_mock: | ||
workspace_mock.id = constants.WORKSPACE_ID | ||
workspace_mock.auth = auth_mock | ||
catalog_obj = up42.initialize_catalog() | ||
assert isinstance(catalog_obj, catalog.Catalog) | ||
|
||
storage_obj = up42.initialize_storage() | ||
assert isinstance(storage_obj, storage.Storage) | ||
assert storage_obj.workspace_id == constants.WORKSPACE_ID | ||
|
||
order_obj = up42.initialize_order(order_id=constants.ORDER_ID) | ||
assert order_obj.info == order_mock.info | ||
asset_obj = up42.initialize_asset(asset_id=constants.ASSET_ID) | ||
assert asset_obj.info == asset_mock.info | ||
result = up42.initialize_tasking() | ||
assert isinstance(result, tasking.Tasking) | ||
|
||
|
||
def test_should_get_webhook_events(webhooks: mock.MagicMock): | ||
events = mock.MagicMock() | ||
webhooks.get_webhook_events.return_value = events | ||
assert up42.get_webhook_events() == events | ||
|
||
|
||
catalog_obj = up42.initialize_catalog() | ||
assert isinstance(catalog_obj, catalog.Catalog) | ||
@pytest.mark.parametrize("return_json", [False, True]) | ||
def test_should_get_webhooks(webhooks: mock.MagicMock, return_json): | ||
hooks = mock.MagicMock() | ||
webhooks.get_webhooks.return_value = hooks | ||
assert up42.get_webhooks(return_json=return_json) == hooks | ||
webhooks.get_webhooks.assert_called_with(return_json=return_json) | ||
|
||
storage_obj = up42.initialize_storage() | ||
assert isinstance(storage_obj, storage.Storage) | ||
assert storage_obj.workspace_id == constants.WORKSPACE_ID | ||
|
||
order_obj = up42.initialize_order(order_id=constants.ORDER_ID) | ||
assert order_obj.info == order_mock.info | ||
asset_obj = up42.initialize_asset(asset_id=constants.ASSET_ID) | ||
assert asset_obj.info == asset_mock.info | ||
result = up42.initialize_tasking() | ||
assert isinstance(result, tasking.Tasking) | ||
def test_should_create_webhook(webhooks: mock.MagicMock): | ||
name = "name" | ||
url = "url" | ||
events = ["event"] | ||
active = True | ||
secret = "secret" | ||
webhook = mock.MagicMock() | ||
webhooks.create_webhook.return_value = webhook | ||
assert webhook == up42.create_webhook(name, url, events, active, secret) | ||
webhooks.create_webhook.assert_called_with(name=name, url=url, events=events, active=active, secret=secret) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters