splent-framework 0.0.1__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 (42) hide show
  1. splent_framework-0.0.1/LICENSE +113 -0
  2. splent_framework-0.0.1/PKG-INFO +144 -0
  3. splent_framework-0.0.1/README.md +1 -0
  4. splent_framework-0.0.1/pyproject.toml +40 -0
  5. splent_framework-0.0.1/setup.cfg +4 -0
  6. splent_framework-0.0.1/splent_framework/_init__.py +0 -0
  7. splent_framework-0.0.1/splent_framework/core/__init__.py +0 -0
  8. splent_framework-0.0.1/splent_framework/core/blueprints/__init__.py +0 -0
  9. splent_framework-0.0.1/splent_framework/core/blueprints/base_blueprint.py +76 -0
  10. splent_framework-0.0.1/splent_framework/core/bootstraps/__init__.py +0 -0
  11. splent_framework-0.0.1/splent_framework/core/bootstraps/locustfile_bootstrap.py +50 -0
  12. splent_framework-0.0.1/splent_framework/core/configuration/__init__.py +0 -0
  13. splent_framework-0.0.1/splent_framework/core/configuration/configuration.py +25 -0
  14. splent_framework-0.0.1/splent_framework/core/decorators/__init__.py +0 -0
  15. splent_framework-0.0.1/splent_framework/core/decorators/decorators.py +18 -0
  16. splent_framework-0.0.1/splent_framework/core/environment/__init__.py +0 -0
  17. splent_framework-0.0.1/splent_framework/core/environment/host.py +65 -0
  18. splent_framework-0.0.1/splent_framework/core/locust/__init__.py +0 -0
  19. splent_framework-0.0.1/splent_framework/core/locust/common.py +14 -0
  20. splent_framework-0.0.1/splent_framework/core/managers/__init__.py +0 -0
  21. splent_framework-0.0.1/splent_framework/core/managers/config_manager.py +65 -0
  22. splent_framework-0.0.1/splent_framework/core/managers/error_handler_manager.py +27 -0
  23. splent_framework-0.0.1/splent_framework/core/managers/logging_manager.py +33 -0
  24. splent_framework-0.0.1/splent_framework/core/managers/module_manager.py +119 -0
  25. splent_framework-0.0.1/splent_framework/core/managers/task_queue_manager.py +52 -0
  26. splent_framework-0.0.1/splent_framework/core/repositories/BaseRepository.py +65 -0
  27. splent_framework-0.0.1/splent_framework/core/repositories/__init__.py +0 -0
  28. splent_framework-0.0.1/splent_framework/core/resources/__init__.py +0 -0
  29. splent_framework-0.0.1/splent_framework/core/resources/generic_resource.py +79 -0
  30. splent_framework-0.0.1/splent_framework/core/seeders/BaseSeeder.py +60 -0
  31. splent_framework-0.0.1/splent_framework/core/seeders/__init__.py +0 -0
  32. splent_framework-0.0.1/splent_framework/core/selenium/__init__.py +0 -0
  33. splent_framework-0.0.1/splent_framework/core/selenium/common.py +17 -0
  34. splent_framework-0.0.1/splent_framework/core/serialisers/__init__.py +0 -0
  35. splent_framework-0.0.1/splent_framework/core/serialisers/serializer.py +34 -0
  36. splent_framework-0.0.1/splent_framework/core/services/BaseService.py +42 -0
  37. splent_framework-0.0.1/splent_framework/core/services/__init__.py +0 -0
  38. splent_framework-0.0.1/splent_framework.egg-info/PKG-INFO +144 -0
  39. splent_framework-0.0.1/splent_framework.egg-info/SOURCES.txt +40 -0
  40. splent_framework-0.0.1/splent_framework.egg-info/dependency_links.txt +1 -0
  41. splent_framework-0.0.1/splent_framework.egg-info/requires.txt +18 -0
  42. splent_framework-0.0.1/splent_framework.egg-info/top_level.txt +1 -0
@@ -0,0 +1,113 @@
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc.
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+ Preamble
9
+
10
+ The GNU General Public License is a free, copyleft license for
11
+ software and other kinds of works.
12
+
13
+ The licenses for most software and other practical works are designed
14
+ to take away your freedom to share and change the works. By contrast,
15
+ the GNU General Public License is intended to guarantee your freedom to
16
+ share and change all versions of a program--to make sure it remains free
17
+ software for all its users. We, the Free Software Foundation, use the
18
+ GNU General Public License for most of our software; it applies also to
19
+ any other work released this way by its authors. You can apply it to
20
+ your programs, too.
21
+
22
+ When we speak of free software, we are referring to freedom, not
23
+ price. Our General Public Licenses are designed to make sure that you
24
+ have the freedom to distribute copies of free software (and charge for
25
+ them if you wish), that you receive source code or can get it if you
26
+ want it, that you can change the software or use pieces of it in new
27
+ free programs, and that you know you can do these things.
28
+
29
+ To protect your rights, we need to prevent others from denying you
30
+ these rights or asking you to surrender the rights. Therefore, you have
31
+ certain responsibilities if you distribute copies of the software, or if
32
+ you modify it: responsibilities to respect the freedom of others.
33
+
34
+ For example, if you distribute copies of such a program, whether
35
+ gratis or for a fee, you must pass on to the recipients the same
36
+ freedoms that you received. You must make sure that they, too, receive
37
+ or can get the source code. And you must show them these terms so they
38
+ know their rights.
39
+
40
+ Developers that use the GNU GPL protect your rights with two steps:
41
+ (1) assert copyright on the software, and (2) offer you this License
42
+ giving you legal permission to copy, distribute and/or modify it.
43
+
44
+ For the developers' and authors' protection, the GPL clearly explains
45
+ that there is no warranty for this free software. For both users' and
46
+ authors' sake, the GPL requires that modified versions be marked as
47
+ changed, so that their problems will not be attributed erroneously to
48
+ authors of previous versions.
49
+
50
+ Some devices are designed to deny users access to install or run
51
+ modified versions of the software inside them, although the manufacturer
52
+ can do so. This is fundamentally incompatible with the aim of protecting
53
+ users' freedom to change the software. The systematic pattern of such
54
+ abuse occurs in the area of products for individuals to use, which is
55
+ precisely where it is most unacceptable. Therefore, we have designed
56
+ this version of the GPL to prohibit the practice for those products. If
57
+ such problems arise substantially in other domains, we stand ready to
58
+ extend this provision to those domains in future versions of the GPL, as
59
+ needed to protect the freedom of users.
60
+
61
+ Finally, every program is threatened constantly by software patents.
62
+ States should not allow patents to restrict development and use of
63
+ software on general-purpose computers, but in those that do, we wish to
64
+ avoid the special danger that patents applied to a free program could
65
+ make it effectively proprietary. To prevent this, the GPL assures that
66
+ patents cannot be used to render the program non-free.
67
+
68
+ The precise terms and conditions for copying, distribution and
69
+ modification follow.
70
+
71
+ TERMS AND CONDITIONS
72
+
73
+ 0. Definitions.
74
+
75
+ "This License" refers to version 3 of the GNU General Public License.
76
+
77
+ "Copyright" also means copyright-like laws that apply to other kinds
78
+ of works, such as semiconductor masks.
79
+
80
+ "The Program" refers to any copyrightable work licensed under this
81
+ License. Each licensee is addressed as "you". "Licensees" and
82
+ "recipients" may be individuals or organizations.
83
+
84
+ To "modify" a work means to copy from or adapt all or part of the work
85
+ in a fashion requiring copyright permission, other than the making of an
86
+ exact copy. The resulting work is called a "modified version" of the
87
+ earlier work or a work "based on" the earlier work.
88
+
89
+ A "covered work" means either the unmodified Program or a work based
90
+ on the Program.
91
+
92
+ To "propagate" a work means to do anything with it that, without
93
+ permission, would make you directly or secondarily liable for
94
+ infringement under applicable copyright law, except executing it on a
95
+ computer or modifying a private copy. Propagation includes copying,
96
+ distribution (with or without modification), making available to the
97
+ public, and in some countries other activities as well.
98
+
99
+ To "convey" a work means any kind of propagation that enables other
100
+ parties to make or receive copies. Mere interaction with a user through
101
+ a computer network, with no transfer of a copy, is not conveying.
102
+
103
+ An interactive user interface displays "Appropriate Legal Notices"
104
+ to the extent that it includes a convenient and prominently visible
105
+ feature that (1) displays an appropriate copyright notice, and (2)
106
+ tells the user that there is no warranty for the work (except to the
107
+ extent that warranties are provided), that licensees may convey the
108
+ work under this License, and how to view a copy of this License. If
109
+ the interface presents a list of user commands or options, such as a
110
+ menu, a prominent item in the list meets this criterion.
111
+
112
+ (El texto completo es largo, puedes encontrarlo en https://www.gnu.org/licenses/gpl-3.0.txt)
113
+
@@ -0,0 +1,144 @@
1
+ Metadata-Version: 2.2
2
+ Name: splent_framework
3
+ Version: 0.0.1
4
+ Summary: SPLENT-FRAMEWORK is a set of libraries for agile product development within SPLENT.
5
+ Author-email: David Romero <drorganvidez@us.es>
6
+ License: GNU GENERAL PUBLIC LICENSE
7
+ Version 3, 29 June 2007
8
+
9
+ Copyright (C) 2007 Free Software Foundation, Inc.
10
+ Everyone is permitted to copy and distribute verbatim copies
11
+ of this license document, but changing it is not allowed.
12
+
13
+ Preamble
14
+
15
+ The GNU General Public License is a free, copyleft license for
16
+ software and other kinds of works.
17
+
18
+ The licenses for most software and other practical works are designed
19
+ to take away your freedom to share and change the works. By contrast,
20
+ the GNU General Public License is intended to guarantee your freedom to
21
+ share and change all versions of a program--to make sure it remains free
22
+ software for all its users. We, the Free Software Foundation, use the
23
+ GNU General Public License for most of our software; it applies also to
24
+ any other work released this way by its authors. You can apply it to
25
+ your programs, too.
26
+
27
+ When we speak of free software, we are referring to freedom, not
28
+ price. Our General Public Licenses are designed to make sure that you
29
+ have the freedom to distribute copies of free software (and charge for
30
+ them if you wish), that you receive source code or can get it if you
31
+ want it, that you can change the software or use pieces of it in new
32
+ free programs, and that you know you can do these things.
33
+
34
+ To protect your rights, we need to prevent others from denying you
35
+ these rights or asking you to surrender the rights. Therefore, you have
36
+ certain responsibilities if you distribute copies of the software, or if
37
+ you modify it: responsibilities to respect the freedom of others.
38
+
39
+ For example, if you distribute copies of such a program, whether
40
+ gratis or for a fee, you must pass on to the recipients the same
41
+ freedoms that you received. You must make sure that they, too, receive
42
+ or can get the source code. And you must show them these terms so they
43
+ know their rights.
44
+
45
+ Developers that use the GNU GPL protect your rights with two steps:
46
+ (1) assert copyright on the software, and (2) offer you this License
47
+ giving you legal permission to copy, distribute and/or modify it.
48
+
49
+ For the developers' and authors' protection, the GPL clearly explains
50
+ that there is no warranty for this free software. For both users' and
51
+ authors' sake, the GPL requires that modified versions be marked as
52
+ changed, so that their problems will not be attributed erroneously to
53
+ authors of previous versions.
54
+
55
+ Some devices are designed to deny users access to install or run
56
+ modified versions of the software inside them, although the manufacturer
57
+ can do so. This is fundamentally incompatible with the aim of protecting
58
+ users' freedom to change the software. The systematic pattern of such
59
+ abuse occurs in the area of products for individuals to use, which is
60
+ precisely where it is most unacceptable. Therefore, we have designed
61
+ this version of the GPL to prohibit the practice for those products. If
62
+ such problems arise substantially in other domains, we stand ready to
63
+ extend this provision to those domains in future versions of the GPL, as
64
+ needed to protect the freedom of users.
65
+
66
+ Finally, every program is threatened constantly by software patents.
67
+ States should not allow patents to restrict development and use of
68
+ software on general-purpose computers, but in those that do, we wish to
69
+ avoid the special danger that patents applied to a free program could
70
+ make it effectively proprietary. To prevent this, the GPL assures that
71
+ patents cannot be used to render the program non-free.
72
+
73
+ The precise terms and conditions for copying, distribution and
74
+ modification follow.
75
+
76
+ TERMS AND CONDITIONS
77
+
78
+ 0. Definitions.
79
+
80
+ "This License" refers to version 3 of the GNU General Public License.
81
+
82
+ "Copyright" also means copyright-like laws that apply to other kinds
83
+ of works, such as semiconductor masks.
84
+
85
+ "The Program" refers to any copyrightable work licensed under this
86
+ License. Each licensee is addressed as "you". "Licensees" and
87
+ "recipients" may be individuals or organizations.
88
+
89
+ To "modify" a work means to copy from or adapt all or part of the work
90
+ in a fashion requiring copyright permission, other than the making of an
91
+ exact copy. The resulting work is called a "modified version" of the
92
+ earlier work or a work "based on" the earlier work.
93
+
94
+ A "covered work" means either the unmodified Program or a work based
95
+ on the Program.
96
+
97
+ To "propagate" a work means to do anything with it that, without
98
+ permission, would make you directly or secondarily liable for
99
+ infringement under applicable copyright law, except executing it on a
100
+ computer or modifying a private copy. Propagation includes copying,
101
+ distribution (with or without modification), making available to the
102
+ public, and in some countries other activities as well.
103
+
104
+ To "convey" a work means any kind of propagation that enables other
105
+ parties to make or receive copies. Mere interaction with a user through
106
+ a computer network, with no transfer of a copy, is not conveying.
107
+
108
+ An interactive user interface displays "Appropriate Legal Notices"
109
+ to the extent that it includes a convenient and prominently visible
110
+ feature that (1) displays an appropriate copyright notice, and (2)
111
+ tells the user that there is no warranty for the work (except to the
112
+ extent that warranties are provided), that licensees may convey the
113
+ work under this License, and how to view a copy of this License. If
114
+ the interface presents a list of user commands or options, such as a
115
+ menu, a prominent item in the list meets this criterion.
116
+
117
+ (El texto completo es largo, puedes encontrarlo en https://www.gnu.org/licenses/gpl-3.0.txt)
118
+
119
+
120
+ Project-URL: Homepage, https://github.com/diverso-lab/splent_framework
121
+ Project-URL: Issues, https://github.com/diverso-lab/splent_framework/issues
122
+ Requires-Python: >=3.12
123
+ Description-Content-Type: text/markdown
124
+ License-File: LICENSE
125
+ Requires-Dist: click
126
+ Requires-Dist: python-dotenv
127
+ Requires-Dist: sqlalchemy
128
+ Requires-Dist: flask_sqlalchemy
129
+ Requires-Dist: flask_migrate
130
+ Requires-Dist: flask_session
131
+ Requires-Dist: flask_mail
132
+ Requires-Dist: flask_login
133
+ Requires-Dist: flask_wtf
134
+ Requires-Dist: redis
135
+ Requires-Dist: pymysql
136
+ Requires-Dist: docker
137
+ Requires-Dist: psutil
138
+ Requires-Dist: pytz
139
+ Requires-Dist: pytest
140
+ Requires-Dist: pytest-cov
141
+ Requires-Dist: selenium
142
+ Requires-Dist: webdriver_manager
143
+
144
+ # splent_framework
@@ -0,0 +1 @@
1
+ # splent_framework
@@ -0,0 +1,40 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "splent_framework"
7
+ version = "0.0.1"
8
+ description = "SPLENT-FRAMEWORK is a set of libraries for agile product development within SPLENT."
9
+ readme = "README.md"
10
+ requires-python = ">=3.12"
11
+ authors = [{ name = "David Romero", email = "drorganvidez@us.es" }]
12
+ license = { file = "LICENSE" }
13
+ dependencies = [
14
+ "click",
15
+ "python-dotenv",
16
+ "sqlalchemy",
17
+ "flask_sqlalchemy",
18
+ "flask_migrate",
19
+ "flask_session",
20
+ "flask_mail",
21
+ "flask_login",
22
+ "flask_wtf",
23
+ "redis",
24
+ "pymysql",
25
+ "docker",
26
+ "psutil",
27
+ "pytz",
28
+ "pytest",
29
+ "pytest-cov",
30
+ "selenium",
31
+ "webdriver_manager"
32
+ ]
33
+
34
+ [tool.setuptools.packages.find]
35
+ where = ["."]
36
+ include = ["splent_framework*"]
37
+
38
+ [project.urls]
39
+ Homepage = "https://github.com/diverso-lab/splent_framework"
40
+ Issues = "https://github.com/diverso-lab/splent_framework/issues"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
File without changes
@@ -0,0 +1,76 @@
1
+ from flask import Blueprint, Response, abort
2
+ import os
3
+
4
+ from splent_cli.utils.path_utils import PathUtils
5
+
6
+
7
+ class BaseBlueprint(Blueprint):
8
+ def __init__(
9
+ self,
10
+ name,
11
+ import_name,
12
+ static_folder=None,
13
+ static_url_path=None,
14
+ template_folder=None,
15
+ url_prefix=None,
16
+ subdomain=None,
17
+ url_defaults=None,
18
+ root_path=None,
19
+ ):
20
+ super().__init__(
21
+ name,
22
+ import_name,
23
+ static_folder=static_folder,
24
+ static_url_path=static_url_path,
25
+ template_folder=template_folder,
26
+ url_prefix=url_prefix,
27
+ subdomain=subdomain,
28
+ url_defaults=url_defaults,
29
+ root_path=root_path,
30
+ )
31
+ self.module_path = os.path.join(PathUtils.get_modules_dir(), name)
32
+ self.add_asset_routes()
33
+
34
+ def add_asset_routes(self):
35
+ """Define a dynamic route to serve any file inside subfolders under assets (e.g., js, css)."""
36
+ assets_folder = os.path.join(self.module_path, "assets")
37
+ if os.path.exists(assets_folder):
38
+ # Define a route for any file inside the 'assets' folder and its subfolders
39
+ self.add_url_rule(
40
+ f"/{self.name}/<path:subfolder>/<path:filename>",
41
+ "assets",
42
+ self.send_file,
43
+ )
44
+ else:
45
+ print(f"(BaseBlueprint) -> {assets_folder} does not exist.")
46
+
47
+ def send_file(self, subfolder, filename):
48
+ """Send any file located in the specified subfolder within the assets folder."""
49
+ file_path = os.path.join(
50
+ self.module_path, "assets", subfolder, filename
51
+ )
52
+
53
+ if filename == "webpack.config.js":
54
+ abort(403, description="Access to this file is forbidden")
55
+
56
+ # Check if the file exists and is located within a valid subfolder (e.g., js, css)
57
+ if os.path.exists(file_path) and subfolder in ["js", "css", "dist"]:
58
+ try:
59
+ # Detect the correct MIME type based on file extension
60
+ if filename.endswith(".js"):
61
+ mimetype = "application/javascript"
62
+ elif filename.endswith(".css"):
63
+ mimetype = "text/css"
64
+ else:
65
+ mimetype = "text/plain"
66
+
67
+ with open(file_path) as file:
68
+ file_content = file.read()
69
+ return Response(file_content, mimetype=mimetype)
70
+ except FileNotFoundError:
71
+ abort(404, description=f"File not found: {file_path}")
72
+ else:
73
+ abort(
74
+ 404,
75
+ description=f"Invalid path or file: {subfolder}/{filename}",
76
+ )
@@ -0,0 +1,50 @@
1
+ import os
2
+ import glob
3
+ import inspect
4
+ import importlib.util
5
+ from locust import HttpUser
6
+ from dotenv import load_dotenv
7
+
8
+
9
+ def load_locustfiles():
10
+ load_dotenv()
11
+ working_dir = os.getenv("WORKING_DIR", "")
12
+ print(f"Working directory: {working_dir}")
13
+
14
+ module_dir = os.path.join(working_dir, "app", "modules")
15
+ print(f"Module directory: {module_dir}")
16
+
17
+ locustfile_paths = glob.glob(
18
+ os.path.join(module_dir, "*", "tests", "locustfile.py")
19
+ )
20
+ print(f"Found locustfiles: {locustfile_paths}")
21
+
22
+ found_user_classes = []
23
+
24
+ for path in locustfile_paths:
25
+ print(f"Loading locustfile: {path}")
26
+ module_name = os.path.splitext(os.path.basename(path))[0]
27
+ spec = importlib.util.spec_from_file_location(module_name, path)
28
+ locustfile = importlib.util.module_from_spec(spec)
29
+ spec.loader.exec_module(locustfile)
30
+
31
+ # Collect all classes that inherit from HttpUser
32
+ for name, obj in vars(locustfile).items():
33
+ if (
34
+ inspect.isclass(obj)
35
+ and issubclass(obj, HttpUser)
36
+ and obj is not HttpUser
37
+ ):
38
+ unique_name = f"{name}_{os.path.basename(path).split('.')[0]}"
39
+ globals()[unique_name] = obj # Add to globals
40
+ found_user_classes.append((unique_name, obj))
41
+ print(f"Loaded user class: {unique_name}")
42
+
43
+ if not found_user_classes:
44
+ raise ValueError("No User class found!")
45
+
46
+ return found_user_classes
47
+
48
+
49
+ found_user_classes = load_locustfiles()
50
+ print(f"Total user classes loaded: {len(found_user_classes)}")
@@ -0,0 +1,25 @@
1
+ import os
2
+ from dotenv import load_dotenv
3
+
4
+ load_dotenv()
5
+
6
+
7
+ def uploads_folder_name():
8
+ return os.getenv("UPLOADS_DIR", "uploads")
9
+
10
+
11
+ def get_app_version():
12
+ version_file_path = os.path.join(os.getenv("WORKING_DIR", ""), ".version")
13
+ try:
14
+ with open(version_file_path) as file:
15
+ return file.readline().strip()
16
+ except FileNotFoundError:
17
+ return "unknown"
18
+
19
+
20
+ def is_develop():
21
+ return os.getenv("FLASK_ENV") == "development"
22
+
23
+
24
+ def is_production():
25
+ return os.getenv("FLASK_ENV") == "production"
@@ -0,0 +1,18 @@
1
+ from functools import wraps
2
+
3
+ from flask import abort
4
+
5
+
6
+ def pass_or_abort(condition):
7
+
8
+ def decorator(f):
9
+
10
+ @wraps(f)
11
+ def decorated_function(*args, **kwargs):
12
+ if not condition(**kwargs):
13
+ abort(404)
14
+ return f(*args, **kwargs)
15
+
16
+ return decorated_function
17
+
18
+ return decorator
@@ -0,0 +1,65 @@
1
+ import os
2
+ from dotenv import load_dotenv
3
+
4
+ load_dotenv()
5
+
6
+
7
+ def get_host_for_testing(test_type: str) -> str:
8
+ """
9
+ Get the host URL for testing based on the test type and the working directory.
10
+
11
+ Parameters:
12
+ test_type (str): The type of test (either "locust" or "selenium").
13
+
14
+ Returns:
15
+ str: The host URL corresponding to the test type and working directory.
16
+
17
+ Raises:
18
+ ValueError: If the test type is unknown or the WORKING_DIR value is not mapped.
19
+ """
20
+ # Define host mappings for locust and selenium tests
21
+ host_mapping = {
22
+ "locust": {
23
+ "": "http://localhost:5000",
24
+ "/app/": "http://nginx_web_server_container",
25
+ "/vagrant/": "http://localhost:5000",
26
+ },
27
+ "selenium": {
28
+ "": "http://localhost:5000",
29
+ "/app/": "http://localhost",
30
+ "/vagrant/": "http://localhost:5000",
31
+ },
32
+ }
33
+
34
+ # Check if the provided test type is valid
35
+ if test_type not in host_mapping:
36
+ raise ValueError(f"Unknown test type: {test_type}")
37
+
38
+ # Get the working directory from the environment variable
39
+ working_dir = os.getenv("WORKING_DIR", "")
40
+
41
+ # Return the host URL based on the working directory
42
+ if working_dir in host_mapping[test_type]:
43
+ return host_mapping[test_type][working_dir]
44
+ else:
45
+ raise ValueError(f"Unknown WORKING_DIR value: {working_dir}")
46
+
47
+
48
+ def get_host_for_locust_testing() -> str:
49
+ """
50
+ Get the host URL for locust testing.
51
+
52
+ Returns:
53
+ str: The host URL for locust testing.
54
+ """
55
+ return get_host_for_testing("locust")
56
+
57
+
58
+ def get_host_for_selenium_testing() -> str:
59
+ """
60
+ Get the host URL for selenium testing.
61
+
62
+ Returns:
63
+ str: The host URL for selenium testing.
64
+ """
65
+ return get_host_for_testing("selenium")
@@ -0,0 +1,14 @@
1
+ from faker import Faker
2
+ from bs4 import BeautifulSoup
3
+
4
+ fake = Faker()
5
+
6
+
7
+ def get_csrf_token(response):
8
+ soup = BeautifulSoup(response.text, "html.parser")
9
+ token_tag = soup.find("input", {"name": "csrf_token"})
10
+ if token_tag:
11
+ return token_tag["value"]
12
+ else:
13
+ print("Response HTML:", response.text)
14
+ raise ValueError("CSRF token not found in the response")
@@ -0,0 +1,65 @@
1
+ import os
2
+ import redis
3
+
4
+
5
+ class ConfigManager:
6
+ def __init__(self, app):
7
+ self.app = app
8
+
9
+ def load_config(self, config_name="development"):
10
+ # If config_name is not provided, use the environment variable FLASK_ENV
11
+ if config_name is None:
12
+ config_name = os.getenv("FLASK_ENV", "development")
13
+
14
+ # Load configuration
15
+ if config_name == "testing":
16
+ self.app.config.from_object(TestingConfig)
17
+ elif config_name == "production":
18
+ self.app.config.from_object(ProductionConfig)
19
+ else:
20
+ self.app.config.from_object(DevelopmentConfig)
21
+
22
+
23
+ class Config:
24
+ SECRET_KEY = os.getenv(
25
+ "SECRET_KEY", "dev_test_key_1234567890abcdefghijklmnopqrstu"
26
+ )
27
+ SQLALCHEMY_DATABASE_URI = (
28
+ f"mysql+pymysql://{os.getenv('MARIADB_USER', 'default_user')}:"
29
+ f"{os.getenv('MARIADB_PASSWORD', 'default_password')}@"
30
+ f"{os.getenv('MARIADB_HOSTNAME', 'localhost')}:"
31
+ f"{os.getenv('MARIADB_PORT', '3306')}/"
32
+ f"{os.getenv('MARIADB_DATABASE', 'default_db')}"
33
+ )
34
+ SQLALCHEMY_TRACK_MODIFICATIONS = False
35
+ TIMEZONE = "Europe/Madrid"
36
+ TEMPLATES_AUTO_RELOAD = True
37
+ UPLOAD_FOLDER = "uploads"
38
+ SESSION_TYPE = "redis"
39
+ SESSION_PERMANENT = False
40
+ SESSION_USE_SIGNER = True
41
+ REDIS_URL = os.getenv("REDIS_URL", "redis://redis:6379")
42
+ SESSION_REDIS = redis.from_url(REDIS_URL)
43
+ REDIS_WORKER_TIMEOUT = os.getenv("REDIS_WORKER_TIMEOUT", 180)
44
+
45
+
46
+ class DevelopmentConfig(Config):
47
+ DEBUG = True
48
+
49
+
50
+ class TestingConfig(Config):
51
+ TESTING = True
52
+ SQLALCHEMY_DATABASE_URI = (
53
+ f"mysql+pymysql://{os.getenv('MARIADB_USER', 'default_user')}:"
54
+ f"{os.getenv('MARIADB_PASSWORD', 'default_password')}@"
55
+ f"{os.getenv('MARIADB_HOSTNAME', 'localhost')}:"
56
+ f"{os.getenv('MARIADB_PORT', '3306')}/"
57
+ f"{os.getenv('MARIADB_TEST_DATABASE', 'default_db')}"
58
+ )
59
+ WTF_CSRF_ENABLED = False
60
+ SESSION_TYPE = "filesystem"
61
+ SESSION_FILE_DIR = "/tmp/flask_sessions"
62
+
63
+
64
+ class ProductionConfig(Config):
65
+ DEBUG = False