hdx-python-api 6.2.4__tar.gz → 6.2.6__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.
Files changed (128) hide show
  1. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/CONTRIBUTING.md +1 -1
  2. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/PKG-INFO +3 -3
  3. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/documentation/main.md +6 -0
  4. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/pyproject.toml +1 -1
  5. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/requirements.txt +3 -3
  6. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/src/hdx/api/_version.py +2 -2
  7. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/src/hdx/api/configuration.py +24 -16
  8. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/hdx/api/test_configuration.py +17 -1
  9. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/hdx/facades/test_keyword_arguments.py +6 -6
  10. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/hdx/facades/test_simple.py +6 -6
  11. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/.config/coveragerc +0 -0
  12. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/.config/pre-commit-config.yaml +0 -0
  13. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/.config/pytest.ini +0 -0
  14. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/.config/ruff.toml +0 -0
  15. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/.github/workflows/publish.yaml +0 -0
  16. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/.github/workflows/run-python-tests.yaml +0 -0
  17. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/.gitignore +0 -0
  18. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/LICENSE +0 -0
  19. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/README.md +0 -0
  20. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/documentation/.readthedocs.yaml +0 -0
  21. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/documentation/pydoc-markdown.yaml +0 -0
  22. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/src/hdx/api/__init__.py +0 -0
  23. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/src/hdx/api/hdx_base_configuration.yaml +0 -0
  24. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/src/hdx/api/locations.py +0 -0
  25. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/src/hdx/api/remotehdx.py +0 -0
  26. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/src/hdx/data/__init__.py +0 -0
  27. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/src/hdx/data/dataset.py +0 -0
  28. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/src/hdx/data/dataset_title_helper.py +0 -0
  29. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/src/hdx/data/date_helper.py +0 -0
  30. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/src/hdx/data/filestore_helper.py +0 -0
  31. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/src/hdx/data/hdx_datasource_topline.yaml +0 -0
  32. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/src/hdx/data/hdxobject.py +0 -0
  33. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/src/hdx/data/indicator_resource_view_template.yaml +0 -0
  34. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/src/hdx/data/organization.py +0 -0
  35. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/src/hdx/data/resource.py +0 -0
  36. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/src/hdx/data/resource_matcher.py +0 -0
  37. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/src/hdx/data/resource_view.py +0 -0
  38. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/src/hdx/data/showcase.py +0 -0
  39. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/src/hdx/data/user.py +0 -0
  40. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/src/hdx/data/vocabulary.py +0 -0
  41. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/src/hdx/facades/__init__.py +0 -0
  42. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/src/hdx/facades/infer_arguments.py +0 -0
  43. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/src/hdx/facades/keyword_arguments.py +0 -0
  44. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/src/hdx/facades/simple.py +0 -0
  45. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/Accepted_Tags.csv +0 -0
  46. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/CKAN/hdx_dataset_static.yaml +0 -0
  47. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/Tag_Mapping.csv +0 -0
  48. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/Tag_Mapping_ChainRuleError.csv +0 -0
  49. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/config/empty.yaml +0 -0
  50. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/config/hdx_base_config.json +0 -0
  51. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/config/hdx_base_config.yaml +0 -0
  52. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/config/hdx_config.json +0 -0
  53. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/config/hdx_config.yaml +0 -0
  54. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/config/hdx_dataset_static.json +0 -0
  55. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/config/hdx_dataset_static.yaml +0 -0
  56. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/config/hdx_datasource_topline.json +0 -0
  57. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/config/hdx_datasource_topline.yaml +0 -0
  58. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/config/hdx_email_configuration.json +0 -0
  59. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/config/hdx_email_configuration.yaml +0 -0
  60. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/config/hdx_missing_site_config.json +0 -0
  61. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/config/hdx_organization_static.json +0 -0
  62. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/config/hdx_organization_static.yaml +0 -0
  63. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/config/hdx_resource_static.json +0 -0
  64. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/config/hdx_resource_static.yaml +0 -0
  65. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/config/hdx_resource_view_static.json +0 -0
  66. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/config/hdx_resource_view_static.yaml +0 -0
  67. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/config/hdx_showcase_static.json +0 -0
  68. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/config/hdx_showcase_static.yaml +0 -0
  69. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/config/hdx_user_static.json +0 -0
  70. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/config/hdx_user_static.yaml +0 -0
  71. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/config/hdx_vocabulary_static.json +0 -0
  72. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/config/hdx_vocabulary_static.yaml +0 -0
  73. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/config/project_configuration.json +0 -0
  74. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/config/project_configuration.yaml +0 -0
  75. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/config/user_agent_config.yaml +0 -0
  76. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/config/user_agent_config2.yaml +0 -0
  77. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/config/user_agent_config3.yaml +0 -0
  78. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/config/user_agent_config_wrong.yaml +0 -0
  79. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/dataset_search_results.yaml +0 -0
  80. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/datastore/ACLED-All-Africa-File_20170101-to-20170708.xlsx +0 -0
  81. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/empty.csv +0 -0
  82. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/gen_resource/conflict_data_alg.csv +0 -0
  83. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/gen_resource/min_qc_conflict_data_alg.csv +0 -0
  84. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/gen_resource/qc_conflict_data_alg.csv +0 -0
  85. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/gen_resource/test_data_no_data.csv +0 -0
  86. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/gen_resource/test_data_no_years.csv +0 -0
  87. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/organization_show_results.yaml +0 -0
  88. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/qc_from_rows/qc_conflict_data_alg.csv +0 -0
  89. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/qc_from_rows/qc_conflict_data_alg_one_col.csv +0 -0
  90. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/resource_formats.json +0 -0
  91. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/showcase_all_search_results.yaml +0 -0
  92. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/test_data.csv +0 -0
  93. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/test_data.zip +0 -0
  94. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/update_dataset_resources/dem_data_zwe.csv +0 -0
  95. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/update_dataset_resources/dem_indicatorlist_zwe.csv +0 -0
  96. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/update_dataset_resources/expected_resources_to_update.json +0 -0
  97. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/update_dataset_resources/opri_data_zwe.csv +0 -0
  98. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/update_dataset_resources/opri_indicatorlist_zwe.csv +0 -0
  99. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/update_dataset_resources/opri_metadata_zwe.csv +0 -0
  100. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/update_dataset_resources/qc_sdg_data_zwe.csv +0 -0
  101. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/update_dataset_resources/sdg_data_zwe.csv +0 -0
  102. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/update_dataset_resources/sdg_indicatorlist_zwe.csv +0 -0
  103. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/update_dataset_resources/sdg_metadata_zwe.csv +0 -0
  104. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/update_dataset_resources/unesco_dataset.json +0 -0
  105. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/update_dataset_resources/unesco_update_dataset.json +0 -0
  106. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/update_logic/update_logic_resources.yaml +0 -0
  107. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/fixtures/update_logic/update_logic_resources_new.yaml +0 -0
  108. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/hdx/api/test_ckan.py +0 -0
  109. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/hdx/api/test_locations.py +0 -0
  110. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/hdx/conftest.py +0 -0
  111. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/hdx/data/__init__.py +0 -0
  112. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/hdx/data/test_dataset_core.py +0 -0
  113. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/hdx/data/test_dataset_noncore.py +0 -0
  114. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/hdx/data/test_dataset_title_helper.py +0 -0
  115. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/hdx/data/test_organization.py +0 -0
  116. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/hdx/data/test_resource.py +0 -0
  117. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/hdx/data/test_resource_view.py +0 -0
  118. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/hdx/data/test_showcase.py +0 -0
  119. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/hdx/data/test_update_dataset_resources.py +0 -0
  120. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/hdx/data/test_update_logic.py +0 -0
  121. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/hdx/data/test_user.py +0 -0
  122. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/hdx/data/test_vocabulary.py +0 -0
  123. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/hdx/facades/__init__.py +0 -0
  124. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/tests/hdx/facades/test_infer_arguments.py +0 -0
  125. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/workingexample/my_code.py +0 -0
  126. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/workingexample/my_resource.csv +0 -0
  127. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/workingexample/my_resource.xlsx +0 -0
  128. {hdx_python_api-6.2.4 → hdx_python_api-6.2.6}/workingexample/run.py +0 -0
@@ -28,7 +28,7 @@ the line that begins with `ARGS` to:
28
28
  ARGS=(hook-impl --config=.config/pre-commit-config.yaml --hook-type=pre-commit)
29
29
 
30
30
  With pre-commit, all code is formatted according to
31
- [ruff]("https://github.com/charliermarsh/ruff") guidelines.
31
+ [ruff](https://github.com/astral-sh/ruff) guidelines.
32
32
 
33
33
  To check if your changes pass pre-commit without committing, run:
34
34
 
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: hdx-python-api
3
- Version: 6.2.4
3
+ Version: 6.2.6
4
4
  Summary: HDX Python API for interacting with the Humanitarian Data Exchange
5
5
  Project-URL: Homepage, https://github.com/OCHA-DAP/hdx-python-api
6
6
  Author-email: Michael Rans <rans@email.com>
@@ -29,7 +29,7 @@ Requires-Dist: ckanapi>=4.7
29
29
  Requires-Dist: defopt>=6.4.0
30
30
  Requires-Dist: email-validator
31
31
  Requires-Dist: hdx-python-country>=3.6.9
32
- Requires-Dist: hdx-python-utilities>=3.6.6
32
+ Requires-Dist: hdx-python-utilities>=3.6.7
33
33
  Requires-Dist: libhxl>=5.2.1
34
34
  Requires-Dist: makefun
35
35
  Requires-Dist: ndg-httpsclient
@@ -52,6 +52,12 @@ The library has detailed API documentation which can be found in the menu at the
52
52
 
53
53
 
54
54
  ## Breaking Changes
55
+ From 6.2.6, kwargs take preference over environment variables which take
56
+ preference over configuration files
57
+
58
+ From 6.2.5, environment variables take preference over kwargs which take
59
+ preference over configuration files
60
+
55
61
  From 6.1.5, any method or parameter with "reference_period" in it is renamed
56
62
  to "time_period" and any method or parameter with "file_type" in it is renamed
57
63
  to "format"
@@ -38,7 +38,7 @@ dependencies = [
38
38
  "defopt>=6.4.0",
39
39
  "email_validator",
40
40
  "hdx-python-country>=3.6.9",
41
- "hdx-python-utilities>=3.6.6",
41
+ "hdx-python-utilities>=3.6.7",
42
42
  "libhxl>=5.2.1",
43
43
  "makefun",
44
44
  "ndg-httpsclient",
@@ -29,7 +29,7 @@ click==8.1.7
29
29
  # via typer
30
30
  colorama==0.4.6
31
31
  # via typer
32
- coverage[toml]==7.4.3
32
+ coverage[toml]==7.4.4
33
33
  # via pytest-cov
34
34
  cryptography==42.0.5
35
35
  # via pyopenssl
@@ -63,7 +63,7 @@ gspread==6.0.2
63
63
  # via hdx-python-api (pyproject.toml)
64
64
  hdx-python-country==3.6.9
65
65
  # via hdx-python-api (pyproject.toml)
66
- hdx-python-utilities==3.6.6
66
+ hdx-python-utilities==3.6.7
67
67
  # via
68
68
  # hdx-python-api (pyproject.toml)
69
69
  # hdx-python-country
@@ -251,7 +251,7 @@ urllib3==2.2.1
251
251
  # via
252
252
  # libhxl
253
253
  # requests
254
- validators==0.22.0
254
+ validators==0.23.1
255
255
  # via frictionless
256
256
  virtualenv==20.25.1
257
257
  # via pre-commit
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '6.2.4'
16
- __version_tuple__ = version_tuple = (6, 2, 4)
15
+ __version__ = version = '6.2.6'
16
+ __version_tuple__ = version_tuple = (6, 2, 6)
@@ -34,7 +34,7 @@ class Configuration(UserDict):
34
34
  user_agent_config_yaml (str): Path to YAML user agent configuration. Ignored if user_agent supplied. Defaults to ~/.useragent.yaml.
35
35
  user_agent_lookup (str): Lookup key for YAML. Ignored if user_agent supplied.
36
36
  hdx_url (str): HDX url to use. Overrides hdx_site.
37
- hdx_site (str): HDX site to use eg. prod, test.
37
+ hdx_site (str): HDX site to use eg. prod, test. Defaults to stage.
38
38
  hdx_read_only (bool): Whether to access HDX in read only mode. Defaults to False.
39
39
  hdx_key (str): Your HDX key. Ignored if hdx_read_only = True.
40
40
  hdx_config_dict (dict): HDX configuration dictionary to use instead of above 3 parameters OR
@@ -198,18 +198,22 @@ class Configuration(UserDict):
198
198
  prefix=Configuration.prefix, **self.data
199
199
  )
200
200
 
201
- hdx_url = os.getenv(
202
- "HDX_URL", kwargs.get("hdx_url", self.data.get("hdx_url"))
203
- )
201
+ hdx_url = kwargs.get("hdx_url")
202
+ if not hdx_url:
203
+ hdx_url = os.getenv("HDX_URL")
204
+ if not hdx_url:
205
+ hdx_url = self.data.get("hdx_url")
204
206
  if hdx_url:
205
207
  hdx_site = "custom"
206
208
  self.hdx_site = "hdx_custom_site"
207
209
  hdx_url = hdx_url.rstrip("/")
208
210
  self.data[self.hdx_site] = {"url": hdx_url}
209
211
  else:
210
- hdx_site = os.getenv(
211
- "HDX_SITE", kwargs.get("hdx_site", self.data.get("hdx_site"))
212
- )
212
+ hdx_site = kwargs.get("hdx_site")
213
+ if not hdx_site:
214
+ hdx_site = os.getenv("HDX_SITE")
215
+ if not hdx_site:
216
+ hdx_site = self.data.get("hdx_site")
213
217
  if not hdx_site:
214
218
  hdx_site = "stage"
215
219
  self.hdx_site = f"hdx_{hdx_site}_site"
@@ -228,14 +232,18 @@ class Configuration(UserDict):
228
232
  if self.hdx_site == "hdx_custom_site":
229
233
  hdx_key = None
230
234
  else:
231
- hdx_key = os.getenv(f"HDX_KEY_{hdx_site.upper()}")
235
+ hdx_key_site = f"hdx_key_{hdx_site}"
236
+ hdx_key = kwargs.get(hdx_key_site)
232
237
  if not hdx_key:
233
- hdx_key_site = f"hdx_key_{hdx_site}"
234
- hdx_key = kwargs.get(hdx_key_site, self.data.get(hdx_key_site))
238
+ hdx_key = os.getenv(f"HDX_KEY_{hdx_site.upper()}")
239
+ if not hdx_key:
240
+ hdx_key = self.data.get(hdx_key_site)
235
241
  if not hdx_key:
236
- hdx_key = os.getenv(
237
- "HDX_KEY", kwargs.get("hdx_key", self.data.get("hdx_key"))
238
- )
242
+ hdx_key = kwargs.get("hdx_key")
243
+ if not hdx_key:
244
+ hdx_key = os.getenv("HDX_KEY")
245
+ if not hdx_key:
246
+ hdx_key = self.data.get("hdx_key")
239
247
  if hdx_key:
240
248
  self.hdx_key = hdx_key
241
249
  return
@@ -525,7 +533,7 @@ class Configuration(UserDict):
525
533
  user_agent_config_yaml (str): Path to YAML user agent configuration. Ignored if user_agent supplied. Defaults to ~/.useragent.yaml.
526
534
  user_agent_lookup (str): Lookup key for YAML. Ignored if user_agent supplied.
527
535
  hdx_url (str): HDX url to use. Overrides hdx_site.
528
- hdx_site (str): HDX site to use eg. prod, test.
536
+ hdx_site (str): HDX site to use eg. prod, test. Defaults to stage.
529
537
  hdx_read_only (bool): Whether to access HDX in read only mode. Defaults to False.
530
538
  hdx_key (str): Your HDX key. Ignored if hdx_read_only = True.
531
539
  hdx_config_dict (dict): HDX configuration dictionary to use instead of above 3 parameters OR
@@ -565,7 +573,7 @@ class Configuration(UserDict):
565
573
  user_agent_config_yaml (str): Path to YAML user agent configuration. Ignored if user_agent supplied. Defaults to ~/.useragent.yaml.
566
574
  user_agent_lookup (str): Lookup key for YAML. Ignored if user_agent supplied.
567
575
  hdx_url (str): HDX url to use. Overrides hdx_site.
568
- hdx_site (str): HDX site to use eg. prod, test.
576
+ hdx_site (str): HDX site to use eg. prod, test. Defaults to stage.
569
577
  hdx_read_only (bool): Whether to access HDX in read only mode. Defaults to False.
570
578
  hdx_key (str): Your HDX key. Ignored if hdx_read_only = True.
571
579
  hdx_config_dict (dict): HDX configuration dictionary to use instead of above 3 parameters OR
@@ -604,7 +612,7 @@ class Configuration(UserDict):
604
612
  user_agent_config_yaml (str): Path to YAML user agent configuration. Ignored if user_agent supplied. Defaults to ~/.useragent.yaml.
605
613
  user_agent_lookup (str): Lookup key for YAML. Ignored if user_agent supplied.
606
614
  hdx_url (str): HDX url to use. Overrides hdx_site.
607
- hdx_site (str): HDX site to use eg. prod, test.
615
+ hdx_site (str): HDX site to use eg. prod, test. Defaults to stage.
608
616
  hdx_read_only (bool): Whether to access HDX in read only mode. Defaults to False.
609
617
  hdx_key (str): Your HDX key. Ignored if hdx_read_only = True.
610
618
  hdx_config_dict (dict): HDX configuration dictionary to use instead of above 3 parameters OR
@@ -62,10 +62,26 @@ class TestConfiguration:
62
62
  Configuration.default_hdx_config_yaml = "NOT EXIST"
63
63
  with pytest.raises(UserAgentError):
64
64
  Configuration()
65
+ with pytest.raises(ConfigurationError):
66
+ Configuration(user_agent="test")
67
+ configuration = Configuration(user_agent="test", hdx_key="test")
68
+ assert configuration.hdx_read_only is False
69
+ assert (
70
+ configuration.get_hdx_site_url()
71
+ == "https://stage.data-humdata-org.ahconu.org"
72
+ )
73
+ assert (
74
+ configuration.get_user_agent()
75
+ == f"HDXPythonLibrary/{__version__}-test"
76
+ )
77
+ configuration = Configuration(full_agent="test", hdx_key="test")
78
+ assert configuration.get_user_agent() == "test"
65
79
  Configuration.default_hdx_config_yaml = default_config_file
66
80
 
67
81
  Configuration.default_hdx_config_yaml = hdx_config_yaml
68
- assert Configuration(user_agent="test").get_api_key() == "12345"
82
+ configuration = Configuration(user_agent="test")
83
+ assert configuration.get_api_key() == "12345"
84
+
69
85
  Configuration.default_hdx_config_yaml = default_config_file
70
86
 
71
87
  with pytest.raises(IOError):
@@ -90,10 +90,10 @@ class TestKeywordArguments:
90
90
  assert testresult.actual_result == my_test_key
91
91
  UserAgent.clear_global()
92
92
  testresult.actual_result = None
93
- monkeypatch.setenv("HDX_KEY", my_test_key)
93
+ monkeypatch.setenv("HDX_KEY", "aaaa")
94
94
  facade(
95
95
  my_testfnkw,
96
- hdx_key="aaaa",
96
+ hdx_key=my_test_key,
97
97
  user_agent=my_user_agent,
98
98
  hdx_config_yaml=hdx_config_yaml,
99
99
  project_config_yaml=project_config_yaml,
@@ -117,10 +117,10 @@ class TestKeywordArguments:
117
117
  )
118
118
  UserAgent.clear_global()
119
119
  testresult.actual_result = None
120
- monkeypatch.setenv("HDX_SITE", my_test_hdxsite)
120
+ monkeypatch.setenv("HDX_SITE", "feature")
121
121
  facade(
122
122
  my_testfnkw,
123
- hdx_site="feature",
123
+ hdx_site=my_test_hdxsite,
124
124
  user_agent=my_user_agent,
125
125
  hdx_config_yaml=hdx_config_yaml,
126
126
  project_config_yaml=project_config_yaml,
@@ -143,11 +143,11 @@ class TestKeywordArguments:
143
143
  )
144
144
  assert testresult.actual_result == my_test_hdxurl
145
145
  UserAgent.clear_global()
146
- my_test_hdxurl2 = "http://other-data.humdata.org/"
146
+ my_test_hdxurl2 = "http://other2-data.humdata.org/"
147
147
  monkeypatch.setenv("HDX_URL", my_test_hdxurl2)
148
148
  facade(
149
149
  my_testfnkw,
150
- hdx_site="feature",
150
+ hdx_url=my_test_hdxurl,
151
151
  user_agent=my_user_agent,
152
152
  hdx_config_yaml=hdx_config_yaml,
153
153
  project_config_yaml=project_config_yaml,
@@ -84,10 +84,10 @@ class TestSimple:
84
84
  assert testresult.actual_result == my_test_key
85
85
  UserAgent.clear_global()
86
86
  testresult.actual_result = None
87
- monkeypatch.setenv("HDX_KEY", my_test_key)
87
+ monkeypatch.setenv("HDX_KEY", "aaaa")
88
88
  facade(
89
89
  my_testkeyfn,
90
- hdx_key="aaaa",
90
+ hdx_key=my_test_key,
91
91
  user_agent=my_user_agent,
92
92
  hdx_config_yaml=hdx_config_yaml,
93
93
  project_config_yaml=project_config_yaml,
@@ -109,10 +109,10 @@ class TestSimple:
109
109
  )
110
110
  UserAgent.clear_global()
111
111
  testresult.actual_result = None
112
- monkeypatch.setenv("HDX_SITE", my_test_hdxsite)
112
+ monkeypatch.setenv("HDX_SITE", "feature")
113
113
  facade(
114
114
  my_testfn,
115
- hdx_site="feature",
115
+ hdx_site=my_test_hdxsite,
116
116
  user_agent=my_user_agent,
117
117
  hdx_config_yaml=hdx_config_yaml,
118
118
  project_config_yaml=project_config_yaml,
@@ -133,11 +133,11 @@ class TestSimple:
133
133
  )
134
134
  assert testresult.actual_result == my_test_hdxurl
135
135
  UserAgent.clear_global()
136
- my_test_hdxurl2 = "http://other-data.humdata.org/"
136
+ my_test_hdxurl2 = "http://other2-data.humdata.org/"
137
137
  monkeypatch.setenv("HDX_URL", my_test_hdxurl2)
138
138
  facade(
139
139
  my_testfn,
140
- hdx_site="feature",
140
+ hdx_url=my_test_hdxurl,
141
141
  user_agent=my_user_agent,
142
142
  hdx_config_yaml=hdx_config_yaml,
143
143
  project_config_yaml=project_config_yaml,
File without changes
File without changes