bots: Move contrib_bots to api/bots*.
This will make it convenient to include these bots in Zulip API releases on pypi. Fix #5009.
This commit is contained in:
parent
7531c4fb26
commit
894adb1e43
110 changed files with 36 additions and 27 deletions
44
bots_api/test-bots
Executable file
44
bots_api/test-bots
Executable file
|
@ -0,0 +1,44 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
from unittest import TestCase
|
||||
|
||||
def dir_join(dir1, dir2):
|
||||
# type: (str, str) -> str
|
||||
return os.path.abspath(os.path.join(dir1, dir2))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
description = 'Script to run test_<bot>.py files in bots/<bot> directories'
|
||||
parser = argparse.ArgumentParser(description=description)
|
||||
parser.add_argument('--bot',
|
||||
nargs=1,
|
||||
type=str,
|
||||
action='store',
|
||||
help='test specified single bot')
|
||||
args = parser.parse_args()
|
||||
|
||||
bots_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
root_dir = dir_join(bots_dir, '..')
|
||||
bots_test_dir = dir_join(bots_dir, '../bots')
|
||||
|
||||
sys.path.insert(0, root_dir)
|
||||
sys.path.insert(0, bots_test_dir)
|
||||
|
||||
# mypy doesn't recognize the TestLoader attribute, even though the code
|
||||
# is executable
|
||||
loader = unittest.TestLoader() # type: ignore
|
||||
if args.bot is not None:
|
||||
bots_test_dir = dir_join(bots_test_dir, args.bot[0])
|
||||
suite = loader.discover(start_dir=bots_test_dir, top_level_dir=root_dir)
|
||||
runner = unittest.TextTestRunner(verbosity=2)
|
||||
# same issue as for TestLoader
|
||||
result = runner.run(suite) # type: ignore
|
||||
if result.errors or result.failures:
|
||||
raise Exception('Test failed!')
|
Loading…
Add table
Add a link
Reference in a new issue