mirror of
https://github.com/chatmail/relay.git
synced 2026-05-10 16:04:37 +00:00
count ci accounts correctly
This commit is contained in:
@@ -4,14 +4,16 @@ import time
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main(vmail_dir=None):
|
||||||
vmail_dir = sys.argv[1]
|
if vmail_dir is None:
|
||||||
|
vmail_dir = sys.argv[1]
|
||||||
|
|
||||||
accounts = 0
|
accounts = 0
|
||||||
ci_accounts = 0
|
ci_accounts = 0
|
||||||
|
|
||||||
for path in Path(vmail_dir).iterdir():
|
for path in Path(vmail_dir).iterdir():
|
||||||
accounts += 1
|
accounts += 1
|
||||||
if path.name.startswith("ci-"):
|
if path.name[:3] in ("ci-", "ac_"):
|
||||||
ci_accounts += 1
|
ci_accounts += 1
|
||||||
|
|
||||||
timestamp = int(time.time() * 1000)
|
timestamp = int(time.time() * 1000)
|
||||||
|
|||||||
16
chatmaild/src/chatmaild/tests/test_metrics.py
Normal file
16
chatmaild/src/chatmaild/tests/test_metrics.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
from chatmaild.metrics import main
|
||||||
|
|
||||||
|
|
||||||
|
def test_main(tmp_path, capsys):
|
||||||
|
for x in ("ci-asllkj", "ac_12l3kj", "qweqwe", "ci-l1k2j31l2k3"):
|
||||||
|
tmp_path.joinpath(x).mkdir()
|
||||||
|
main(tmp_path)
|
||||||
|
out, _ = capsys.readouterr()
|
||||||
|
d = {}
|
||||||
|
for line in out.split("\n"):
|
||||||
|
if line.strip():
|
||||||
|
name, num, _ = line.split()
|
||||||
|
d[name] = int(num)
|
||||||
|
|
||||||
|
assert d["accounts"] == 4
|
||||||
|
assert d["ci_accounts"] == 3
|
||||||
Reference in New Issue
Block a user