-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathtest.py
More file actions
63 lines (51 loc) · 2.02 KB
/
test.py
File metadata and controls
63 lines (51 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import argparse
import logging
import sys
from sephera.CodeLoc import CodeLoc
from datalyzer.sql import SqlManager
from utils.utils import Utils
class SepheraTest:
def __init__(self) -> None:
self.log = logging
self.log.basicConfig(level = logging.DEBUG, format = "%(asctime)s - %(levelname)s - %(message)s")
self.args: argparse.ArgumentParser = argparse.ArgumentParser()
self.subparsers = self.args.add_subparsers(dest = "command")
self.test_command = self.subparsers.add_parser(
"test", help = "Run test cases",
)
self.test_command.add_argument(
"command",
nargs = "*",
help = "Test cases"
)
self.parser_args = self.args.parse_args()
if self.parser_args.command:
self.match_args(args = str(self.parser_args.command[0]))
else:
self.log.error("No test case provided.")
sys.exit(1)
def match_args(self, args: str) -> None:
match args.lower().strip():
case "loc":
codeLoc = CodeLoc(".")
codeLoc.stdout_result()
case "fetch-version":
utils = Utils()
version = utils.fetch_latest_version()
self.log.debug(version)
case "is-latest":
utils = Utils()
isLatestVersion = utils.is_latest_version()
if isLatestVersion:
self.log.debug("This binary of Sephera is latest version")
else:
self.log.debug("This binary of Sephera it not a latest version")
case "cfg-path":
sql = SqlManager()
utils = Utils()
sql.connect_to_sql(f"{utils.get_local_data()}/.config/Sephera/settings.db")
self.log.debug(sql.get_cfg_path())
case _:
self.log.error(f"Test case: {args} not found.")
sys.exit(1)
_ = SepheraTest()