53 """Fixture for setting up the environment once per module."""
56 host=TCONST.QUERY_HOST,
58 delay=TCONST.QUERY_DELAY
63 server: Server = Server(
64 host=TCONST.SERVER_HOST,
66 success=TCONST.SUCCESS,
72 active_thread: Thread = Thread(
74 daemon=
True, name=f
"{TCONST.APP_NAME}_server_thread"
79 print(
"Waiting for server to start (5 seconds delay)...")
81 if active_thread.is_alive()
is not True:
82 pytest.skip(
"(test_server) thread failed to start")
83 if server.is_running()
is not True:
84 pytest.skip(
"(test_server) Server is not running")
85 call = server.runtime_data_initialised.database_link.get_table_names()
86 if isinstance(call, int)
and call == server.error:
88 "(test_server) Server failed to connect to the database"
90 print(
"Server started.")
93 if server
is not None:
94 print(
"Shutting down server...")
96 print(
"Server stopped")
97 if active_thread.is_alive()
is True:
98 print(
"Stopping thread (5 seconds grace) ...")
99 active_thread.join(timeout=5)
100 print(
"Thread stopped.")
102 print(
"Thread already stopped.")
103 return TCONST.SUCCESS
106 loop = asyncio.get_event_loop()
107 return loop.run_until_complete(teardown())
109 request.addfinalizer(teardown_sync)
115 "success": TCONST.SUCCESS,
116 "error": TCONST.ERROR,
117 "thread": active_thread,
119 TCONST.LAMBDA_USER_TOKEN_KEY: {
120 TCONST.PRETTY_TOKEN_KEY: {TCONST.TOKEN_AUTH_ID_STR:
""},
121 TCONST.RAW_TOKEN_KEY:
""
123 TCONST.ADMIN_USER_TOKEN_KEY: {
124 TCONST.PRETTY_TOKEN_KEY: {TCONST.TOKEN_AUTH_ID_STR:
""},
125 TCONST.RAW_TOKEN_KEY:
""
130 TCONST.USER_NORMAL_MODE: {
131 TCONST.UNODE_EMAIL_KEY: f
"endpoint_{TCONST.USER_DATA_EMAIL}",
132 TCONST.UNODE_PASSWORD_KEY: f
"endpoint_{TCONST.USER_DATA_PASSWORD}",
133 TCONST.UNODE_USERNAME_KEY: f
"endpoint_{TCONST.USER_DATA_USERNAME}",
134 TCONST.UNODE_METHOD_KEY: f
"{TCONST.USER_DATA_METHOD}",
135 TCONST.UNODE_FAVICON_KEY: f
"{TCONST.USER_DATA_FAVICON}",
136 TCONST.UNODE_ADMIN_KEY: f
"{TCONST.USER_DATA_ADMIN}"
138 TCONST.USER_PUT_MODE: {
139 TCONST.UNODE_EMAIL_KEY: f
"endpoint_{TCONST.USER_DATA_EMAIL_REBIND}",
140 TCONST.UNODE_PASSWORD_KEY: f
"endpoint_{TCONST.USER_DATA_PASSWORD_REBIND}",
141 TCONST.UNODE_USERNAME_KEY: f
"endpoint_{TCONST.USER_DATA_USERNAME_REBIND}",
142 TCONST.UNODE_METHOD_KEY: f
"{TCONST.USER_DATA_METHOD}",
143 TCONST.UNODE_FAVICON_KEY: f
"{TCONST.USER_DATA_FAVICON}",
144 TCONST.UNODE_ADMIN_KEY: f
"{TCONST.USER_DATA_ADMIN}"
146 TCONST.USER_PATCH_MODE: {
147 TCONST.UNODE_EMAIL_KEY: f
"endpoint_{TCONST.USER_DATA_EMAIL_PATCH}",
148 TCONST.UNODE_PASSWORD_KEY: f
"endpoint_{TCONST.USER_DATA_PASSWORD_PATCH}",
149 TCONST.UNODE_USERNAME_KEY: f
"endpoint_{TCONST.USER_DATA_USERNAME_PATCH}",
150 TCONST.UNODE_METHOD_KEY: f
"{TCONST.USER_DATA_METHOD}",
151 TCONST.UNODE_FAVICON_KEY: f
"{TCONST.USER_DATA_FAVICON}",
152 TCONST.UNODE_ADMIN_KEY: f
"{TCONST.USER_DATA_ADMIN}"
156 TCONST.USER_NORMAL_MODE: {
157 TCONST.UNODE_EMAIL_KEY: f
"endpoint_{TCONST.ADMIN_DATA_EMAIL}",
158 TCONST.UNODE_PASSWORD_KEY: f
"endpoint_{TCONST.ADMIN_DATA_PASSWORD}",
159 TCONST.UNODE_USERNAME_KEY: f
"endpoint_{TCONST.ADMIN_DATA_USERNAME}",
160 TCONST.UNODE_METHOD_KEY: f
"{TCONST.ADMIN_DATA_METHOD}",
161 TCONST.UNODE_FAVICON_KEY: f
"{TCONST.ADMIN_DATA_FAVICON}",
162 TCONST.UNODE_ADMIN_KEY: f
"{TCONST.ADMIN_DATA_ADMIN}"
164 TCONST.USER_PUT_MODE: {
165 TCONST.UNODE_EMAIL_KEY: f
"endpoint_{TCONST.ADMIN_DATA_EMAIL_REBIND}",
166 TCONST.UNODE_PASSWORD_KEY: f
"endpoint_{TCONST.ADMIN_DATA_PASSWORD_REBIND}",
167 TCONST.UNODE_USERNAME_KEY: f
"endpoint_{TCONST.ADMIN_DATA_USERNAME_REBIND}",
168 TCONST.UNODE_METHOD_KEY: f
"{TCONST.ADMIN_DATA_METHOD}",
169 TCONST.UNODE_FAVICON_KEY: f
"{TCONST.ADMIN_DATA_FAVICON}",
170 TCONST.UNODE_ADMIN_KEY: f
"{TCONST.ADMIN_DATA_ADMIN}"
172 TCONST.USER_PATCH_MODE: {
173 TCONST.UNODE_EMAIL_KEY: f
"endpoint_{TCONST.ADMIN_DATA_EMAIL_PATCH}",
174 TCONST.UNODE_PASSWORD_KEY: f
"endpoint_{TCONST.ADMIN_DATA_PASSWORD_PATCH}",
175 TCONST.UNODE_USERNAME_KEY: f
"endpoint_{TCONST.ADMIN_DATA_USERNAME_PATCH}",
176 TCONST.UNODE_METHOD_KEY: f
"{TCONST.ADMIN_DATA_METHOD}",
177 TCONST.UNODE_FAVICON_KEY: f
"{TCONST.ADMIN_DATA_FAVICON}",
178 TCONST.UNODE_ADMIN_KEY: f
"{TCONST.ADMIN_DATA_ADMIN}"
182 TCONST.RUNTIME_NODE_CRITICAL_KEY:
False,
183 "teardown_func": teardown_sync
187@pytest.mark.usefixtures("setup_environment")