diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8d672a5..16cbac2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,6 +58,8 @@ jobs: - name: Build docs with Material for MkDocs run: poetry run mkdocs build - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v3 - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + uses: codecov/codecov-action@v4 + with: + fail_ci_if_error: true + token: ${{ secrets.CODECOV_TOKEN }} + verbose: true diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 40ae1b9..740f225 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -58,6 +58,8 @@ jobs: - name: Build docs with Material for MkDocs run: poetry run mkdocs build - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v3 - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + uses: codecov/codecov-action@v4 + with: + fail_ci_if_error: true + token: ${{ secrets.CODECOV_TOKEN }} + verbose: true diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 26ef2e8..07bc14c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -31,7 +31,7 @@ repos: # ruff - linting and format - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.1.14" + rev: "v0.2.1" hooks: - id: ruff args: [--fix] diff --git a/README.md b/README.md index 3297d84..f217731 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,13 @@ # PyBMKG -![CI](https://github.com/kiraware/PyBMKG/actions/workflows/ci.yml/badge.svg) +[![CI](https://github.com/kiraware/PyBMKG/workflows/ci/badge.svg)](https://github.com/kiraware/PyBMKG/actions/workflows/ci.yml) +[![CodeQL](https://github.com/kiraware/PyBMKG/workflows/codeql/badge.svg)](https://github.com/kiraware/PyBMKG/actions/workflows/codeql.yml) [![Docs](https://readthedocs.org/projects/pybmkg/badge/?version=latest)](https://pybmkg.readthedocs.io/en/latest/?badge=latest) [![codecov](https://codecov.io/gh/kiraware/PyBMKG/graph/badge.svg?token=MN6AXAHO0P)](https://codecov.io/gh/kiraware/PyBMKG) [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit) [![security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://github.com/PyCQA/bandit) [![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/) -[![Ruff](https://camo.githubusercontent.com/7f995d42c2de5a9eb8ced2df552a0813050d324427a3facabfcfa5f88cb11c59/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d68747470733a2f2f7261772e67697468756275736572636f6e74656e742e636f6d2f636861726c6965726d617273682f727566662f6d61696e2f6173736574732f62616467652f76312e6a736f6e)](https://github.com/astral-sh/ruff) +[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![pypi](https://img.shields.io/pypi/v/PyBMKG.svg)](https://pypi.org/project/PyBMKG/) [![python](https://img.shields.io/pypi/pyversions/PyBMKG.svg)](https://pypi.org/project/PyBMKG/) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/license/mit/) diff --git a/docs/index.md b/docs/index.md index 48216bb..89c2a2b 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,12 +1,13 @@ # PyBMKG -![CI](https://github.com/kiraware/PyBMKG/actions/workflows/ci.yml/badge.svg) +[![CI](https://github.com/kiraware/PyBMKG/workflows/ci/badge.svg)](https://github.com/kiraware/PyBMKG/actions/workflows/ci.yml) +[![CodeQL](https://github.com/kiraware/PyBMKG/workflows/codeql/badge.svg)](https://github.com/kiraware/PyBMKG/actions/workflows/codeql.yml) [![Docs](https://readthedocs.org/projects/pybmkg/badge/?version=latest)](https://pybmkg.readthedocs.io/en/latest/?badge=latest) [![codecov](https://codecov.io/gh/kiraware/PyBMKG/graph/badge.svg?token=MN6AXAHO0P)](https://codecov.io/gh/kiraware/PyBMKG) [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit) [![security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://github.com/PyCQA/bandit) [![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/) -[![Ruff](https://camo.githubusercontent.com/7f995d42c2de5a9eb8ced2df552a0813050d324427a3facabfcfa5f88cb11c59/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d68747470733a2f2f7261772e67697468756275736572636f6e74656e742e636f6d2f636861726c6965726d617273682f727566662f6d61696e2f6173736574732f62616467652f76312e6a736f6e)](https://github.com/astral-sh/ruff) +[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![pypi](https://img.shields.io/pypi/v/PyBMKG.svg)](https://pypi.org/project/PyBMKG/) [![python](https://img.shields.io/pypi/pyversions/PyBMKG.svg)](https://pypi.org/project/PyBMKG/) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/license/mit/) diff --git a/docs/reference/api.md b/docs/reference/api.md index 43c72af..9b8e4f4 100644 --- a/docs/reference/api.md +++ b/docs/reference/api.md @@ -1,4 +1 @@ -::: bmkg.BMKG -::: bmkg.api.earthquake.Earthquake -::: bmkg.api.weather_forecast.WeatherForecast -::: bmkg.api.shakemap.Shakemap +::: bmkg.api diff --git a/docs/reference/exception.md b/docs/reference/exception.md index b8ed9b8..df1c385 100644 --- a/docs/reference/exception.md +++ b/docs/reference/exception.md @@ -1 +1 @@ -::: bmkg.exception +::: bmkg.exceptions diff --git a/docs/tutorials.md b/docs/tutorials.md index c2a345c..933f209 100644 --- a/docs/tutorials.md +++ b/docs/tutorials.md @@ -14,16 +14,16 @@ All done! ## Earthquake API -There are four APIs available for earthquakes -namely get_latest_earthquake, get_latest_earthquake_shakemap, -get_strong_earthquake, and get_felt_earthquake. +There are three APIs available for earthquakes +namely get_latest_earthquake, get_strong_earthquake, +and get_felt_earthquake. ### get_latest_earthquake get_latest_earthquake is used to get latest earthquake information at `https://data.bmkg.go.id/DataMKG/TEWS/autogempa.json`. Read get_latest_earthquake -[reference](reference/api.md/#bmkg.earthquake.Earthquake.get_latest_earthquake) +[reference](reference/api.md/#bmkg.api.Earthquake.get_latest_earthquake) for more details. Code example: @@ -70,48 +70,13 @@ Tidak berpotensi tsunami Shakemap(file_name='20240118013237.mmi.jpg') ``` -### get_latest_earthquake_shakemap - -get_latest_earthquake_shakemap is used to get latest -earthquake shake map. The link starts with `https://data.bmkg.go.id/DataMKG/TEWS/` -and followed with shakemap filename. Read get_latest_earthquake_shakemap -[reference](reference/api.md/#bmkg.earthquake.Earthquake.get_latest_earthquake_shakemap) -for more details. - -Code example: - -```python -import asyncio - -from bmkg import BMKG - - -async def main(): - async with BMKG() as bmkg: - latest_earthquake = await bmkg.earthquake.get_latest_earthquake() - shakemap = latest_earthquake.shakemap - shakemap_content = await shakemap.get_content() - - print(shakemap.file_name) - print(shakemap_content) - -asyncio.run(main()) -``` - -Example output: - -```console -20240203152510.mmi.jpg -b'\xff\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x01\x00...' -``` - ### get_strong_earthquake get_strong_earthquake is used to get fifteen strong earthquake information with a magnitude of 5.0 M and above at `https://data.bmkg.go.id/DataMKG/TEWS/gempaterkini.json`. Read get_strong_earthquake -[reference](reference/api.md/#bmkg.earthquake.Earthquake.get_strong_earthquake) +[reference](reference/api.md/#bmkg.api.Earthquake.get_strong_earthquake) for more details. Code example: @@ -161,7 +126,7 @@ Tidak berpotensi tsunami get_felt_earthquake is used to get fifteen felt earthquake information at `https://data.bmkg.go.id/DataMKG/TEWS/gempadirasakan.json`. Read get_felt_earthquake -[reference](reference/api.md/#bmkg.earthquake.Earthquake.get_felt_earthquake) +[reference](reference/api.md/#bmkg.api.Earthquake.get_felt_earthquake) for more details. Code example: @@ -206,6 +171,46 @@ III Banda Aceh, II-III Calang Aceh Jaya, II-III Aceh Besar ... ``` +## Shakemap API + +Shakemap API is part of the earthquake API. There is one method +that the shakemap API has, namely the get_content method. + +### get_content + +get_content is used to get latest earthquake shake map. +The link starts with `https://data.bmkg.go.id/DataMKG/TEWS` +and followed with `/shakemap-filename`. Read get_content +[reference](reference/api.md/#bmkg.api.Shakemap.get_content) +for more details. + +Code example: + +```python +import asyncio + +from bmkg import BMKG + + +async def main(): + async with BMKG() as bmkg: + latest_earthquake = await bmkg.earthquake.get_latest_earthquake() + shakemap = latest_earthquake.shakemap + shakemap_content = await shakemap.get_content() + + print(shakemap.file_name) + print(shakemap_content) + +asyncio.run(main()) +``` + +Example output: + +```console +20240203152510.mmi.jpg +b'\xff\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x01\x00...' +``` + ## Weather Forecast API There is only one API available for weather forecast @@ -219,9 +224,9 @@ within three days. There are 35 weather forecast data representing provinces and major cities in Indonesia. For each area you will get twelve weather forecasts data so there are four weather forecasts for one day. The link -starts with `https://data.bmkg.go.id/DataMKG/MEWS/DigitalForecast/` -and followed with `DigitalForecast-{PROVINCE_NAME}.xml`. Read -get_weather_forecast [reference](reference/api.md/#bmkg.weather_forecast.WeatherForecast.get_weather_forecast) +starts with `https://data.bmkg.go.id/DataMKG/MEWS/DigitalForecast` +and followed with `/DigitalForecast-{PROVINCE_NAME}.xml`. Read +get_weather_forecast [reference](reference/api.md/#bmkg.api.WeatherForecast.get_weather_forecast) for more details. Code example: diff --git a/poetry.lock b/poetry.lock index 05c4675..a813104 100644 --- a/poetry.lock +++ b/poetry.lock @@ -480,13 +480,13 @@ dev = ["flake8", "markdown", "twine", "wheel"] [[package]] name = "griffe" -version = "0.40.0" +version = "0.40.1" description = "Signatures for entire Python programs. Extract the structure, the frame, the skeleton of your project, to generate API documentation or find breaking changes in your API." optional = false python-versions = ">=3.8" files = [ - {file = "griffe-0.40.0-py3-none-any.whl", hash = "sha256:db1da6d1d8e08cbb20f1a7dee8c09da940540c2d4c1bfa26a9091cf6fc36a9ec"}, - {file = "griffe-0.40.0.tar.gz", hash = "sha256:76c4439eaa2737af46ae003c331ab6ca79c5365b552f7b5aed263a3b4125735b"}, + {file = "griffe-0.40.1-py3-none-any.whl", hash = "sha256:5b8c023f366fe273e762131fe4bfd141ea56c09b3cb825aa92d06a82681cfd93"}, + {file = "griffe-0.40.1.tar.gz", hash = "sha256:66c48a62e2ce5784b6940e603300fcfb807b6f099b94e7f753f1841661fd5c7c"}, ] [package.dependencies] @@ -708,13 +708,13 @@ mkdocs = ">=1.1" [[package]] name = "mkdocs-material" -version = "9.5.7" +version = "9.5.9" description = "Documentation that simply works" optional = false python-versions = ">=3.8" files = [ - {file = "mkdocs_material-9.5.7-py3-none-any.whl", hash = "sha256:0be8ce8bcfebb52bae9b00cf9b851df45b8a92d629afcfd7f2c09b2dfa155ea3"}, - {file = "mkdocs_material-9.5.7.tar.gz", hash = "sha256:16110292575d88a338d2961f3cb665cf12943ff8829e551a9b364f24019e46af"}, + {file = "mkdocs_material-9.5.9-py3-none-any.whl", hash = "sha256:a5d62b73b3b74349e45472bfadc129c871dd2d4add68d84819580597b2f50d5d"}, + {file = "mkdocs_material-9.5.9.tar.gz", hash = "sha256:635df543c01c25c412d6c22991872267723737d5a2f062490f33b2da1c013c6d"}, ] [package.dependencies] @@ -731,7 +731,7 @@ regex = ">=2022.4" requests = ">=2.26,<3.0" [package.extras] -git = ["mkdocs-git-committers-plugin-2 (>=1.1,<2.0)", "mkdocs-git-revision-date-localized-plugin (>=1.2,<2.0)"] +git = ["mkdocs-git-committers-plugin-2 (>=1.1,<2.0)", "mkdocs-git-revision-date-localized-plugin (>=1.2.4,<2.0)"] imaging = ["cairosvg (>=2.6,<3.0)", "pillow (>=10.2,<11.0)"] recommended = ["mkdocs-minify-plugin (>=0.7,<1.0)", "mkdocs-redirects (>=1.2,<2.0)", "mkdocs-rss-plugin (>=1.6,<2.0)"] @@ -1081,37 +1081,37 @@ extra = ["pygments (>=2.12)"] [[package]] name = "pytest" -version = "7.4.4" +version = "8.0.0" description = "pytest: simple powerful testing with Python" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "pytest-7.4.4-py3-none-any.whl", hash = "sha256:b090cdf5ed60bf4c45261be03239c2c1c22df034fbffe691abe93cd80cea01d8"}, - {file = "pytest-7.4.4.tar.gz", hash = "sha256:2cf0005922c6ace4a3e2ec8b4080eb0d9753fdc93107415332f50ce9e7994280"}, + {file = "pytest-8.0.0-py3-none-any.whl", hash = "sha256:50fb9cbe836c3f20f0dfa99c565201fb75dc54c8d76373cd1bde06b06657bdb6"}, + {file = "pytest-8.0.0.tar.gz", hash = "sha256:249b1b0864530ba251b7438274c4d251c58d868edaaec8762893ad4a0d71c36c"}, ] [package.dependencies] colorama = {version = "*", markers = "sys_platform == \"win32\""} iniconfig = "*" packaging = "*" -pluggy = ">=0.12,<2.0" +pluggy = ">=1.3.0,<2.0" [package.extras] testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] [[package]] name = "pytest-asyncio" -version = "0.23.4" +version = "0.23.5" description = "Pytest support for asyncio" optional = false python-versions = ">=3.8" files = [ - {file = "pytest-asyncio-0.23.4.tar.gz", hash = "sha256:2143d9d9375bf372a73260e4114541485e84fca350b0b6b92674ca56ff5f7ea2"}, - {file = "pytest_asyncio-0.23.4-py3-none-any.whl", hash = "sha256:b0079dfac14b60cd1ce4691fbfb1748fe939db7d0234b5aba97197d10fbe0fef"}, + {file = "pytest-asyncio-0.23.5.tar.gz", hash = "sha256:3a048872a9c4ba14c3e90cc1aa20cbc2def7d01c7c8db3777ec281ba9c057675"}, + {file = "pytest_asyncio-0.23.5-py3-none-any.whl", hash = "sha256:4e7093259ba018d58ede7d5315131d21923a60f8a6e9ee266ce1589685c89eac"}, ] [package.dependencies] -pytest = ">=7.0.0,<8" +pytest = ">=7.0.0,<9" [package.extras] docs = ["sphinx (>=5.3)", "sphinx-rtd-theme (>=1.0)"] @@ -1355,28 +1355,28 @@ jupyter = ["ipywidgets (>=7.5.1,<9)"] [[package]] name = "ruff" -version = "0.1.15" +version = "0.2.1" description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.1.15-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:5fe8d54df166ecc24106db7dd6a68d44852d14eb0729ea4672bb4d96c320b7df"}, - {file = "ruff-0.1.15-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:6f0bfbb53c4b4de117ac4d6ddfd33aa5fc31beeaa21d23c45c6dd249faf9126f"}, - {file = "ruff-0.1.15-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e0d432aec35bfc0d800d4f70eba26e23a352386be3a6cf157083d18f6f5881c8"}, - {file = "ruff-0.1.15-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:9405fa9ac0e97f35aaddf185a1be194a589424b8713e3b97b762336ec79ff807"}, - {file = "ruff-0.1.15-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c66ec24fe36841636e814b8f90f572a8c0cb0e54d8b5c2d0e300d28a0d7bffec"}, - {file = "ruff-0.1.15-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:6f8ad828f01e8dd32cc58bc28375150171d198491fc901f6f98d2a39ba8e3ff5"}, - {file = "ruff-0.1.15-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:86811954eec63e9ea162af0ffa9f8d09088bab51b7438e8b6488b9401863c25e"}, - {file = "ruff-0.1.15-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:fd4025ac5e87d9b80e1f300207eb2fd099ff8200fa2320d7dc066a3f4622dc6b"}, - {file = "ruff-0.1.15-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b17b93c02cdb6aeb696effecea1095ac93f3884a49a554a9afa76bb125c114c1"}, - {file = "ruff-0.1.15-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:ddb87643be40f034e97e97f5bc2ef7ce39de20e34608f3f829db727a93fb82c5"}, - {file = "ruff-0.1.15-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:abf4822129ed3a5ce54383d5f0e964e7fef74a41e48eb1dfad404151efc130a2"}, - {file = "ruff-0.1.15-py3-none-musllinux_1_2_i686.whl", hash = "sha256:6c629cf64bacfd136c07c78ac10a54578ec9d1bd2a9d395efbee0935868bf852"}, - {file = "ruff-0.1.15-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:1bab866aafb53da39c2cadfb8e1c4550ac5340bb40300083eb8967ba25481447"}, - {file = "ruff-0.1.15-py3-none-win32.whl", hash = "sha256:2417e1cb6e2068389b07e6fa74c306b2810fe3ee3476d5b8a96616633f40d14f"}, - {file = "ruff-0.1.15-py3-none-win_amd64.whl", hash = "sha256:3837ac73d869efc4182d9036b1405ef4c73d9b1f88da2413875e34e0d6919587"}, - {file = "ruff-0.1.15-py3-none-win_arm64.whl", hash = "sha256:9a933dfb1c14ec7a33cceb1e49ec4a16b51ce3c20fd42663198746efc0427360"}, - {file = "ruff-0.1.15.tar.gz", hash = "sha256:f6dfa8c1b21c913c326919056c390966648b680966febcb796cc9d1aaab8564e"}, + {file = "ruff-0.2.1-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:dd81b911d28925e7e8b323e8d06951554655021df8dd4ac3045d7212ac4ba080"}, + {file = "ruff-0.2.1-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:dc586724a95b7d980aa17f671e173df00f0a2eef23f8babbeee663229a938fec"}, + {file = "ruff-0.2.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c92db7101ef5bfc18e96777ed7bc7c822d545fa5977e90a585accac43d22f18a"}, + {file = "ruff-0.2.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:13471684694d41ae0f1e8e3a7497e14cd57ccb7dd72ae08d56a159d6c9c3e30e"}, + {file = "ruff-0.2.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a11567e20ea39d1f51aebd778685582d4c56ccb082c1161ffc10f79bebe6df35"}, + {file = "ruff-0.2.1-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:00a818e2db63659570403e44383ab03c529c2b9678ba4ba6c105af7854008105"}, + {file = "ruff-0.2.1-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:be60592f9d218b52f03384d1325efa9d3b41e4c4d55ea022cd548547cc42cd2b"}, + {file = "ruff-0.2.1-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:fbd2288890b88e8aab4499e55148805b58ec711053588cc2f0196a44f6e3d855"}, + {file = "ruff-0.2.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f3ef052283da7dec1987bba8d8733051c2325654641dfe5877a4022108098683"}, + {file = "ruff-0.2.1-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:7022d66366d6fded4ba3889f73cd791c2d5621b2ccf34befc752cb0df70f5fad"}, + {file = "ruff-0.2.1-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:0a725823cb2a3f08ee743a534cb6935727d9e47409e4ad72c10a3faf042ad5ba"}, + {file = "ruff-0.2.1-py3-none-musllinux_1_2_i686.whl", hash = "sha256:0034d5b6323e6e8fe91b2a1e55b02d92d0b582d2953a2b37a67a2d7dedbb7acc"}, + {file = "ruff-0.2.1-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:e5cb5526d69bb9143c2e4d2a115d08ffca3d8e0fddc84925a7b54931c96f5c02"}, + {file = "ruff-0.2.1-py3-none-win32.whl", hash = "sha256:6b95ac9ce49b4fb390634d46d6ece32ace3acdd52814671ccaf20b7f60adb232"}, + {file = "ruff-0.2.1-py3-none-win_amd64.whl", hash = "sha256:e3affdcbc2afb6f5bd0eb3130139ceedc5e3f28d206fe49f63073cb9e65988e0"}, + {file = "ruff-0.2.1-py3-none-win_arm64.whl", hash = "sha256:efababa8e12330aa94a53e90a81eb6e2d55f348bc2e71adbf17d9cad23c03ee6"}, + {file = "ruff-0.2.1.tar.gz", hash = "sha256:3b42b5d8677cd0c72b99fcaf068ffc62abb5a19e71b4a3b9cfa50658a0af02f1"}, ] [[package]] @@ -1445,38 +1445,40 @@ zstd = ["zstandard (>=0.18.0)"] [[package]] name = "watchdog" -version = "3.0.0" +version = "4.0.0" description = "Filesystem events monitoring" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "watchdog-3.0.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:336adfc6f5cc4e037d52db31194f7581ff744b67382eb6021c868322e32eef41"}, - {file = "watchdog-3.0.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:a70a8dcde91be523c35b2bf96196edc5730edb347e374c7de7cd20c43ed95397"}, - {file = "watchdog-3.0.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:adfdeab2da79ea2f76f87eb42a3ab1966a5313e5a69a0213a3cc06ef692b0e96"}, - {file = "watchdog-3.0.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:2b57a1e730af3156d13b7fdddfc23dea6487fceca29fc75c5a868beed29177ae"}, - {file = "watchdog-3.0.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:7ade88d0d778b1b222adebcc0927428f883db07017618a5e684fd03b83342bd9"}, - {file = "watchdog-3.0.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:7e447d172af52ad204d19982739aa2346245cc5ba6f579d16dac4bfec226d2e7"}, - {file = "watchdog-3.0.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:9fac43a7466eb73e64a9940ac9ed6369baa39b3bf221ae23493a9ec4d0022674"}, - {file = "watchdog-3.0.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:8ae9cda41fa114e28faf86cb137d751a17ffd0316d1c34ccf2235e8a84365c7f"}, - {file = "watchdog-3.0.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:25f70b4aa53bd743729c7475d7ec41093a580528b100e9a8c5b5efe8899592fc"}, - {file = "watchdog-3.0.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:4f94069eb16657d2c6faada4624c39464f65c05606af50bb7902e036e3219be3"}, - {file = "watchdog-3.0.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:7c5f84b5194c24dd573fa6472685b2a27cc5a17fe5f7b6fd40345378ca6812e3"}, - {file = "watchdog-3.0.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:3aa7f6a12e831ddfe78cdd4f8996af9cf334fd6346531b16cec61c3b3c0d8da0"}, - {file = "watchdog-3.0.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:233b5817932685d39a7896b1090353fc8efc1ef99c9c054e46c8002561252fb8"}, - {file = "watchdog-3.0.0-pp37-pypy37_pp73-macosx_10_9_x86_64.whl", hash = "sha256:13bbbb462ee42ec3c5723e1205be8ced776f05b100e4737518c67c8325cf6100"}, - {file = "watchdog-3.0.0-pp38-pypy38_pp73-macosx_10_9_x86_64.whl", hash = "sha256:8f3ceecd20d71067c7fd4c9e832d4e22584318983cabc013dbf3f70ea95de346"}, - {file = "watchdog-3.0.0-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:c9d8c8ec7efb887333cf71e328e39cffbf771d8f8f95d308ea4125bf5f90ba64"}, - {file = "watchdog-3.0.0-py3-none-manylinux2014_aarch64.whl", hash = "sha256:0e06ab8858a76e1219e68c7573dfeba9dd1c0219476c5a44d5333b01d7e1743a"}, - {file = "watchdog-3.0.0-py3-none-manylinux2014_armv7l.whl", hash = "sha256:d00e6be486affb5781468457b21a6cbe848c33ef43f9ea4a73b4882e5f188a44"}, - {file = "watchdog-3.0.0-py3-none-manylinux2014_i686.whl", hash = "sha256:c07253088265c363d1ddf4b3cdb808d59a0468ecd017770ed716991620b8f77a"}, - {file = "watchdog-3.0.0-py3-none-manylinux2014_ppc64.whl", hash = "sha256:5113334cf8cf0ac8cd45e1f8309a603291b614191c9add34d33075727a967709"}, - {file = "watchdog-3.0.0-py3-none-manylinux2014_ppc64le.whl", hash = "sha256:51f90f73b4697bac9c9a78394c3acbbd331ccd3655c11be1a15ae6fe289a8c83"}, - {file = "watchdog-3.0.0-py3-none-manylinux2014_s390x.whl", hash = "sha256:ba07e92756c97e3aca0912b5cbc4e5ad802f4557212788e72a72a47ff376950d"}, - {file = "watchdog-3.0.0-py3-none-manylinux2014_x86_64.whl", hash = "sha256:d429c2430c93b7903914e4db9a966c7f2b068dd2ebdd2fa9b9ce094c7d459f33"}, - {file = "watchdog-3.0.0-py3-none-win32.whl", hash = "sha256:3ed7c71a9dccfe838c2f0b6314ed0d9b22e77d268c67e015450a29036a81f60f"}, - {file = "watchdog-3.0.0-py3-none-win_amd64.whl", hash = "sha256:4c9956d27be0bb08fc5f30d9d0179a855436e655f046d288e2bcc11adfae893c"}, - {file = "watchdog-3.0.0-py3-none-win_ia64.whl", hash = "sha256:5d9f3a10e02d7371cd929b5d8f11e87d4bad890212ed3901f9b4d68767bee759"}, - {file = "watchdog-3.0.0.tar.gz", hash = "sha256:4d98a320595da7a7c5a18fc48cb633c2e73cda78f93cac2ef42d42bf609a33f9"}, + {file = "watchdog-4.0.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:39cb34b1f1afbf23e9562501673e7146777efe95da24fab5707b88f7fb11649b"}, + {file = "watchdog-4.0.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:c522392acc5e962bcac3b22b9592493ffd06d1fc5d755954e6be9f4990de932b"}, + {file = "watchdog-4.0.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:6c47bdd680009b11c9ac382163e05ca43baf4127954c5f6d0250e7d772d2b80c"}, + {file = "watchdog-4.0.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:8350d4055505412a426b6ad8c521bc7d367d1637a762c70fdd93a3a0d595990b"}, + {file = "watchdog-4.0.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:c17d98799f32e3f55f181f19dd2021d762eb38fdd381b4a748b9f5a36738e935"}, + {file = "watchdog-4.0.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:4986db5e8880b0e6b7cd52ba36255d4793bf5cdc95bd6264806c233173b1ec0b"}, + {file = "watchdog-4.0.0-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:11e12fafb13372e18ca1bbf12d50f593e7280646687463dd47730fd4f4d5d257"}, + {file = "watchdog-4.0.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:5369136a6474678e02426bd984466343924d1df8e2fd94a9b443cb7e3aa20d19"}, + {file = "watchdog-4.0.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:76ad8484379695f3fe46228962017a7e1337e9acadafed67eb20aabb175df98b"}, + {file = "watchdog-4.0.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:45cc09cc4c3b43fb10b59ef4d07318d9a3ecdbff03abd2e36e77b6dd9f9a5c85"}, + {file = "watchdog-4.0.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:eed82cdf79cd7f0232e2fdc1ad05b06a5e102a43e331f7d041e5f0e0a34a51c4"}, + {file = "watchdog-4.0.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:ba30a896166f0fee83183cec913298151b73164160d965af2e93a20bbd2ab605"}, + {file = "watchdog-4.0.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:d18d7f18a47de6863cd480734613502904611730f8def45fc52a5d97503e5101"}, + {file = "watchdog-4.0.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:2895bf0518361a9728773083908801a376743bcc37dfa252b801af8fd281b1ca"}, + {file = "watchdog-4.0.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:87e9df830022488e235dd601478c15ad73a0389628588ba0b028cb74eb72fed8"}, + {file = "watchdog-4.0.0-pp310-pypy310_pp73-macosx_10_9_x86_64.whl", hash = "sha256:6e949a8a94186bced05b6508faa61b7adacc911115664ccb1923b9ad1f1ccf7b"}, + {file = "watchdog-4.0.0-pp38-pypy38_pp73-macosx_10_9_x86_64.whl", hash = "sha256:6a4db54edea37d1058b08947c789a2354ee02972ed5d1e0dca9b0b820f4c7f92"}, + {file = "watchdog-4.0.0-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:d31481ccf4694a8416b681544c23bd271f5a123162ab603c7d7d2dd7dd901a07"}, + {file = "watchdog-4.0.0-py3-none-manylinux2014_aarch64.whl", hash = "sha256:8fec441f5adcf81dd240a5fe78e3d83767999771630b5ddfc5867827a34fa3d3"}, + {file = "watchdog-4.0.0-py3-none-manylinux2014_armv7l.whl", hash = "sha256:6a9c71a0b02985b4b0b6d14b875a6c86ddea2fdbebd0c9a720a806a8bbffc69f"}, + {file = "watchdog-4.0.0-py3-none-manylinux2014_i686.whl", hash = "sha256:557ba04c816d23ce98a06e70af6abaa0485f6d94994ec78a42b05d1c03dcbd50"}, + {file = "watchdog-4.0.0-py3-none-manylinux2014_ppc64.whl", hash = "sha256:d0f9bd1fd919134d459d8abf954f63886745f4660ef66480b9d753a7c9d40927"}, + {file = "watchdog-4.0.0-py3-none-manylinux2014_ppc64le.whl", hash = "sha256:f9b2fdca47dc855516b2d66eef3c39f2672cbf7e7a42e7e67ad2cbfcd6ba107d"}, + {file = "watchdog-4.0.0-py3-none-manylinux2014_s390x.whl", hash = "sha256:73c7a935e62033bd5e8f0da33a4dcb763da2361921a69a5a95aaf6c93aa03a87"}, + {file = "watchdog-4.0.0-py3-none-manylinux2014_x86_64.whl", hash = "sha256:6a80d5cae8c265842c7419c560b9961561556c4361b297b4c431903f8c33b269"}, + {file = "watchdog-4.0.0-py3-none-win32.whl", hash = "sha256:8f9a542c979df62098ae9c58b19e03ad3df1c9d8c6895d96c0d51da17b243b1c"}, + {file = "watchdog-4.0.0-py3-none-win_amd64.whl", hash = "sha256:f970663fa4f7e80401a7b0cbeec00fa801bf0287d93d48368fc3e6fa32716245"}, + {file = "watchdog-4.0.0-py3-none-win_ia64.whl", hash = "sha256:9a03e16e55465177d416699331b0f3564138f1807ecc5f2de9d55d8f188d08c7"}, + {file = "watchdog-4.0.0.tar.gz", hash = "sha256:e3e7065cbdabe6183ab82199d7a4f6b3ba0a438c5a512a68559846ccb76a78ec"}, ] [package.extras] @@ -1588,4 +1590,4 @@ multidict = ">=4.0" [metadata] lock-version = "2.0" python-versions = "^3.11" -content-hash = "c3735b49ffced8b08aa5938294fc655c29d3b02fc3e2518ab6163553640876ef" +content-hash = "fb83f7888ccaf16653929446b6ba54132809c4ba17d02f2cd533ef12f4a32513" diff --git a/pyproject.toml b/pyproject.toml index 8147e23..69e43ea 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "PyBMKG" -version = "1.0.0" +version = "2.0.0" description = "Python BMKG API Wrapper" authors = ["Kira "] packages = [ @@ -35,10 +35,10 @@ python = "^3.11" bandit = "^1.7.6" mypy = "^1.8.0" poethepoet = "^0.24.4" -ruff = "^0.1.14" +ruff = "^0.2.1" [tool.poetry.group.test.dependencies] -pytest = "^7.4.4" +pytest = "^8.0.0" pytest-asyncio = "^0.23.3" pytest-cov = "^4.1.0" @@ -98,6 +98,14 @@ src = ["src", "tests"] docstring-code-format = true [tool.pytest.ini_options] -addopts = "-vvv --doctest-modules" +addopts = [ + "-vvv", + "--doctest-modules", + "--import-mode=importlib", +] +pythonpath = [ + ".", + "src", +] testpaths = ["tests", "src"] asyncio_mode = "auto" diff --git a/src/bmkg/api/__init__.py b/src/bmkg/api/__init__.py index d754f0a..ecd3e2d 100644 --- a/src/bmkg/api/__init__.py +++ b/src/bmkg/api/__init__.py @@ -1,3 +1,11 @@ from .bmkg import BMKG +from .earthquake import Earthquake +from .shakemap import Shakemap +from .weather_forecast import WeatherForecast -__all__ = ["BMKG"] +__all__ = [ + "BMKG", + "Earthquake", + "Shakemap", + "WeatherForecast", +] diff --git a/src/bmkg/exception.py b/src/bmkg/exceptions.py similarity index 100% rename from src/bmkg/exception.py rename to src/bmkg/exceptions.py diff --git a/src/bmkg/parsers/parse_area_element.py b/src/bmkg/parsers/parse_area_element.py index d2efd55..145417c 100644 --- a/src/bmkg/parsers/parse_area_element.py +++ b/src/bmkg/parsers/parse_area_element.py @@ -3,7 +3,7 @@ from xml.etree.ElementTree import Element # nosec B405 from ..enums import Type -from ..exception import WeatherForecastParseError +from ..exceptions import WeatherForecastParseError from ..schemas import ( Area, Coordinate, diff --git a/src/bmkg/parsers/parse_data_element.py b/src/bmkg/parsers/parse_data_element.py index 3255178..5fb88d9 100644 --- a/src/bmkg/parsers/parse_data_element.py +++ b/src/bmkg/parsers/parse_data_element.py @@ -2,7 +2,7 @@ # Element is used only for typing not parsing from xml.etree.ElementTree import Element # nosec B405 -from ..exception import WeatherForecastParseError +from ..exceptions import WeatherForecastParseError from ..schemas import Data __all__ = ["parse_data_element"] diff --git a/src/bmkg/parsers/parse_datetime_element.py b/src/bmkg/parsers/parse_datetime_element.py index b624560..190c3a4 100644 --- a/src/bmkg/parsers/parse_datetime_element.py +++ b/src/bmkg/parsers/parse_datetime_element.py @@ -5,7 +5,7 @@ # Element is used only for typing not parsing from xml.etree.ElementTree import Element # nosec B405 -from ..exception import WeatherForecastParseError +from ..exceptions import WeatherForecastParseError __all__ = ["parse_datetime_element"] diff --git a/src/bmkg/parsers/parse_forecast_element.py b/src/bmkg/parsers/parse_forecast_element.py index 576b770..b7c4889 100644 --- a/src/bmkg/parsers/parse_forecast_element.py +++ b/src/bmkg/parsers/parse_forecast_element.py @@ -2,7 +2,7 @@ # Element is used only for typing not parsing from xml.etree.ElementTree import Element # nosec B405 -from ..exception import WeatherForecastParseError +from ..exceptions import WeatherForecastParseError from ..schemas import Forecast __all__ = ["parse_forecast_element"] diff --git a/src/bmkg/parsers/parse_humidity_element.py b/src/bmkg/parsers/parse_humidity_element.py index a1f607c..6a5dbfe 100644 --- a/src/bmkg/parsers/parse_humidity_element.py +++ b/src/bmkg/parsers/parse_humidity_element.py @@ -4,7 +4,7 @@ # Element is used only for typing not parsing from xml.etree.ElementTree import Element # nosec B405 -from ..exception import WeatherForecastParseError +from ..exceptions import WeatherForecastParseError from ..schemas import Humidity __all__ = ["parse_humidity_element"] diff --git a/src/bmkg/parsers/parse_issue_element.py b/src/bmkg/parsers/parse_issue_element.py index 4c1a362..c8bc2f9 100644 --- a/src/bmkg/parsers/parse_issue_element.py +++ b/src/bmkg/parsers/parse_issue_element.py @@ -4,7 +4,7 @@ # Element is used only for typing not parsing from xml.etree.ElementTree import Element # nosec B405 -from ..exception import WeatherForecastParseError +from ..exceptions import WeatherForecastParseError __all__ = ["parse_issue_element"] diff --git a/src/bmkg/parsers/parse_temperature_element.py b/src/bmkg/parsers/parse_temperature_element.py index e9f39b9..6133814 100644 --- a/src/bmkg/parsers/parse_temperature_element.py +++ b/src/bmkg/parsers/parse_temperature_element.py @@ -4,7 +4,7 @@ # Element is used only for typing not parsing from xml.etree.ElementTree import Element # nosec B405 -from ..exception import WeatherForecastParseError +from ..exceptions import WeatherForecastParseError from ..schemas import Temperature __all__ = ["parse_temperature_element"] diff --git a/src/bmkg/parsers/parse_weather_element.py b/src/bmkg/parsers/parse_weather_element.py index 1b0eac1..c3cc46f 100644 --- a/src/bmkg/parsers/parse_weather_element.py +++ b/src/bmkg/parsers/parse_weather_element.py @@ -5,7 +5,7 @@ from xml.etree.ElementTree import Element # nosec B405 from .. import enums -from ..exception import WeatherForecastParseError +from ..exceptions import WeatherForecastParseError __all__ = ["parse_weather_element"] diff --git a/src/bmkg/parsers/parse_weather_forecast_data.py b/src/bmkg/parsers/parse_weather_forecast_data.py index 43681fd..f9a320b 100644 --- a/src/bmkg/parsers/parse_weather_forecast_data.py +++ b/src/bmkg/parsers/parse_weather_forecast_data.py @@ -6,7 +6,7 @@ from defusedxml.ElementTree import fromstring # type: ignore from ..enums import Type -from ..exception import WeatherForecastParseError +from ..exceptions import WeatherForecastParseError from ..schemas import ( Weather, WeatherForecast, diff --git a/src/bmkg/parsers/parse_wind_direction_element.py b/src/bmkg/parsers/parse_wind_direction_element.py index 8e22ff2..78cfca7 100644 --- a/src/bmkg/parsers/parse_wind_direction_element.py +++ b/src/bmkg/parsers/parse_wind_direction_element.py @@ -5,7 +5,7 @@ from xml.etree.ElementTree import Element # nosec B405 from ..enums import Cardinal, Sexa -from ..exception import WeatherForecastParseError +from ..exceptions import WeatherForecastParseError from ..schemas import WindDirection __all__ = ["parse_wind_direction_element"] diff --git a/src/bmkg/parsers/parse_wind_speed_element.py b/src/bmkg/parsers/parse_wind_speed_element.py index 0b8abf7..6c26ce0 100644 --- a/src/bmkg/parsers/parse_wind_speed_element.py +++ b/src/bmkg/parsers/parse_wind_speed_element.py @@ -4,7 +4,7 @@ # Element is used only for typing not parsing from xml.etree.ElementTree import Element # nosec B405 -from ..exception import WeatherForecastParseError +from ..exceptions import WeatherForecastParseError from ..schemas import WindSpeed __all__ = ["parse_wind_speed_element"] diff --git a/tests/test_enum.py b/tests/test_enum.py deleted file mode 100644 index a1c35c7..0000000 --- a/tests/test_enum.py +++ /dev/null @@ -1,251 +0,0 @@ -from itertools import chain, repeat - -import pytest - -from bmkg.enums import Cardinal, Province, Sexa, Type, Weather - -expected_cardinal_values = ( - "N", - "NNE", - "NE", - "ENE", - "E", - "ESE", - "SE", - "SSE", - "S", - "SSW", - "SW", - "WSW", - "W", - "WNW", - "NW", - "NNW", - "VARIABLE", -) -expected_province_values = ( - "Aceh", - "Bali", - "BangkaBelitung", - "Banten", - "Bengkulu", - "DIYogyakarta", - "DKIJakarta", - "Gorontalo", - "Jambi", - "JawaBarat", - "JawaTengah", - "JawaTimur", - "KalimantanBarat", - "KalimantanSelatan", - "KalimantanTengah", - "KalimantanTimur", - "KalimantanUtara", - "KepulauanRiau", - "Lampung", - "Maluku", - "MalukuUtara", - "NusaTenggaraBarat", - "NusaTenggaraTimur", - "Papua", - "PapuaBarat", - "Riau", - "SulawesiBarat", - "SulawesiSelatan", - "SulawesiTengah", - "SulawesiTenggara", - "SulawesiUtara", - "SumateraBarat", - "SumateraSelatan", - "SumateraUtara", - "Indonesia", -) -expected_sexa_values = ( - "2230", - "4500", - "6730", - "9000", - "11230", - "13500", - "15730", - "18000", - "20230", - "22500", - "24730", - "27000", - "29230", - "31500", - "33730", - "000", -) -expected_type_values = ( - "land", - "sea", -) -expected_weather_values = ( - 0, - 1, - 2, - 3, - 4, - 5, - 10, - 45, - 60, - 61, - 63, - 80, - 95, - 97, -) -expected_cardinal_names = ( - "NORTH", - "NORTH_NORTHEAST", - "NORTHEAST", - "EAST_NORTHEAST", - "EAST", - "EAST_SOUTHEAST", - "SOUTHEAST", - "SOUTH_SOUTHEAST", - "SOUTH", - "SOUTH_SOUTHWEST", - "SOUTHWEST", - "WEST_SOUTHWEST", - "WEST", - "WEST_NORTHWEST", - "NORTHWEST", - "NORTH_NORTHWEST", - "VARIABLE", -) -expected_province_names = ( - "ACEH", - "BALI", - "BANGKA_BELITUNG", - "BANTEN", - "BENGKULU", - "DI_YOGYAKARTA", - "DKI_JAKARTA", - "GORONTALO", - "JAMBI", - "JAWA_BARAT", - "JAWA_TENGAH", - "JAWA_TIMUR", - "KALIMANTAN_BARAT", - "KALIMANTAN_SELATAN", - "KALIMANTAN_TENGAH", - "KALIMANTAN_TIMUR", - "KALIMANTAN_UTARA", - "KEPULAUAN_RIAU", - "LAMPUNG", - "MALUKU", - "MALUKU_UTARA", - "NUSA_TENGGARA_BARAT", - "NUSA_TENGGARA_TIMUR", - "PAPUA", - "PAPUA_BARAT", - "RIAU", - "SULAWESI_BARAT", - "SULAWESI_SELATAN", - "SULAWESI_TENGAH", - "SULAWESI_TENGGARA", - "SULAWESI_UTARA", - "SUMATERA_BARAT", - "SUMATERA_SELATAN", - "SUMATERA_UTARA", - "INDONESIA", -) -expected_sexa_names = ( - "NORTH_NORTHEAST", - "NORTHEAST", - "EAST_NORTHEAST", - "EAST", - "EAST_SOUTHEAST", - "SOUTHEAST", - "SOUTH_SOUTHEAST", - "SOUTH", - "SOUTH_SOUTHWEST", - "SOUTHWEST", - "WEST_SOUTHWEST", - "WEST", - "WEST_NORTHWEST", - "NORTHWEST", - "NORTH_NORTHWEST", - "VARIABLE", -) -expected_type_names = ( - "LAND", - "SEA", -) -expected_weather_names = ( - "CLEAR_SKIES", - "PARTLY_CLOUDY", - "PARTLY_CLOUDY2", - "MOSTLY_CLOUDY", - "OVERCAST", - "HAZE", - "SMOKE", - "FOG", - "LIGHT_RAIN", - "RAIN", - "HEAVY_RAIN", - "ISOLATED_SHOWER", - "SEVERE_THUNDERSTORM", - "SEVERE_THUNDERSTORM2", -) -expected_enum_names_or_values = chain( - expected_cardinal_values, - expected_province_values, - expected_sexa_values, - expected_type_values, - expected_weather_values, - expected_cardinal_names, - expected_province_names, - expected_sexa_names, - expected_type_names, - expected_weather_names, -) - -actual_cardinal_values = (member.value for member in Cardinal) -actual_province_values = (member.value for member in Province) -actual_sexa_values = (member.value for member in Sexa) -actual_type_values = (member.value for member in Type) -actual_weather_values = (member.value for member in Weather) -actual_cardinal_names = (member.name for member in Cardinal) -actual_province_names = (member.name for member in Province) -actual_sexa_names = (member.name for member in Sexa) -actual_type_names = (member.name for member in Type) -actual_weather_names = (member.name for member in Weather) -actual_enum_names_or_values = chain( - repeat(actual_cardinal_values, len(expected_cardinal_values)), - repeat(actual_province_values, len(expected_province_values)), - repeat(actual_sexa_values, len(expected_sexa_values)), - repeat(actual_type_values, len(expected_type_values)), - repeat(actual_weather_values, len(expected_weather_values)), - repeat(actual_cardinal_names, len(expected_cardinal_names)), - repeat(actual_province_names, len(expected_province_names)), - repeat(actual_sexa_names, len(expected_sexa_names)), - repeat(actual_type_names, len(expected_type_names)), - repeat(actual_weather_names, len(expected_weather_names)), -) - - -@pytest.mark.parametrize( - "expected_enum_name_or_value, actual_enum_names_or_values", - zip(expected_enum_names_or_values, actual_enum_names_or_values), -) -def test_enum_member_is_contained_in_enum_class( - expected_enum_name_or_value, actual_enum_names_or_values -): - assert expected_enum_name_or_value in actual_enum_names_or_values - - -@pytest.mark.parametrize( - "enum_class, count", - ((Cardinal, 17), (Province, 34 + 1), (Sexa, 17 - 1), (Type, 2), (Weather, 12 + 2)), -) -def test_enum_member_count(enum_class, count): - assert len(enum_class) == count - - -def test_sexa_not_contain_north(): - assert "NORTH" not in expected_sexa_names diff --git a/tests/test_integration/__init__.py b/tests/test_integration/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_earthquake_integration.py b/tests/test_integration/test_earthquake_integration.py similarity index 100% rename from tests/test_earthquake_integration.py rename to tests/test_integration/test_earthquake_integration.py diff --git a/tests/test_weather_forecast_integration.py b/tests/test_integration/test_weather_forecast_integration.py similarity index 100% rename from tests/test_weather_forecast_integration.py rename to tests/test_integration/test_weather_forecast_integration.py diff --git a/tests/test_parsers/test_parse_area_element.py b/tests/test_parsers/test_parse_area_element.py index 80685af..f0ae97d 100644 --- a/tests/test_parsers/test_parse_area_element.py +++ b/tests/test_parsers/test_parse_area_element.py @@ -2,7 +2,7 @@ import pytest -from bmkg.exception import WeatherForecastParseError +from bmkg.exceptions import WeatherForecastParseError from bmkg.parsers import parse_area_element diff --git a/tests/test_parsers/test_parse_data_element.py b/tests/test_parsers/test_parse_data_element.py index 4412acf..721efcc 100644 --- a/tests/test_parsers/test_parse_data_element.py +++ b/tests/test_parsers/test_parse_data_element.py @@ -2,7 +2,7 @@ import pytest -from bmkg.exception import WeatherForecastParseError +from bmkg.exceptions import WeatherForecastParseError from bmkg.parsers import parse_data_element diff --git a/tests/test_parsers/test_parse_datetime_element.py b/tests/test_parsers/test_parse_datetime_element.py index 5468415..fb27c15 100644 --- a/tests/test_parsers/test_parse_datetime_element.py +++ b/tests/test_parsers/test_parse_datetime_element.py @@ -2,7 +2,7 @@ import pytest -from bmkg.exception import WeatherForecastParseError +from bmkg.exceptions import WeatherForecastParseError from bmkg.parsers import parse_datetime_element diff --git a/tests/test_parsers/test_parse_forecast_element.py b/tests/test_parsers/test_parse_forecast_element.py index 6767cae..45897de 100644 --- a/tests/test_parsers/test_parse_forecast_element.py +++ b/tests/test_parsers/test_parse_forecast_element.py @@ -2,7 +2,7 @@ import pytest -from bmkg.exception import WeatherForecastParseError +from bmkg.exceptions import WeatherForecastParseError from bmkg.parsers import parse_forecast_element diff --git a/tests/test_parsers/test_parse_humidity_element.py b/tests/test_parsers/test_parse_humidity_element.py index 1df1e28..b02fa2b 100644 --- a/tests/test_parsers/test_parse_humidity_element.py +++ b/tests/test_parsers/test_parse_humidity_element.py @@ -2,7 +2,7 @@ import pytest -from bmkg.exception import WeatherForecastParseError +from bmkg.exceptions import WeatherForecastParseError from bmkg.parsers import parse_humidity_element diff --git a/tests/test_parsers/test_parse_issue_element.py b/tests/test_parsers/test_parse_issue_element.py index 9f3e0f0..453fb59 100644 --- a/tests/test_parsers/test_parse_issue_element.py +++ b/tests/test_parsers/test_parse_issue_element.py @@ -2,7 +2,7 @@ import pytest -from bmkg.exception import WeatherForecastParseError +from bmkg.exceptions import WeatherForecastParseError from bmkg.parsers import parse_issue_element diff --git a/tests/test_parsers/test_parse_temperature_element.py b/tests/test_parsers/test_parse_temperature_element.py index 5b17d8d..fd770aa 100644 --- a/tests/test_parsers/test_parse_temperature_element.py +++ b/tests/test_parsers/test_parse_temperature_element.py @@ -2,7 +2,7 @@ import pytest -from bmkg.exception import WeatherForecastParseError +from bmkg.exceptions import WeatherForecastParseError from bmkg.parsers import parse_temperature_element diff --git a/tests/test_parsers/test_parse_weather_element.py b/tests/test_parsers/test_parse_weather_element.py index 320b07b..9dacd43 100644 --- a/tests/test_parsers/test_parse_weather_element.py +++ b/tests/test_parsers/test_parse_weather_element.py @@ -2,7 +2,7 @@ import pytest -from bmkg.exception import WeatherForecastParseError +from bmkg.exceptions import WeatherForecastParseError from bmkg.parsers import parse_weather_element diff --git a/tests/test_parsers/test_parse_weather_forecast_data.py b/tests/test_parsers/test_parse_weather_forecast_data.py new file mode 100644 index 0000000..295f998 --- /dev/null +++ b/tests/test_parsers/test_parse_weather_forecast_data.py @@ -0,0 +1,42 @@ +import pytest + +from bmkg.exceptions import WeatherForecastParseError +from bmkg.parsers import parse_weather_forecast_data + + +def test_parse_element_with_invalid_attribute(): + with pytest.raises( + WeatherForecastParseError, match="id attribute in parameter tag not found" + ): + parse_weather_forecast_data( + '' + "" + "" + "20240216023745" + "2024" + "02" + "16" + "02" + "37" + "45" + "" + "" + 'Aceh Barat' + 'Kab. Aceh Barat' + '' + "" + "" + "" + "" + ) diff --git a/tests/test_parsers/test_parse_wind_direction_element.py b/tests/test_parsers/test_parse_wind_direction_element.py index bf6445d..b451630 100644 --- a/tests/test_parsers/test_parse_wind_direction_element.py +++ b/tests/test_parsers/test_parse_wind_direction_element.py @@ -2,7 +2,7 @@ import pytest -from bmkg.exception import WeatherForecastParseError +from bmkg.exceptions import WeatherForecastParseError from bmkg.parsers import parse_wind_direction_element diff --git a/tests/test_parsers/test_parse_wind_speed_element.py b/tests/test_parsers/test_parse_wind_speed_element.py index 9cc99fa..8c5ff3d 100644 --- a/tests/test_parsers/test_parse_wind_speed_element.py +++ b/tests/test_parsers/test_parse_wind_speed_element.py @@ -2,7 +2,7 @@ import pytest -from bmkg.exception import WeatherForecastParseError +from bmkg.exceptions import WeatherForecastParseError from bmkg.parsers import parse_wind_speed_element