-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HDX-10153 - add pyproject.toml file and tests
- Loading branch information
1 parent
0732adc
commit 330bd96
Showing
8 changed files
with
134 additions
and
18 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[pytest] | ||
log_cli = True | ||
log_cli_format = %(asctime)s %(levelname)s %(message)s | ||
log_cli_date_format = %Y-%m-%d %H:%M:%S | ||
log_cli_level = INFO |
Empty file.
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import pytest | ||
import os | ||
|
||
from config.config import Config, get_config | ||
|
||
DEFAULT_ENV = { | ||
# 'REDIS_STREAM_HOST': 'gisredis', | ||
'REDIS_STREAM_DB': '14' | ||
} | ||
|
||
|
||
@pytest.fixture(scope='module', autouse=True) | ||
def prepare_environment(): | ||
for key, value in DEFAULT_ENV.items(): | ||
os.environ[key] = value | ||
|
||
|
||
# | ||
# @pytest.fixture(scope='module') | ||
# def key_value_store() -> RedisKeyValueStore: | ||
# key_value_store = connect_to_key_value_store_with_env_vars() | ||
# return key_value_store | ||
|
||
|
||
@pytest.fixture(scope='module') | ||
def config() -> Config: | ||
config = get_config() | ||
return config | ||
|
||
# @pytest.fixture(scope='module') | ||
# def context(key_value_store: RedisKeyValueStore, config: Config) -> Context: | ||
# context = Context(store=key_value_store, config=config, gsheets=None, slack_client=SlackClientWrapper()) | ||
# return context | ||
|
||
# @pytest.fixture(scope='function') | ||
# def clean_redis(key_value_store: RedisKeyValueStore) -> None: | ||
# key_value_store.redis_conn.flushdb() |
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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import logging | ||
|
||
from processing.helpers import get_change_summary | ||
from processing.datasets import get_dataset_id_list | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def _generate_resource_created_test_event(): | ||
return { | ||
'event_type': 'resource-created', | ||
'event_time': '2024-10-02T11:22:15.973707', | ||
'event_source': 'ckan', | ||
'initiator_user_name': 'test-user', | ||
'dataset_name': 'test-dataset', | ||
'dataset_title': 'Test dataset', | ||
'dataset_id': 'test-dataset-id', | ||
'changed_fields': [ | ||
{ | ||
'field': 'microdata', | ||
'new_value': False, | ||
'new_display_value': 'does not contain microdata', | ||
'old_value': None, | ||
'old_display_value': 'does not contain microdata' | ||
}, | ||
{ | ||
'field': 'resource_type', | ||
'new_value': 'file.upload', | ||
'new_display_value': 'file.upload', | ||
'old_value': None, | ||
'old_display_value': None | ||
}, | ||
{ | ||
'field': 'name', | ||
'new_value': 'ING.Account.Statement_30-09-24_999911495277_USD.pdf', | ||
'new_display_value': 'ING.Account.Statement_30-09-24_999911495277_USD.pdf', | ||
'old_value': None, | ||
'old_display_value': None | ||
}, | ||
{ | ||
'field': 'format', | ||
'new_value': 'PDF', | ||
'new_display_value': 'PDF', | ||
'old_value': None, | ||
'old_display_value': None | ||
}, | ||
{ | ||
'field': 'url', | ||
'new_value': 'https://data.humdata.local/dataset/f679245a-5740-4ba6-a395-ec4e1ac20325/resource/b017f603-fb5e-4169-a7c5-88dbf202d368/download/ing.account.statement_30-09-24_999911495277_usd.pdf', | ||
'new_display_value': 'https://data.humdata.local/dataset/f679245a-5740-4ba6-a395-ec4e1ac20325/resource/b017f603-fb5e-4169-a7c5-88dbf202d368/download/ing.account.statement_30-09-24_999911495277_usd.pdf', | ||
'old_value': None, | ||
'old_display_value': None | ||
} | ||
], | ||
'org_id': 'test-org-id', | ||
'org_name': 'test-org', | ||
'org_title': 'Test Org', | ||
'resource_name': 'test.csv', | ||
'resource_id': 'b017f603-fb5e-4169-a7c5-88dbf202d368' | ||
} | ||
|
||
|
||
|
||
def test_get_change_summary(): | ||
resource_create_event = _generate_resource_created_test_event() | ||
summary = get_change_summary(event=resource_create_event) | ||
assert resource_create_event.get('resource_name') in summary | ||
assert 'was created' in summary | ||
|
||
|
||
def test_get_dataset_id_list(): | ||
dataset_id_list = get_dataset_id_list() | ||
assert len(dataset_id_list) > 0 |