Terarea  2
The automation project
Loading...
Searching...
No Matches
constants Namespace Reference

Functions

str get_cache_busting ()
 
Any _get_env_node (Dict[str, Any] env, str key, str default)
 
str _get_environement_variable (dotenv environement, str variable_name)
 
str _get_toml_variable (dict toml_conf, str section, str key, default=None)
 
str _password_generator (int length=20, str encapsulation_node="password")
 
bool are_json_responses_identical (Dict[str, Any] json_response1, Dict[str, Any] json_response2, str test_name="are_json_responses_identical")
 

Variables

bool DEBUG = False
 
 debug
 
 name
 
int DB_PORT = 3307
 
str DB_HOST = "127.0.0.1"
 
str DB_USER = "root"
 
str DB_PASSWORD = ""
 
str DB_DATABASE = "terarea"
 
str SERVER_HOST = "0.0.0.0"
 
str QUERY_HOST = "http://127.0.0.1"
 
int PORT = 6000
 
int QUERY_DELAY = 2
 
int SUCCESS = 0
 
int ERROR = 1
 
str APP_NAME = "Area - Testing"
 
 SAFE_STRING = ascii_letters+digits
 
 SAFE_STRING_LENGTH = len(SAFE_STRING)
 
str CACHE_BUSTER = get_cache_busting()
 
str CACHE_BUSTER_ADMIN = f"admin_{get_cache_busting()}_admin"
 
str TEST_ENV = ".env"
 
 ENV = dict(dotenv.dotenv_values())
 
Any MINIO_HOST = _get_env_node(ENV, "MINIO_HOST", "minio")
 
 MINIO_PORT = int(_get_env_node(ENV, "MINIO_PORT", 9000))
 
Any MINIO_ROOT_USER = _get_env_node(ENV, "MINIO_ROOT_USER", "root")
 
str MINIO_ROOT_PASSWORD
 
 TOML_CONF = toml.load("config.toml")
 
str PATH_GET_HOME = "/"
 
str PATH_GET_API_HOME = "/api/v1/"
 
str PATH_PUT_REGISTER = "/api/v1/register"
 
str PATH_POST_LOGIN = "/api/v1/login"
 
str PATH_PATCH_USER = "/api/v1/user"
 
str PATH_PUT_USER = "/api/v1/user"
 
str PATH_DELETE_USER = "/api/v1/user"
 
str PATH_GET_USER = "/api/v1/user"
 
str PATH_GET_USER_ID = "/api/v1/user_id"
 
str PATH_POST_LOGOUT = "/api/v1/logout"
 
str LAMBDA_USER_TOKEN_KEY = "lambda_user"
 
str ADMIN_USER_TOKEN_KEY = "admin_user"
 
str TOKEN_AUTH_ID_STR = "Authorization"
 
str PRETTY_TOKEN_KEY = "token_header"
 
str RAW_TOKEN_KEY = "token_key"
 
str USER_DATA_EMAIL = f"some_email_{CACHE_BUSTER}@company.example"
 
str USER_DATA_USERNAME = USER_DATA_EMAIL.split("@")[0]
 
str USER_DATA_PASSWORD
 
str USER_DATA_METHOD = "local"
 
str USER_DATA_FAVICON = "NULL"
 
str USER_DATA_ADMIN = "0"
 
str USER_DATA_TOKEN = f"some_token_{CACHE_BUSTER}_some_token"
 
int USER_DATA_TOKEN_LIFESPAN = 3600
 
str USER_DATA_EMAIL_REBIND = f"some_email_{CACHE_BUSTER}_rebind@company.example"
 
str USER_DATA_USERNAME_REBIND = USER_DATA_EMAIL_REBIND.split("@")[0]
 
str USER_DATA_PASSWORD_REBIND
 
str USER_DATA_EMAIL_PATCH = f"some_email_{CACHE_BUSTER}_patch@company.com"
 
str USER_DATA_USERNAME_PATCH = USER_DATA_EMAIL_PATCH.split("@")[0]
 
str USER_DATA_PASSWORD_PATCH
 
str ADMIN_DATA_EMAIL = f"some_email_{CACHE_BUSTER_ADMIN}@company.example"
 
str ADMIN_DATA_USERNAME = ADMIN_DATA_EMAIL.split("@")[0]
 
str ADMIN_DATA_PASSWORD
 
str ADMIN_DATA_METHOD = "local"
 
str ADMIN_DATA_FAVICON = "NULL"
 
str ADMIN_DATA_ADMIN = "1"
 
str ADMIN_DATA_TOKEN = f"some_token_{CACHE_BUSTER_ADMIN}_some_token"
 
int ADMIN_DATA_TOKEN_LIFESPAN = 3600
 
str ADMIN_DATA_EMAIL_REBIND = f"some_email_{CACHE_BUSTER_ADMIN}_"
 
str ADMIN_DATA_USERNAME_REBIND = ADMIN_DATA_EMAIL_REBIND.split("@")[0]
 
str ADMIN_DATA_PASSWORD_REBIND
 
str ADMIN_DATA_EMAIL_PATCH = f"some_email_{CACHE_BUSTER_ADMIN}_patch@company.com"
 
str ADMIN_DATA_USERNAME_PATCH = ADMIN_DATA_EMAIL_PATCH.split("@")[0]
 
str ADMIN_DATA_PASSWORD_PATCH
 
str UNODE_EMAIL_KEY = "email"
 
str UNODE_PASSWORD_KEY = "password"
 
str UNODE_USERNAME_KEY = "username"
 
str UNODE_METHOD_KEY = "method"
 
str UNODE_FAVICON_KEY = "favicon"
 
str UNODE_ADMIN_KEY = "admin"
 
str USER_NORMAL_MODE = "normal"
 
str USER_PUT_MODE = "put"
 
str USER_PATCH_MODE = "patch"
 
str RUNTIME_NODE_CRITICAL_KEY = "critical"
 
dict RESPONSE_GET_HOME_RESPONSE_NOT_LOGGED_IN
 
dict RESPONSE_GET_HOME_API_RESPONSE_NOT_LOGGED_IN
 
dict RESPONSE_POST_LOGIN
 
dict RESPONSE_POST_REGISTER
 
dict RESPONSE_PUT_USER
 
dict RESPONSE_PATCH_USER
 
dict RESPONSE_GET_USER
 
dict RESPONSE_GET_USER_ID
 
dict RESPONSE_POST_LOGOUT
 
dict RESPONSE_DELETE_USER
 

Detailed Description

_summary_
This is the file in charge of storing the variable constants

Raises:
    ValueError: _description_
    KeyError: _description_
    KeyError: _description_
    RuntimeError: _description_

Returns:
    _type_: _description_

Function Documentation

◆ _get_env_node()

Any constants._get_env_node ( Dict[str, Any] env,
str key,
str default )
protected
_summary_
    Load the variable from the environement.
    Otherwise, use the default value provided.
Args:
    key (_type_): _description_
    default (_type_): _description_

Returns:
    Any: _description_

Definition at line 83 of file constants.py.

◆ _get_environement_variable()

str constants._get_environement_variable ( dotenv environement,
str variable_name )
protected
_summary_
    Get the content of an environement variable.

Args:
    variable_name (str): _description_

Returns:
    str: _description_: the value of that variable, otherwise an exception is raised.

Definition at line 100 of file constants.py.

◆ _get_toml_variable()

str constants._get_toml_variable ( dict toml_conf,
str section,
str key,
default = None )
protected
Get the value of a configuration variable from the TOML file.

Args:
    toml_conf (dict): The loaded TOML configuration as a dictionary.
    section (str): The section of the TOML file to search in.
    key (str): The key within the section to fetch.
    default: The default value to return if the key is not found. Defaults to None.

Returns:
    str: The value of the configuration variable, or the default value if the key is not found.

Raises:
    KeyError: If the section is not found in the TOML configuration.

Definition at line 118 of file constants.py.

◆ _password_generator()

str constants._password_generator ( int length = 20,
str encapsulation_node = "password" )
protected
_summary_
    This is a function in charge of generating a password for on the fly accounts.

Args:
    length (int, optional): _description_. Defaults to 20.

Returns:
    str: _description_

Definition at line 159 of file constants.py.

◆ are_json_responses_identical()

bool constants.are_json_responses_identical ( Dict[str, Any] json_response1,
Dict[str, Any] json_response2,
str test_name = "are_json_responses_identical" )
_summary_
    This function is in charge of comparing two json responses to see if they are identical.

Args:
    json_response1 (Dict[str,Any]): _description_: The first json response you wish to compare
    json_response2 (Dict[str,Any]): _description_: The json response that the first response will be compared against

Returns:
    bool: _description_: Returns True if they are identical, False otherwise.

Definition at line 188 of file constants.py.

◆ get_cache_busting()

str constants.get_cache_busting ( )
_summary_
    This function is in charge of generating a cache busting string.
    This is done in order to avoid creating already existing accounts

Returns:
    str: _description_

Definition at line 56 of file constants.py.

Variable Documentation

◆ ADMIN_DATA_ADMIN

str constants.ADMIN_DATA_ADMIN = "1"

Definition at line 319 of file constants.py.

◆ ADMIN_DATA_EMAIL

str constants.ADMIN_DATA_EMAIL = f"some_email_{CACHE_BUSTER_ADMIN}@company.example"

Definition at line 312 of file constants.py.

◆ ADMIN_DATA_EMAIL_PATCH

str constants.ADMIN_DATA_EMAIL_PATCH = f"some_email_{CACHE_BUSTER_ADMIN}_patch@company.com"

Definition at line 332 of file constants.py.

◆ ADMIN_DATA_EMAIL_REBIND

str constants.ADMIN_DATA_EMAIL_REBIND = f"some_email_{CACHE_BUSTER_ADMIN}_"

Definition at line 324 of file constants.py.

◆ ADMIN_DATA_FAVICON

str constants.ADMIN_DATA_FAVICON = "NULL"

Definition at line 318 of file constants.py.

◆ ADMIN_DATA_METHOD

str constants.ADMIN_DATA_METHOD = "local"

Definition at line 317 of file constants.py.

◆ ADMIN_DATA_PASSWORD

str constants.ADMIN_DATA_PASSWORD
Initial value:
1= _password_generator(
2 length=20, encapsulation_node="some_admin"
3)

Definition at line 314 of file constants.py.

◆ ADMIN_DATA_PASSWORD_PATCH

str constants.ADMIN_DATA_PASSWORD_PATCH
Initial value:
1= _password_generator(
2 length=20, encapsulation_node="some_admin_patch"
3)

Definition at line 334 of file constants.py.

◆ ADMIN_DATA_PASSWORD_REBIND

str constants.ADMIN_DATA_PASSWORD_REBIND
Initial value:
1= _password_generator(
2 length=20, encapsulation_node="some_admin_rebind"
3)

Definition at line 327 of file constants.py.

◆ ADMIN_DATA_TOKEN

str constants.ADMIN_DATA_TOKEN = f"some_token_{CACHE_BUSTER_ADMIN}_some_token"

Definition at line 320 of file constants.py.

◆ ADMIN_DATA_TOKEN_LIFESPAN

int constants.ADMIN_DATA_TOKEN_LIFESPAN = 3600

Definition at line 321 of file constants.py.

◆ ADMIN_DATA_USERNAME

str constants.ADMIN_DATA_USERNAME = ADMIN_DATA_EMAIL.split("@")[0]

Definition at line 313 of file constants.py.

◆ ADMIN_DATA_USERNAME_PATCH

str constants.ADMIN_DATA_USERNAME_PATCH = ADMIN_DATA_EMAIL_PATCH.split("@")[0]

Definition at line 333 of file constants.py.

◆ ADMIN_DATA_USERNAME_REBIND

str constants.ADMIN_DATA_USERNAME_REBIND = ADMIN_DATA_EMAIL_REBIND.split("@")[0]

Definition at line 326 of file constants.py.

◆ ADMIN_USER_TOKEN_KEY

str constants.ADMIN_USER_TOKEN_KEY = "admin_user"

Definition at line 280 of file constants.py.

◆ APP_NAME

str constants.APP_NAME = "Area - Testing"

Definition at line 48 of file constants.py.

◆ CACHE_BUSTER

str constants.CACHE_BUSTER = get_cache_busting()

Definition at line 222 of file constants.py.

◆ CACHE_BUSTER_ADMIN

str constants.CACHE_BUSTER_ADMIN = f"admin_{get_cache_busting()}_admin"

Definition at line 223 of file constants.py.

◆ DB_DATABASE

Any constants.DB_DATABASE = "terarea"

Definition at line 36 of file constants.py.

◆ DB_HOST

Any constants.DB_HOST = "127.0.0.1"

Definition at line 33 of file constants.py.

◆ DB_PASSWORD

str constants.DB_PASSWORD = ""

Definition at line 35 of file constants.py.

◆ DB_PORT

constants.DB_PORT = 3307

Definition at line 32 of file constants.py.

◆ DB_USER

Any constants.DB_USER = "root"

Definition at line 34 of file constants.py.

◆ DEBUG

bool constants.DEBUG = False

Definition at line 26 of file constants.py.

◆ debug

constants.debug

Definition at line 28 of file constants.py.

◆ ENV

constants.ENV = dict(dotenv.dotenv_values())

Definition at line 228 of file constants.py.

◆ ERROR

constants.ERROR = 1

Definition at line 46 of file constants.py.

◆ LAMBDA_USER_TOKEN_KEY

str constants.LAMBDA_USER_TOKEN_KEY = "lambda_user"

Definition at line 279 of file constants.py.

◆ MINIO_HOST

Any constants.MINIO_HOST = _get_env_node(ENV, "MINIO_HOST", "minio")

Definition at line 235 of file constants.py.

◆ MINIO_PORT

constants.MINIO_PORT = int(_get_env_node(ENV, "MINIO_PORT", 9000))

Definition at line 236 of file constants.py.

◆ MINIO_ROOT_PASSWORD

str constants.MINIO_ROOT_PASSWORD
Initial value:
1= _get_environement_variable(
2 ENV, "MINIO_ROOT_PASSWORD"
3 )

Definition at line 238 of file constants.py.

◆ MINIO_ROOT_USER

Any constants.MINIO_ROOT_USER = _get_env_node(ENV, "MINIO_ROOT_USER", "root")

Definition at line 237 of file constants.py.

◆ name

constants.name

Definition at line 30 of file constants.py.

◆ PATH_DELETE_USER

str constants.PATH_DELETE_USER = "/api/v1/user"

Definition at line 273 of file constants.py.

◆ PATH_GET_API_HOME

str constants.PATH_GET_API_HOME = "/api/v1/"

Definition at line 268 of file constants.py.

◆ PATH_GET_HOME

str constants.PATH_GET_HOME = "/"

Definition at line 267 of file constants.py.

◆ PATH_GET_USER

str constants.PATH_GET_USER = "/api/v1/user"

Definition at line 274 of file constants.py.

◆ PATH_GET_USER_ID

str constants.PATH_GET_USER_ID = "/api/v1/user_id"

Definition at line 275 of file constants.py.

◆ PATH_PATCH_USER

str constants.PATH_PATCH_USER = "/api/v1/user"

Definition at line 271 of file constants.py.

◆ PATH_POST_LOGIN

str constants.PATH_POST_LOGIN = "/api/v1/login"

Definition at line 270 of file constants.py.

◆ PATH_POST_LOGOUT

str constants.PATH_POST_LOGOUT = "/api/v1/logout"

Definition at line 276 of file constants.py.

◆ PATH_PUT_REGISTER

str constants.PATH_PUT_REGISTER = "/api/v1/register"

Definition at line 269 of file constants.py.

◆ PATH_PUT_USER

str constants.PATH_PUT_USER = "/api/v1/user"

Definition at line 272 of file constants.py.

◆ PORT

constants.PORT = 6000

Definition at line 40 of file constants.py.

◆ PRETTY_TOKEN_KEY

str constants.PRETTY_TOKEN_KEY = "token_header"

Definition at line 282 of file constants.py.

◆ QUERY_DELAY

int constants.QUERY_DELAY = 2

Definition at line 43 of file constants.py.

◆ QUERY_HOST

constants.QUERY_HOST = "http://127.0.0.1"

Definition at line 39 of file constants.py.

◆ RAW_TOKEN_KEY

str constants.RAW_TOKEN_KEY = "token_key"

Definition at line 283 of file constants.py.

◆ RESPONSE_DELETE_USER

dict constants.RESPONSE_DELETE_USER
Initial value:
1= {
2 "title": "Delete user",
3 "msg": "The account has successfully been deleted.",
4 "resp": "success",
5 "logged in": False
6}

Definition at line 410 of file constants.py.

◆ RESPONSE_GET_HOME_API_RESPONSE_NOT_LOGGED_IN

dict constants.RESPONSE_GET_HOME_API_RESPONSE_NOT_LOGGED_IN
Initial value:
1= {
2 'title': 'Home',
3 'msg': 'Welcome to the control server.',
4 'resp': '',
5 'logged in': False
6}

Definition at line 361 of file constants.py.

◆ RESPONSE_GET_HOME_RESPONSE_NOT_LOGGED_IN

dict constants.RESPONSE_GET_HOME_RESPONSE_NOT_LOGGED_IN
Initial value:
1= {
2 'title': 'Home',
3 'msg': 'Welcome to the control server.',
4 'resp': '',
5 'logged in': False
6}

Definition at line 355 of file constants.py.

◆ RESPONSE_GET_USER

dict constants.RESPONSE_GET_USER
Initial value:
1= {
2 "title": "Get user",
3 "msg": "The user information has been retrieved.",
4 "resp": "success",
5 "logged in": True
6}

Definition at line 392 of file constants.py.

◆ RESPONSE_GET_USER_ID

dict constants.RESPONSE_GET_USER_ID
Initial value:
1= {
2 "title": "Get user id",
3 "msg": "The user information has been retrieved.",
4 "resp": 0,
5 "logged in": True
6}

Definition at line 398 of file constants.py.

◆ RESPONSE_PATCH_USER

dict constants.RESPONSE_PATCH_USER
Initial value:
1= {
2 "title": "Patch user",
3 "msg": "The account information has been updated.",
4 "resp": "success",
5 "logged in": True
6}

Definition at line 386 of file constants.py.

◆ RESPONSE_POST_LOGIN

dict constants.RESPONSE_POST_LOGIN
Initial value:
1= {
2 'title': 'Login',
3 'msg': 'Welcome {name}',
4 'resp': 'success',
5 'logged in': True,
6 'token': ''
7}

Definition at line 367 of file constants.py.

◆ RESPONSE_POST_LOGOUT

dict constants.RESPONSE_POST_LOGOUT
Initial value:
1= {
2 "title": "Logout",
3 "msg": "You have successfully logged out...",
4 "resp": "success",
5 "logged in": False
6}

Definition at line 404 of file constants.py.

◆ RESPONSE_POST_REGISTER

dict constants.RESPONSE_POST_REGISTER
Initial value:
1= {
2 'title': 'Register',
3 "msg": "Account created successfully.",
4 'resp': 'success',
5 'logged in': True
6}

Definition at line 374 of file constants.py.

◆ RESPONSE_PUT_USER

dict constants.RESPONSE_PUT_USER
Initial value:
1= {
2 "title": "Put user",
3 "msg": "The account information has been updated.",
4 "resp": "success",
5 "logged in": True
6}

Definition at line 380 of file constants.py.

◆ RUNTIME_NODE_CRITICAL_KEY

str constants.RUNTIME_NODE_CRITICAL_KEY = "critical"

Definition at line 352 of file constants.py.

◆ SAFE_STRING

constants.SAFE_STRING = ascii_letters+digits

Definition at line 52 of file constants.py.

◆ SAFE_STRING_LENGTH

constants.SAFE_STRING_LENGTH = len(SAFE_STRING)

Definition at line 53 of file constants.py.

◆ SERVER_HOST

constants.SERVER_HOST = "0.0.0.0"

Definition at line 38 of file constants.py.

◆ SUCCESS

constants.SUCCESS = 0

Definition at line 45 of file constants.py.

◆ TEST_ENV

str constants.TEST_ENV = ".env"

Definition at line 225 of file constants.py.

◆ TOKEN_AUTH_ID_STR

str constants.TOKEN_AUTH_ID_STR = "Authorization"

Definition at line 281 of file constants.py.

◆ TOML_CONF

constants.TOML_CONF = toml.load("config.toml")

Definition at line 248 of file constants.py.

◆ UNODE_ADMIN_KEY

str constants.UNODE_ADMIN_KEY = "admin"

Definition at line 344 of file constants.py.

◆ UNODE_EMAIL_KEY

str constants.UNODE_EMAIL_KEY = "email"

Definition at line 339 of file constants.py.

◆ UNODE_FAVICON_KEY

str constants.UNODE_FAVICON_KEY = "favicon"

Definition at line 343 of file constants.py.

◆ UNODE_METHOD_KEY

str constants.UNODE_METHOD_KEY = "method"

Definition at line 342 of file constants.py.

◆ UNODE_PASSWORD_KEY

str constants.UNODE_PASSWORD_KEY = "password"

Definition at line 340 of file constants.py.

◆ UNODE_USERNAME_KEY

str constants.UNODE_USERNAME_KEY = "username"

Definition at line 341 of file constants.py.

◆ USER_DATA_ADMIN

str constants.USER_DATA_ADMIN = "0"

Definition at line 293 of file constants.py.

◆ USER_DATA_EMAIL

str constants.USER_DATA_EMAIL = f"some_email_{CACHE_BUSTER}@company.example"

Definition at line 286 of file constants.py.

◆ USER_DATA_EMAIL_PATCH

str constants.USER_DATA_EMAIL_PATCH = f"some_email_{CACHE_BUSTER}_patch@company.com"

Definition at line 305 of file constants.py.

◆ USER_DATA_EMAIL_REBIND

str constants.USER_DATA_EMAIL_REBIND = f"some_email_{CACHE_BUSTER}_rebind@company.example"

Definition at line 298 of file constants.py.

◆ USER_DATA_FAVICON

str constants.USER_DATA_FAVICON = "NULL"

Definition at line 292 of file constants.py.

◆ USER_DATA_METHOD

str constants.USER_DATA_METHOD = "local"

Definition at line 291 of file constants.py.

◆ USER_DATA_PASSWORD

str constants.USER_DATA_PASSWORD
Initial value:
1= _password_generator(
2 length=20, encapsulation_node="some_user"
3)

Definition at line 288 of file constants.py.

◆ USER_DATA_PASSWORD_PATCH

str constants.USER_DATA_PASSWORD_PATCH
Initial value:
1= _password_generator(
2 length=20, encapsulation_node="some_user_patch"
3)

Definition at line 307 of file constants.py.

◆ USER_DATA_PASSWORD_REBIND

str constants.USER_DATA_PASSWORD_REBIND
Initial value:
1= _password_generator(
2 length=20, encapsulation_node="some_user_rebind"
3)

Definition at line 300 of file constants.py.

◆ USER_DATA_TOKEN

str constants.USER_DATA_TOKEN = f"some_token_{CACHE_BUSTER}_some_token"

Definition at line 294 of file constants.py.

◆ USER_DATA_TOKEN_LIFESPAN

int constants.USER_DATA_TOKEN_LIFESPAN = 3600

Definition at line 295 of file constants.py.

◆ USER_DATA_USERNAME

str constants.USER_DATA_USERNAME = USER_DATA_EMAIL.split("@")[0]

Definition at line 287 of file constants.py.

◆ USER_DATA_USERNAME_PATCH

str constants.USER_DATA_USERNAME_PATCH = USER_DATA_EMAIL_PATCH.split("@")[0]

Definition at line 306 of file constants.py.

◆ USER_DATA_USERNAME_REBIND

str constants.USER_DATA_USERNAME_REBIND = USER_DATA_EMAIL_REBIND.split("@")[0]

Definition at line 299 of file constants.py.

◆ USER_NORMAL_MODE

str constants.USER_NORMAL_MODE = "normal"

Definition at line 347 of file constants.py.

◆ USER_PATCH_MODE

str constants.USER_PATCH_MODE = "patch"

Definition at line 349 of file constants.py.

◆ USER_PUT_MODE

str constants.USER_PUT_MODE = "put"

Definition at line 348 of file constants.py.