2 File in charge of testing the boilerplate Boilerplate non http class.
6from datetime
import datetime, timedelta
9from fastapi
import FastAPI
10import constants
as TCONST
12sys.path.append(os.getcwd())
20except ImportError
as e:
21 raise ImportError(
"Failed to import the src module")
from e
25SUCCESS = TCONST.SUCCESS
26RDI =
RuntimeData(TCONST.SERVER_HOST, 5000, TCONST.PORT, ERROR, SUCCESS)
34RDI.database_link =
SQL(
37 username=CONST.DB_USER,
38 password=CONST.DB_PASSWORD,
39 db_name=CONST.DB_DATABASE,
45 runtime_data_initialised=RDI,
54 Function in charge of testing the pause function.
57 monkeypatch.setattr(
'builtins.input',
lambda _: test)
58 data = BNHTTPI.pause()
64 Function in charge of testing the set lifespan function.
67 src: datetime = datetime.now() + timedelta(seconds=delay)
68 data: datetime = BNHTTPI.set_lifespan(delay)
70 "%d/%m/%Y, %H:%M:%S") == src.strftime(
"%d/%m/%Y, %H:%M:%S")
75 Function in charge of testing the generate token function.
77 token = BNHTTPI.generate_token()
78 assert isinstance(token, str)
79 assert len(token) == 36
80 assert token.count(
"-") == 4
85 Function in charge of testing the check date function with a correct date.
87 assert BNHTTPI.check_date(
"11/09/2001")
is True
92 Function in charge of testing the check date function with an incorrect date.
94 assert BNHTTPI.check_date(
"32/01/2021")
is False
99 Function in charge of testing the check date function with an incorrect date.
101 assert BNHTTPI.check_date(
"12/13/2021")
is False
106 Function in charge of testing the check date function with an incorrect date.
108 assert BNHTTPI.check_date(
"12/12/2O21")
is False
113 Function in charge of testing the check date function with an incorrect date.
115 assert BNHTTPI.check_date(
"12-12-2021")
is False
120 Function in charge of testing the generate_check_token function with 4.
122 code = BNHTTPI.generate_check_token(token_size=4)
123 assert isinstance(code, str)
125 assert code.count(
'-') == 4
130 Function in charge of testing the generate_check_token function with 0.
132 code = BNHTTPI.generate_check_token(token_size=0)
133 assert isinstance(code, str)
135 assert code.count(
'-') == 0
140 Function in charge of testing the generate_check_token function with a negative number.
142 code = BNHTTPI.generate_check_token(token_size=-1)
143 assert isinstance(code, str)
145 assert code.count(
'-') == 0
150 Function in charge of testing the generate_check_token function with a string.
152 code = BNHTTPI.generate_check_token(token_size=
"e")
153 assert isinstance(code, str)
155 assert code.count(
'-') == 4
160 Function in charge of testing the generate_check_token function with a floating number.
162 code = BNHTTPI.generate_check_token(token_size=4.8)
163 assert isinstance(code, str)
165 assert code.count(
'-') == 4
170 Function in charge of testing the generate_check_token function with a negative floating number.
172 code = BNHTTPI.generate_check_token(token_size=-4.5)
173 assert isinstance(code, str)
175 assert code.count(
'-') == 0
None test_check_incorrect_format()
None test_check_date_incorrect_month()
None test_generate_token()
None test_pause(pytest.MonkeyPatch monkeypatch)
None test_check_token_generator_size_floating_number()
None test_check_date_incorrect_year()
None test_check_token_generator_size_0()
None test_check_date_incorrect_day()
None test_check_token_generator_size_negative_floating_number()
None test_check_token_generator_size_negative_number()
None test_check_date_correct()
None test_check_token_generator()
None test_check_token_generator_string_as_arg()