plexus-python-common 1.0.36__tar.gz → 1.0.37__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 (83) hide show
  1. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/PKG-INFO +1 -1
  2. plexus_python_common-1.0.37/src/plexus/common/utils/testutils.py +118 -0
  3. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/src/plexus_python_common.egg-info/PKG-INFO +1 -1
  4. plexus_python_common-1.0.36/src/plexus/common/utils/testutils.py +0 -49
  5. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/.editorconfig +0 -0
  6. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/.github/workflows/pr.yml +0 -0
  7. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/.github/workflows/push.yml +0 -0
  8. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/.gitignore +0 -0
  9. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/MANIFEST.in +0 -0
  10. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/README.md +0 -0
  11. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/VERSION +0 -0
  12. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/pyproject.toml +0 -0
  13. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/resources/unittest/jsonutils/dummy.0.jsonl +0 -0
  14. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/resources/unittest/jsonutils/dummy.1.jsonl +0 -0
  15. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/resources/unittest/jsonutils/dummy.2.jsonl +0 -0
  16. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/resources/unittest/s3utils/dir.baz/file.bar.baz +0 -0
  17. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/resources/unittest/s3utils/dir.baz/file.foo.bar +0 -0
  18. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/resources/unittest/s3utils/dir.baz/file.foo.baz +0 -0
  19. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/resources/unittest/s3utils/dir.foo/dir.foo.bar/dir.foo.bar.baz/file.foo.bar.baz +0 -0
  20. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/resources/unittest/s3utils/dir.foo/dir.foo.bar/file.bar.baz +0 -0
  21. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/resources/unittest/s3utils/dir.foo/dir.foo.bar/file.foo.bar +0 -0
  22. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/resources/unittest/s3utils/dir.foo/dir.foo.bar/file.foo.baz +0 -0
  23. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/resources/unittest/s3utils/dir.foo/file.bar +0 -0
  24. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/resources/unittest/s3utils/dir.foo/file.baz +0 -0
  25. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/resources/unittest/s3utils/dir.foo/file.foo +0 -0
  26. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/resources/unittest/s3utils_archive/archive.compressed.zip +0 -0
  27. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/resources/unittest/s3utils_archive/archive.uncompressed.zip +0 -0
  28. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/resources/unittest/shutils/0-dummy +0 -0
  29. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/resources/unittest/shutils/1-dummy +0 -0
  30. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/resources/unittest/shutils/2-dummy +0 -0
  31. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/resources/unittest/shutils/dummy.0.0.jsonl +0 -0
  32. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/resources/unittest/shutils/dummy.0.0.vol-0.jsonl +0 -0
  33. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/resources/unittest/shutils/dummy.0.jsonl +0 -0
  34. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/resources/unittest/shutils/dummy.1.1.jsonl +0 -0
  35. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/resources/unittest/shutils/dummy.1.1.vol-1.jsonl +0 -0
  36. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/resources/unittest/shutils/dummy.1.jsonl +0 -0
  37. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/resources/unittest/shutils/dummy.2.2.jsonl +0 -0
  38. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/resources/unittest/shutils/dummy.2.2.vol-2.jsonl +0 -0
  39. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/resources/unittest/shutils/dummy.2.jsonl +0 -0
  40. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/resources/unittest/shutils/dummy.csv.part0 +0 -0
  41. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/resources/unittest/shutils/dummy.csv.part1 +0 -0
  42. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/resources/unittest/shutils/dummy.csv.part2 +0 -0
  43. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/resources/unittest/shutils/dummy.txt +0 -0
  44. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/setup.cfg +0 -0
  45. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/setup.py +0 -0
  46. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/src/plexus/common/__init__.py +0 -0
  47. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/src/plexus/common/carto/OSMFile.py +0 -0
  48. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/src/plexus/common/carto/OSMNode.py +0 -0
  49. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/src/plexus/common/carto/OSMTags.py +0 -0
  50. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/src/plexus/common/carto/OSMWay.py +0 -0
  51. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/src/plexus/common/carto/__init__.py +0 -0
  52. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/src/plexus/common/pose.py +0 -0
  53. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/src/plexus/common/proj.py +0 -0
  54. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/src/plexus/common/utils/__init__.py +0 -0
  55. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/src/plexus/common/utils/apiutils.py +0 -0
  56. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/src/plexus/common/utils/bagutils.py +0 -0
  57. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/src/plexus/common/utils/config.py +0 -0
  58. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/src/plexus/common/utils/datautils.py +0 -0
  59. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/src/plexus/common/utils/jsonutils.py +0 -0
  60. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/src/plexus/common/utils/ormutils.py +0 -0
  61. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/src/plexus/common/utils/s3utils.py +0 -0
  62. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/src/plexus/common/utils/shutils.py +0 -0
  63. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/src/plexus/common/utils/sqlutils.py +0 -0
  64. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/src/plexus/common/utils/strutils.py +0 -0
  65. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/src/plexus_python_common.egg-info/SOURCES.txt +0 -0
  66. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/src/plexus_python_common.egg-info/dependency_links.txt +0 -0
  67. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/src/plexus_python_common.egg-info/not-zip-safe +0 -0
  68. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/src/plexus_python_common.egg-info/requires.txt +0 -0
  69. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/src/plexus_python_common.egg-info/top_level.txt +0 -0
  70. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/test/plexus_test.py +0 -0
  71. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/test/plexus_tests/__init__.py +0 -0
  72. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/test/plexus_tests/common/carto/osm_file_test.py +0 -0
  73. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/test/plexus_tests/common/carto/osm_tags_test.py +0 -0
  74. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/test/plexus_tests/common/pose_test.py +0 -0
  75. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/test/plexus_tests/common/proj_test.py +0 -0
  76. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/test/plexus_tests/common/utils/bagutils_test.py +0 -0
  77. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/test/plexus_tests/common/utils/datautils_test.py +0 -0
  78. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/test/plexus_tests/common/utils/jsonutils_test.py +0 -0
  79. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/test/plexus_tests/common/utils/ormutils_test.py +0 -0
  80. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/test/plexus_tests/common/utils/s3utils_test.py +0 -0
  81. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/test/plexus_tests/common/utils/shutils_test.py +0 -0
  82. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/test/plexus_tests/common/utils/strutils_test.py +0 -0
  83. {plexus_python_common-1.0.36 → plexus_python_common-1.0.37}/test/plexus_tests/common/utils/testutils_test.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plexus-python-common
3
- Version: 1.0.36
3
+ Version: 1.0.37
4
4
  Classifier: Programming Language :: Python :: 3
5
5
  Classifier: Programming Language :: Python :: 3.12
6
6
  Classifier: Programming Language :: Python :: 3.13
@@ -0,0 +1,118 @@
1
+ import uuid as py_uuid
2
+ from collections.abc import Callable, Generator, Iterator
3
+
4
+ import pytest
5
+ import sqlalchemy as sa
6
+ import sqlalchemy.orm as sa_orm
7
+ import textcase
8
+ from fastapi import FastAPI
9
+ from iker.common.utils.dbutils import ConnectionMaker, Dialects, Drivers
10
+ from iker.common.utils.dbutils import make_scheme
11
+ from iker.common.utils.jsonutils import JsonType
12
+ from iker.common.utils.jsonutils import json_difference, json_reformat
13
+ from sqlmodel import SQLModel
14
+
15
+ from plexus.common.utils.datautils import compute_vin_code_check_digit
16
+
17
+ __all__ = [
18
+ "generate_dummy_uuid_str",
19
+ "generate_dummy_uuid",
20
+ "generate_dummy_vin_code",
21
+ "case_insensitive_json_compare",
22
+ "make_postgresql_patched_session_maker_fixture",
23
+ ]
24
+
25
+
26
+ def generate_dummy_uuid_str(*nums: int) -> str:
27
+ if len(nums) > 8:
28
+ raise ValueError("a maximum of 8 integers can be provided")
29
+ if not all(0 <= num <= 0xFFFF for num in nums):
30
+ raise ValueError("all integers must be in the range 0 to 65535 (0xFFFF)")
31
+ i0, i1, i2, i3, i4, i5, i6, i7 = list(nums) + [0] * (8 - len(nums))
32
+ return f"{i0:04x}{i1:04x}-{i2:04x}-{i3:04x}-{i4:04x}-{i5:04x}{i6:04x}{i7:04x}"
33
+
34
+
35
+ def generate_dummy_uuid(*nums: int) -> py_uuid.UUID:
36
+ return py_uuid.UUID(generate_dummy_uuid_str(*nums))
37
+
38
+
39
+ def generate_dummy_vin_code(*nums: int) -> str:
40
+ if len(nums) > 4:
41
+ raise ValueError("a maximum of 4 integers can be provided")
42
+ if not all(0 <= num <= 9999 for num in nums):
43
+ raise ValueError("all integers must be in the range 0 to 9999")
44
+ i0, i1, i2, i3 = list(nums) + [0] * (4 - len(nums))
45
+ unchecked_vin_code = f"{i0:04d}{i1:04d}0{i2:04d}{i3:04d}"
46
+ check_digit = compute_vin_code_check_digit(unchecked_vin_code)
47
+ return unchecked_vin_code[:8] + check_digit + unchecked_vin_code[-8:]
48
+
49
+
50
+ def case_insensitive_json_compare(a: JsonType, b: JsonType, *, print_diff_messages: bool = True) -> bool:
51
+ identical = True
52
+ for node_path, diff_message in json_difference(json_reformat(a, key_formatter=textcase.camel),
53
+ json_reformat(b, key_formatter=textcase.camel),
54
+ []):
55
+ if print_diff_messages:
56
+ print(node_path, diff_message)
57
+ identical = False
58
+ return identical
59
+
60
+
61
+ def make_postgresql_patched_session_maker_fixture(
62
+ postgresql_test_fixture_name: str,
63
+ base_model: type[SQLModel],
64
+ app: FastAPI,
65
+ session_maker: Callable[[], Generator[sa_orm.Session]],
66
+ ) -> Callable[[pytest.FixtureRequest], Generator[Callable[[], Iterator[sa_orm.Session]]]]:
67
+ """
68
+ Create a pytest fixture that provides a patched session maker for PostgreSQL tests.
69
+
70
+ :param postgresql_test_fixture_name: Name of the PostgreSQL test fixture to use.
71
+ :param base_model: The base SQLModel model containing metadata.
72
+ :param app: FastAPI application instance.
73
+ :param session_maker: Original session maker to be overridden.
74
+ :return: A pytest fixture function.
75
+ """
76
+
77
+ @pytest.fixture(scope="function")
78
+ def fixture(request: pytest.FixtureRequest):
79
+ postgresql_test_fixture = request.getfixturevalue(postgresql_test_fixture_name)
80
+
81
+ cm = ConnectionMaker.create(
82
+ scheme=make_scheme(Dialects.postgresql, Drivers.psycopg),
83
+ host=postgresql_test_fixture.info.host,
84
+ port=postgresql_test_fixture.info.port,
85
+ username=postgresql_test_fixture.info.user,
86
+ password="",
87
+ database=postgresql_test_fixture.info.dbname,
88
+ )
89
+
90
+ def make_session_maker() -> Iterator[sa_orm.Session]:
91
+ with cm.make_session(autocommit=False, autoflush=False) as db:
92
+ try:
93
+ # language=postgresql
94
+ db.execute(sa.sql.text("SET TIMEZONE TO 'UTC'"))
95
+ yield db
96
+ finally:
97
+ db.close()
98
+
99
+ app.dependency_overrides[session_maker] = make_session_maker
100
+
101
+ with cm.make_session() as session:
102
+ for table in base_model.metadata.tables.values():
103
+ session.execute(sa.schema.CreateSchema(table.schema, if_not_exists=True))
104
+ session.commit()
105
+ base_model.metadata.create_all(cm.engine)
106
+
107
+ try:
108
+ yield make_session_maker
109
+ finally:
110
+ base_model.metadata.drop_all(cm.engine)
111
+ with cm.make_session() as session:
112
+ for table in base_model.metadata.tables.values():
113
+ session.execute(sa.schema.DropSchema(table.schema, if_exists=True))
114
+ session.commit()
115
+
116
+ app.dependency_overrides[session_maker] = session_maker
117
+
118
+ return fixture
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plexus-python-common
3
- Version: 1.0.36
3
+ Version: 1.0.37
4
4
  Classifier: Programming Language :: Python :: 3
5
5
  Classifier: Programming Language :: Python :: 3.12
6
6
  Classifier: Programming Language :: Python :: 3.13
@@ -1,49 +0,0 @@
1
- import uuid as py_uuid
2
-
3
- import textcase
4
- from iker.common.utils.jsonutils import JsonType
5
- from iker.common.utils.jsonutils import json_difference, json_reformat
6
-
7
- from plexus.common.utils.datautils import compute_vin_code_check_digit
8
-
9
- __all__ = [
10
- "generate_dummy_uuid_str",
11
- "generate_dummy_uuid",
12
- "generate_dummy_vin_code",
13
- "case_insensitive_json_compare",
14
- ]
15
-
16
-
17
- def generate_dummy_uuid_str(*nums: int) -> str:
18
- if len(nums) > 8:
19
- raise ValueError("a maximum of 8 integers can be provided")
20
- if not all(0 <= num <= 0xFFFF for num in nums):
21
- raise ValueError("all integers must be in the range 0 to 65535 (0xFFFF)")
22
- i0, i1, i2, i3, i4, i5, i6, i7 = list(nums) + [0] * (8 - len(nums))
23
- return f"{i0:04x}{i1:04x}-{i2:04x}-{i3:04x}-{i4:04x}-{i5:04x}{i6:04x}{i7:04x}"
24
-
25
-
26
- def generate_dummy_uuid(*nums: int) -> py_uuid.UUID:
27
- return py_uuid.UUID(generate_dummy_uuid_str(*nums))
28
-
29
-
30
- def generate_dummy_vin_code(*nums: int) -> str:
31
- if len(nums) > 4:
32
- raise ValueError("a maximum of 4 integers can be provided")
33
- if not all(0 <= num <= 9999 for num in nums):
34
- raise ValueError("all integers must be in the range 0 to 9999")
35
- i0, i1, i2, i3 = list(nums) + [0] * (4 - len(nums))
36
- unchecked_vin_code = f"{i0:04d}{i1:04d}0{i2:04d}{i3:04d}"
37
- check_digit = compute_vin_code_check_digit(unchecked_vin_code)
38
- return unchecked_vin_code[:8] + check_digit + unchecked_vin_code[-8:]
39
-
40
-
41
- def case_insensitive_json_compare(a: JsonType, b: JsonType, *, print_diff_messages: bool = True) -> bool:
42
- identical = True
43
- for node_path, diff_message in json_difference(json_reformat(a, key_formatter=textcase.camel),
44
- json_reformat(b, key_formatter=textcase.camel),
45
- []):
46
- if print_diff_messages:
47
- print(node_path, diff_message)
48
- identical = False
49
- return identical