# -*- coding: UTF-8 -*- """Simple Facade Tests""" from os.path import join from hdx.utilities.useragent import UserAgentError, UserAgent from hdx.facades import logging_kwargs from hdx.version import get_api_version logging_kwargs.update({ 'smtp_config_yaml': join('tests', 'fixtures', 'config', 'smtp_config.yml'), }) import pytest from . import my_testfn, my_excfn, testresult, my_testuafn, my_testkeyfn from hdx.facades.simple import facade class TestSimple: def test_facade(self, monkeypatch, hdx_config_yaml, project_config_yaml): UserAgent.clear_global() my_user_agent = 'test' testresult.actual_result = None facade(my_testfn, user_agent=my_user_agent, hdx_config_yaml=hdx_config_yaml, project_config_yaml=project_config_yaml) assert testresult.actual_result == 'https://data.humdata.org/' UserAgent.clear_global() version = get_api_version() testresult.actual_result = None facade(my_testuafn, user_agent=my_user_agent, hdx_config_yaml=hdx_config_yaml, project_config_yaml=project_config_yaml) assert testresult.actual_result == 'HDXPythonLibrary/%s-%s' % (version, my_user_agent)
# -*- coding: UTF-8 -*- """Simple Facade Tests""" from os.path import join from hdx.utilities.useragent import UserAgentError, UserAgent from hdx.facades import logging_kwargs from hdx.version import get_api_version logging_kwargs.update({ 'smtp_config_yaml': join('tests', 'fixtures', 'config', 'smtp_config.yml'), }) import pytest from . import testresult, my_testfn, my_excfn, my_testuafn, my_testkeyfn from hdx.facades.simple import facade class TestSimple: def test_facade(self, monkeypatch, hdx_config_yaml, project_config_yaml): UserAgent.clear_global() my_user_agent = 'test' testresult.actual_result = None facade(my_testfn, user_agent=my_user_agent, hdx_config_yaml=hdx_config_yaml, project_config_yaml=project_config_yaml) assert testresult.actual_result == 'https://data.humdata.org' UserAgent.clear_global()
import logging from os.path import join, expanduser from hdx.data.hdxobject import HDXError from hdx.data.dataset import Dataset from hdx.facades import logging_kwargs logging_kwargs.update( {'logging_config_yaml': join('config', 'logging_configuration.yml')}) from hdx.facades.hdx_scraperwiki import facade logger = logging.getLogger(__name__) real_run = False # set to True to make changes def main(): """Generate dataset and create it in HDX""" for dataset in Dataset.get_all_datasets( check_duplicates=False ): # [Dataset.read_from_hdx('malawi-other')]: changed, error = dataset.clean_dataset_tags() if changed and not error: if real_run: try: logger.info('%s: Updating dataset in HDX' % dataset['name']) dataset['batch_mode'] = 'KEEP_OLD' dataset['skip_validation'] = True dataset.update_in_hdx(update_resources=False,