Commit graph velofy/tests
Author SHA1 Message Date
7d53abc057
Avoid lazy loads in .__repr__()
`ReplaySimulation`, `ReplayedOrder`, and `Forecast` accessed
relationships in their `.__repr__()`, which emits queries
or fails for detached instances.

They now use the foreign key columns.
2026-12-01 22:34:38 +01:00
f532aae588
Test grids with the same side length in different cities
Regression test for the removed `unique=True` on `Grid.side_length`.
2026-12-01 22:20:06 +01:00
5f7d3108de
Check the type annotations at runtime with typeguard 2026-12-01 17:07:00 +01:00
893b6bd8f1
Seed the random fake data in the tests 2026-12-01 15:51:24 +01:00
e4711875ca
Use a pd.DataFrame as the sentinel in test_totals_is_cached 2026-12-01 15:46:54 +01:00
8abc93987e
Generate the fake coordinates as floats
Also, remove the misleading comment in `Location`
2026-12-01 15:27:53 +01:00
77806b14b9
Declare the name of the forecasting models as a class variable 2026-12-01 14:45:37 +01:00
784d5c8ca0
Enable "warn_unreachable"
Also, remove the dead `isinstance()` check in `Location.relate_to()`
2026-12-01 13:07:53 +01:00
0090145b65
Capitalize the explanations after "=>" 2026-11-30 23:27:31 +01:00
c56fe649b7
Enable RUF in ruff 2026-11-30 23:17:41 +01:00
ae2dc8db64
Enable EM in flake8 and ruff 2026-11-30 22:59:41 +01:00
5beb88559f
Enable FBT in flake8 and ruff 2026-11-30 22:43:35 +01:00
99dda74a9e
Enable PL in ruff 2026-11-30 22:28:12 +01:00
95f08bc96d
Enable PD in flake8 and ruff 2026-11-30 22:11:10 +01:00
3bd7dd5772
Enable RET in flake8 and ruff 2026-11-30 22:06:42 +01:00
007998372f
Enable SIM in flake8 and ruff 2026-11-30 22:06:41 +01:00
cf2534f41e
Import velofy.config as pkg_config everywhere 2026-11-30 20:19:35 +01:00
de5e49b497
Import alembic.config as alembic_config 2026-11-30 20:13:46 +01:00
dc45c689c4
Import alembic.command as alembic_cmd 2026-11-30 20:12:41 +01:00
07e90b7851
Import click.testing as cli_testing
Like `click.core` as `cli_core`
2026-11-30 20:01:43 +01:00
07660ecff9
Import geopy.distance as geo_distance everywhere 2026-11-30 20:01:42 +01:00
d660f0cc4e
Import googlemaps as gm everywhere 2026-11-30 20:01:41 +01:00
5ca16ae47c
Import datetime as dt everywhere 2026-11-30 15:50:17 +01:00
aa1a7c796f
Register the shared fixtures via pytest_plugins
That is the documented way to share fixtures from other modules,
instead of importing them into tests/conftest.py
2026-11-30 15:03:27 +01:00
e30b3efbe8
Use the sa alias for sqlalchemy everywhere
`sa` is the common alias, also in SQLAlchemy's own documentation
2026-11-30 14:18:05 +01:00
2b112f46e2
Remove the no longer used engine and connection globals
All checks were successful
CI / Checks (Python 3.13) (push) Successful in 1m52s
Only `session` is used in the package.
Bound to the `engine`, it connects on its first query
instead of when the package is imported.
2026-11-30 14:03:26 +01:00
e9dbf528d7
Query order history via the db.session
The query then runs in the same transaction as the `db.session`

For that, `addresses_mock` now replaces only `session.query()`
instead of the whole `db.session`.
2026-11-30 13:59:34 +01:00
607055d55a
Raise an error if Path._directions is not set ...
... instead of failing inside `json.loads()` on `None`
2026-11-30 12:50:31 +01:00
744d9a6353
Raise an error if an Order timestamp is not set
Like `Order.time_to_delivery` already does,
instead of failing with a `TypeError` on `None`
2026-11-30 12:43:33 +01:00
ee5a372b2b
Link new objects from the parent
Since SQLAlchemy 2.0, only the parent's end
cascades a new object into the session'
2026-11-30 10:40:27 +01:00
87aaebe475
Join the session into the outer transaction
With "create_savepoint", commits inside a test case
only release a savepoint, so the final rollback no longer warns
2026-11-30 10:24:10 +01:00
a24db98262
Enable PLR in ruff
All checks were successful
CI / Checks (Python 3.13) (push) Successful in 1m43s
2026-11-28 04:57:25 +01:00
e451f03d0f
Add ruff to the "format" session
`ruff format` adds parentheses around multi-line lambda bodies
and removes blank lines after block openers,
both of which `black` accepts.

Lines with `# type:ignore` are shortened
because `black` counts pragma comments toward the line length
and `ruff` does not.
2026-11-28 04:44:52 +01:00
4a81403f15
Replace darglint with pydoclint 2026-11-28 04:06:53 +01:00
afe8b3ce90
Apply shared fixtures to whole test classes 2026-11-28 03:52:11 +01:00
882d3c98ba
Add flake8-unused-arguments
- Request fixtures only needed for their side effects
  via `@pytest.mark.usefixtures()` instead of as arguments
- Remove fixtures that a test does not use at all
- Exempt abstract methods because their arguments define an interface
2026-11-28 03:48:50 +01:00
ea8f1a13e3
Use double quotes 2026-11-28 03:26:13 +01:00
7b32ffc599
Add flake8-docstrings 2026-11-28 03:26:12 +01:00
7f14c9c855
Add flake8-commas 2026-11-28 03:26:11 +01:00
137b3b1e03
Remove the config of flake8-expression-complexity 2026-11-28 03:26:10 +01:00
13eedbf699
Remove the config of flake8-rst-docstrings 2026-11-28 03:26:10 +01:00
9fcb3c8c14
Remove all "WPS" codes 2026-11-28 03:25:20 +01:00
03617d5bbb
Move the pytest config 2026-11-25 15:03:34 +01:00
705955b38b
Upgrade pandas
Also, replace the deprecated "T" frequency alias with "min",
and access the trend by position with `.iloc`.
2026-11-25 13:16:55 +01:00
c310c335ff
Upgrade click
Since `click` v8.2, a `Group` invoked without a subcommand
exits with status code 2 ("usage error") instead of 0.
2026-11-25 12:45:59 +01:00
042256eb99
Switch to Python 3.13
All checks were successful
CI / Tests (Python 3.13) (push) Successful in 1m17s
The dependencies stay in the same series as on Python 3.8
where those support 3.13.

Only the unavoidable upgrades are taken:
 - `matplotlib` to v3.9
 - `numpy` to v2.1
 - `pandas` to v2.2
 - `scipy` (via statsmodels)

Required code changes:
- `numpy` v2.1 prints its scalars as `np.float64(...)`,
  which `psycopg2` then writes into the SQL
  => Adjust `Forecast.from_dataframe()` to convert the
     rounded values into plain `float`s
- Python 3.12 no longer accepts `float`s in `random.randint()`
  => The test factories now pass the seconds as `int`s

CI and `nox` use a `u`v-managed Python, which ships the C headers
needed to build `psycopg2` and `rpy2`.

`flake8` v4 does not run on Python 3.12+
and is upgraded in a future commit.
2026-11-25 11:30:33 +01:00
dbdce83067
Upgrade black 2026-11-25 10:30:47 +01:00
c895078837
Upgrade pytest 2026-11-24 17:24:43 +01:00
e94ade4c88
Upgrade wemake-python-styleguide 2026-11-24 17:24:42 +01:00
793f3105b1
Use sa.text() 2026-11-24 17:24:41 +01:00