2 File in charge of testing the paths class.
6from fastapi
import Request, Response, FastAPI
7import constants
as TCONST
9sys.path.append(os.getcwd())
16except ImportError
as e:
17 raise ImportError(
"Failed to import the src module")
from e
22 Function in charge of testing if the current password is the same as the hashed version.
24 return {
"msg":
"Hello World !"}
28SUCCESS = TCONST.SUCCESS
30RDI =
RuntimeData(TCONST.SERVER_HOST, TCONST.PORT,
"Area", ERROR, SUCCESS)
50RDI.paths_initialised = SPI
55 Function in charge of testing if the current password is the same as the hashed version.
57 status = SPI.add_path(
62 assert status == SUCCESS
63 assert len(SPI.routes) == 1
64 assert SPI.routes[0][PATH_KEY] ==
"/dummy_path"
65 assert SPI.routes[0][ENDPOINT_KEY]
is dummy_path
66 assert SPI.routes[0][METHOD_KEY] == [
"GET"]
71 Function in charge of testing the load_default_paths_initialised
73 SPI.load_default_paths_initialised()
74 assert len(SPI.routes) > 0
76 assert isinstance(i[PATH_KEY], str)
is True
77 assert callable(i[ENDPOINT_KEY])
is True
78 assert isinstance(i[METHOD_KEY], list)
is True
79 assert len(i[METHOD_KEY]) > 0
80 for methods
in i[METHOD_KEY]:
81 assert isinstance(methods, str)
is True
82 assert methods
in ALLOWED_METHODS
87 Function in charge of testing the inject_routes
89 SPI.add_path(
"/dd", dummy_path,
"GET")
90 SPI.load_default_paths_initialised()
93 except Exception
as e:
94 print(f
"error: {str(e)}")
None test_inject_routes()
Response dummy_path(Request request)
None test_load_default_paths()