1.0
This commit is contained in:
31
tests/get_info_level_contract_test.py
Normal file
31
tests/get_info_level_contract_test.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def main() -> int:
|
||||
source = Path(__file__).resolve().parents[1] / "src" / "app.cpp"
|
||||
text = source.read_text(encoding="utf-8-sig")
|
||||
|
||||
match = re.search(
|
||||
r"Response Application::handle_get_info\(const Request &request\) \{(?P<body>.*?)\n\}",
|
||||
text,
|
||||
re.S,
|
||||
)
|
||||
if not match:
|
||||
raise AssertionError("handle_get_info definition not found")
|
||||
|
||||
body = match.group("body")
|
||||
if 'body["level"] = user->level;' not in body:
|
||||
raise AssertionError('missing `body["level"] = user->level;` in handle_get_info')
|
||||
if 'body["uservip"] = membership_label(user->level);' not in body:
|
||||
raise AssertionError('missing dynamic `uservip` mapping in handle_get_info')
|
||||
|
||||
print("get_info level contract test passed")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user