| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- import pathlib
- test_file = pathlib.Path(__file__)
- test_dir = test_file.parent
- project_dir = test_dir.parent
- import sys
- sys.path.append(str(project_dir.absolute()))
- import source as communication
- def main():
- message = communication \
- .message_builder() \
- .set_key("test_key", "10") \
- .set_key("other", "20") \
- .set_key("in_section", "a", "sect") \
- .set_key("protocol", "https", "conn") \
- .set_key("ip", "10.0.0.1", "conn") \
- .build()
- def check_key(key: str, section: str | None, value: any) -> None:
- result = message.get_key(key, section) == value
- section = "default" if section is None else section
-
- if result:
- print("Work [" + section + "." + key + "]!")
- return
- print("Not work [" + section + "." + key + "]!")
- raise RuntimeError("Not property value!.")
- check_key("test_key", None, "10")
- check_key("other", None, "20")
- check_key("in_section", "sect", "a")
- check_key("protocol", "conn", "https")
- check_key("ip", "conn", "10.0.0.1")
-
- if __name__ == "__main__":
- main()
|