square-administration 3.2.0__py3-none-any.whl → 3.2.2__py3-none-any.whl

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.
@@ -10,8 +10,12 @@ try:
10
10
  config_file_path = os.path.join(
11
11
  os.path.dirname(os.path.abspath(__file__)), "data", "config.ini"
12
12
  )
13
- ldict_configuration = ConfigReader(config_file_path).read_configuration()
14
-
13
+ config_sample_file_path = os.path.join(
14
+ os.path.dirname(os.path.abspath(__file__)), "data", "config.sample.ini"
15
+ )
16
+ ldict_configuration = ConfigReader(
17
+ config_file_path, config_sample_file_path
18
+ ).read_configuration()
15
19
  # get all vars and typecast
16
20
  # ===========================================
17
21
  # general
@@ -23,6 +27,9 @@ try:
23
27
  # environment
24
28
  config_str_host_ip = ldict_configuration["ENVIRONMENT"]["HOST_IP"]
25
29
  config_int_host_port = int(ldict_configuration["ENVIRONMENT"]["HOST_PORT"])
30
+ config_list_allow_origins = eval(
31
+ ldict_configuration["ENVIRONMENT"]["ALLOW_ORIGINS"]
32
+ )
26
33
  config_str_log_file_name = ldict_configuration["ENVIRONMENT"]["LOG_FILE_NAME"]
27
34
  config_str_admin_password_hash = ldict_configuration["ENVIRONMENT"][
28
35
  "ADMIN_PASSWORD_HASH"
@@ -36,11 +43,8 @@ try:
36
43
  ]
37
44
  config_str_cookie_domain = ldict_configuration["ENVIRONMENT"]["COOKIE_DOMAIN"]
38
45
  config_str_db_ip = ldict_configuration["ENVIRONMENT"]["DB_IP"]
39
-
40
46
  config_int_db_port = int(ldict_configuration["ENVIRONMENT"]["DB_PORT"])
41
-
42
47
  config_str_db_username = ldict_configuration["ENVIRONMENT"]["DB_USERNAME"]
43
-
44
48
  config_str_db_password = ldict_configuration["ENVIRONMENT"]["DB_PASSWORD"]
45
49
  # ===========================================
46
50
 
@@ -5,6 +5,7 @@ APP_NAME = square_admin
5
5
  [ENVIRONMENT]
6
6
  HOST_IP = 0.0.0.0
7
7
  HOST_PORT = 10111
8
+ ALLOW_ORIGINS = ["http://localhost:10111"]
8
9
 
9
10
  LOG_FILE_NAME = square_administration
10
11
 
@@ -5,6 +5,7 @@ APP_NAME = square_admin
5
5
  [ENVIRONMENT]
6
6
  HOST_IP = 0.0.0.0
7
7
  HOST_PORT = 10111
8
+ ALLOW_ORIGINS = ["http://localhost:10111"]
8
9
 
9
10
  LOG_FILE_NAME = square_administration
10
11
 
@@ -11,6 +11,7 @@ from square_administration.configuration import (
11
11
  config_str_module_name,
12
12
  config_str_ssl_key_file_path,
13
13
  config_str_ssl_crt_file_path,
14
+ config_list_allow_origins,
14
15
  )
15
16
  from square_administration.routes import core, authentication
16
17
  from square_administration.utils.common import is_https
@@ -20,7 +21,7 @@ app = FastAPI()
20
21
  app.add_middleware(
21
22
  CORSMiddleware,
22
23
  allow_credentials=True,
23
- allow_origins=["*"],
24
+ allow_origins=config_list_allow_origins,
24
25
  allow_methods=["*"],
25
26
  allow_headers=["*"],
26
27
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: square-administration
3
- Version: 3.2.0
3
+ Version: 3.2.2
4
4
  Summary: common business layer for my personal server.
5
5
  Home-page: https://github.com/thepmsquare/square_administration
6
6
  Author: thePmSquare
@@ -20,7 +20,7 @@ Requires-Dist: requests>=2.32.3
20
20
  Requires-Dist: bcrypt>=4.2.0
21
21
  Requires-Dist: pytest>=8.0.0
22
22
  Requires-Dist: httpx>=0.27.2
23
- Requires-Dist: square-commons>=1.0.0
23
+ Requires-Dist: square-commons>=2.1.0
24
24
  Requires-Dist: square-logger>=2.0.0
25
25
  Requires-Dist: square-database-helper>=2.0.0
26
26
  Requires-Dist: square-database-structure>=1.0.0
@@ -44,6 +44,17 @@ pip install square_administration
44
44
 
45
45
  ## changelog
46
46
 
47
+ ### v3.2.2
48
+
49
+ - remove config.ini and config.testing.ini from version control.
50
+
51
+ ### v3.2.1
52
+
53
+ - testing
54
+ - update get_patched_configuration and create_client_and_cleanup to be session scoped.
55
+ - env
56
+ - add ALLOW_ORIGINS
57
+
47
58
  ### v3.2.0
48
59
 
49
60
  - move global_int_app_id getting logic from configuration.py to utils->common
@@ -1,9 +1,9 @@
1
1
  square_administration/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- square_administration/configuration.py,sha256=u3MB-vHaKMIPz0ccBrgehRNdC3wvhn06XNxEEnCM284,4332
3
- square_administration/main.py,sha256=jQqoNCfO4X6U8GoqEzn8BD9FhSPRM8PXMptv7uIPTKs,1609
2
+ square_administration/configuration.py,sha256=GoeYwDL3EQeInUdGPEKCT9UvA1wY45o-CGVO4OMGvrk,4601
3
+ square_administration/main.py,sha256=vvKBMn4JkDp8B2L_zwBMIfYaSA41rXxhL3ZFsSv8ly8,1660
4
4
  square_administration/messages.py,sha256=VYjJGW0Kvtjrx1Mw7ekksLVMoxcexLol2OckvqhZ3n0,1063
5
- square_administration/data/config.ini,sha256=mPO_mTQU2RT3d6re-SY7Ip7zcUXjxehCRntN857ncMw,1102
6
- square_administration/data/config.testing.ini,sha256=byHvkFGaShkU-Oh0DBa5w1mbT284PlQV_8mqY4hsnis,1150
5
+ square_administration/data/config.sample.ini,sha256=kkSbjJP7qR8ah44Oyv2IyCgYfmheYYh4zSU7wD7v3ec,1145
6
+ square_administration/data/config.testing.sample.ini,sha256=vdW01yJdCqdI6uK-jXHfWa9B9IJVuecYdx0n3y7dS2k,1193
7
7
  square_administration/pydantic_models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  square_administration/pydantic_models/authentication.py,sha256=QEfM5ezG45hc_qATXpFIPNPl4bjf8ICW_bY5tY4cqO4,259
9
9
  square_administration/pydantic_models/core.py,sha256=HUMrBmfKrXeL-126gE5j2povdVmktn8XLg2tHEdeXTk,344
@@ -13,9 +13,9 @@ square_administration/routes/core.py,sha256=H5pfPuPDzSn8-HN40gyI7eDVxFW7821urYq0
13
13
  square_administration/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
14
  square_administration/utils/common.py,sha256=bnyBF10EDMLIYXnfV3ZZOApNKScHRmw-Jcj2zIFE8kE,1157
15
15
  tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
- tests/conftest.py,sha256=KJoXQBlfbyyep60EDWAzLMhV1QpWezPmCGE6FCF7JVE,1767
16
+ tests/conftest.py,sha256=pqL3wk-mb_DPjtTHXWtIcYqVDXqhtM77xFPl3ljbLiw,2010
17
17
  tests/test_1.py,sha256=hikxL01-2dcax594y8ceanjRmLJXvuhLpcY-FMPIdY8,378
18
- square_administration-3.2.0.dist-info/METADATA,sha256=2hiyaCyFxPbFZiQ2w38Mrzi9w6qHbAsRPNVfTJhnXOM,2867
19
- square_administration-3.2.0.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
20
- square_administration-3.2.0.dist-info/top_level.txt,sha256=tyroqpdXXQAiA7Y_V1wCqPPt6nnS_orcY9txLeHjm1s,28
21
- square_administration-3.2.0.dist-info/RECORD,,
18
+ square_administration-3.2.2.dist-info/METADATA,sha256=H5l0VGeSCGUz5HrNC2SReTiSjlmYXg9uQGpWmPEbmn4,3089
19
+ square_administration-3.2.2.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
20
+ square_administration-3.2.2.dist-info/top_level.txt,sha256=tyroqpdXXQAiA7Y_V1wCqPPt6nnS_orcY9txLeHjm1s,28
21
+ square_administration-3.2.2.dist-info/RECORD,,
tests/conftest.py CHANGED
@@ -1,30 +1,36 @@
1
+ import importlib
1
2
  import os
2
3
 
3
4
  import pytest
4
5
  from fastapi.testclient import TestClient
5
6
 
6
7
 
7
- def patched_join(*args):
8
+ @pytest.fixture(scope="session")
9
+ def get_patched_configuration():
10
+ def patched_join(*args):
11
+ *rest, last = args
12
+ if last == "config.ini":
13
+ last = "config.testing.ini"
14
+ elif last == "config.sample.ini":
15
+ last = "config.testing.sample.ini"
8
16
 
9
- *rest, last = args
10
- if last == "config.ini":
11
- last = "config.testing.ini"
17
+ return original_join(*rest, last)
12
18
 
13
- return original_join(*rest, last)
19
+ original_join = os.path.join
20
+ os.path.join = patched_join
14
21
 
22
+ import square_administration.configuration
15
23
 
16
- original_join = os.path.join
17
-
24
+ importlib.reload(square_administration.configuration)
25
+ config = square_administration.configuration
18
26
 
19
- @pytest.fixture
20
- def get_patched_configuration(monkeypatch, tmp_path):
21
- monkeypatch.setattr(os.path, "join", patched_join)
22
- import square_administration.configuration
27
+ yield config
23
28
 
24
- return square_administration.configuration
29
+ # cleanup
30
+ os.path.join = original_join
25
31
 
26
32
 
27
- @pytest.fixture
33
+ @pytest.fixture(scope="session")
28
34
  def create_client_and_cleanup(get_patched_configuration):
29
35
  from square_database_structure import create_database_and_tables
30
36