Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
pmayd committed Dec 4, 2024
2 parents 285e625 + 91311f5 commit e8cb060
Show file tree
Hide file tree
Showing 8 changed files with 155 additions and 145 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
sudo apt-get update
sudo apt-get install -y pandoc
- name: Run poetry image
uses: abatilo/[email protected].0
uses: abatilo/[email protected].1
with:
poetry-version: ${{ vars.POETRY_VERSION }}
- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-to-pypi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Run poetry image
uses: abatilo/[email protected].0
uses: abatilo/[email protected].1
with:
poetry-version: ${{ vars.POETRY_VERSION }}
- name: Publish to PyPI and build before
Expand Down
23 changes: 9 additions & 14 deletions .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Run poetry image
uses: abatilo/[email protected].0
uses: abatilo/[email protected].1
with:
poetry-version: ${{ vars.POETRY_VERSION }}
- name: Install dependencies
Expand All @@ -58,26 +58,21 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Run poetry image
uses: abatilo/[email protected].0
uses: abatilo/[email protected].1
with:
poetry-version: ${{ vars.POETRY_VERSION }}
- name: Install dependencies
run: poetry install --with dev
- name: Run black
run: poetry run black . --check
- name: Run isort
run: poetry run isort . --check-only
- name: Run flake8
run: poetry run flake8 src --output-file=flake8_report.txt
- name: Run pylint
run: poetry run pylint src --recursive=y
- name: Ruff format check
run: poetry run ruff format --check src
- name: Ruff lint check
run: poetry run ruff check src
- name: Run bandit
run: poetry run bandit -r src
- name: Run Safety CLI to check for vulnerabilities
uses: pyupio/safety-action@v1
uses: pyupio/safety-action@v1.0.1
with:
api-key: ${{ secrets.SAFETY_API_KEY }}
continue-on-error: true # Do not fail this action if vulnerabilities are found
args: "--short-report --policy-file=.safety-policy.yml"
- name: Run mypy
run: poetry run mypy src
Expand All @@ -93,7 +88,7 @@ jobs:
with:
python-version: ${{ vars.PYTHON_VERSION}}
- name: Run poetry image
uses: abatilo/[email protected].0
uses: abatilo/[email protected].1
with:
poetry-version: ${{ vars.POETRY_VERSION }}
- name: Install dependencies
Expand All @@ -114,7 +109,7 @@ jobs:
run: |
poetry run pytest --cov=src/pystatis --cov-report=xml --vcr-record=none tests
- name: Upload coverage reports to Codecov with GitHub Action
uses: codecov/codecov-action@v4.5.0
uses: codecov/codecov-action@v5.0.7
with:
verbose: true
env:
Expand Down
252 changes: 126 additions & 126 deletions poetry.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jupyter = "^1.0.0"
jupytext = "^1.16.1"
mypy = "^1.0"
myst-parser = "^4.0.0"
notebook = "^7.3.0"
pre-commit = "^4.0.1"
pylint = "^3.0"
pytest = "^8.0.0"
Expand All @@ -57,7 +58,7 @@ pytest-mock = "^3.8.2"
python-dotenv = "^1.0.0"
requests-toolbelt = "^1.0.0"
sphinx = "^7.0"
sphinx-rtd-theme = "^2.0.0"
sphinx-rtd-theme = "^3.0.0"
urllib3 = { extras = ["appengine"], version = "^2.2.1" }
pytest-vcr = "^1.0.2"
nbsphinx = "^0.9.5"
Expand Down
5 changes: 4 additions & 1 deletion src/pystatis/helloworld.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ def whoami(db_name: str) -> str:
"""
url = f"{db.get_host(db_name)}" + "helloworld/whoami"

response = requests.get(url, timeout=(1, 15))
try:
response = requests.get(url, timeout=(1, 15))
except requests.exceptions.Timeout:
raise TimeoutError("Login request timed out after 15 minutes")

_check_invalid_status_code(response)

Expand Down
2 changes: 1 addition & 1 deletion src/pystatis/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def parse_v4_table(data: pd.DataFrame, language: str) -> pd.DataFrame:
time = pd.DataFrame({data[time_label_col].iloc[-1]: data[time_col]})

# Whenever there is a column with a regional code, we add this column to the final output
# As the position is unknown, we pohave to identify this column by looking for the AGS code
# As the position is unknown, we have to identify this column by looking for the AGS code
ags_codes = list(
set(config.REGIO_AND_GENESIS_AGS_CODES) - set(config.EXCLUDE_AGS_CODES)
)
Expand Down
11 changes: 11 additions & 0 deletions tests/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pytest

from pystatis import config, db
from pystatis.exception import PystatisConfigError


@pytest.fixture()
Expand Down Expand Up @@ -39,6 +40,11 @@ def test_identify_db_matches(config_, name, expected_db):
assert db.identify_db_matches(name)[0] == expected_db


def test_identify_db_matches_no_match(config_):
with pytest.raises(ValueError):
db.identify_db_matches("test")


def test_identify_db_with_multiple_matches(config_):
config_.set("genesis", "username", "test")
config_.set("genesis", "password", "test")
Expand All @@ -57,3 +63,8 @@ def test_identify_db_with_multiple_matches(config_):
if db.check_credentials(db_name):
break
assert db_name == "regio"


def test_select_db_by_credentials(config_):
with pytest.raises(PystatisConfigError):
db.select_db_by_credentials([])

0 comments on commit e8cb060

Please sign in to comment.