mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 19:39:44 +08:00
create scaffold
This commit is contained in:
@@ -1 +1 @@
|
||||
__version__ = '0.7.3'
|
||||
__version__ = '0.7.4'
|
||||
10
ate/cli.py
10
ate/cli.py
@@ -6,6 +6,7 @@ from collections import OrderedDict
|
||||
|
||||
from ate import __version__
|
||||
from ate.task import TaskSuite
|
||||
from ate.utils import create_scaffold
|
||||
|
||||
import PyUnitReport
|
||||
|
||||
@@ -30,6 +31,9 @@ def main_ate():
|
||||
parser.add_argument(
|
||||
'--failfast', action='store_true', default=False,
|
||||
help="Stop the test run on the first error or failure.")
|
||||
parser.add_argument(
|
||||
'--startproject',
|
||||
help="Specify new project name.")
|
||||
|
||||
try:
|
||||
from jenkins_mail_py import MailgunHelper
|
||||
@@ -46,6 +50,12 @@ def main_ate():
|
||||
log_level = getattr(logging, args.log_level.upper())
|
||||
logging.basicConfig(level=log_level)
|
||||
|
||||
project_name = args.startproject
|
||||
if project_name:
|
||||
project_path = os.path.join(os.getcwd(), project_name)
|
||||
create_scaffold(project_path)
|
||||
exit(0)
|
||||
|
||||
report_name = args.report_name
|
||||
if report_name and len(args.testset_paths) > 1:
|
||||
report_name = None
|
||||
|
||||
26
ate/utils.py
26
ate/utils.py
@@ -405,3 +405,29 @@ def print_output(output):
|
||||
content += "============================================\n"
|
||||
|
||||
logging.debug(content)
|
||||
|
||||
def create_scaffold(project_path):
|
||||
logging.info(" Start to create new project: {}".format(project_path))
|
||||
|
||||
if os.path.isdir(project_path):
|
||||
folder_name = os.path.basename(project_path)
|
||||
logging.warning(" Folder {} exists, please specify a new folder name.".format(folder_name))
|
||||
return
|
||||
|
||||
def create_path(path, ptype):
|
||||
if ptype == "folder":
|
||||
os.makedirs(path)
|
||||
elif ptype == "file":
|
||||
open(path, 'w').close()
|
||||
|
||||
logging.info("\tcreated {}: {}".format(ptype, path))
|
||||
|
||||
path_list = [
|
||||
(project_path, "folder"),
|
||||
(os.path.join(project_path, "tests"), "folder"),
|
||||
(os.path.join(project_path, "tests", "api"), "folder"),
|
||||
(os.path.join(project_path, "tests", "suite"), "folder"),
|
||||
(os.path.join(project_path, "tests", "testcases"), "folder"),
|
||||
(os.path.join(project_path, "tests", "debugtalk.py"), "file")
|
||||
]
|
||||
[create_path(p[0], p[1]) for p in path_list]
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
import shutil
|
||||
from collections import OrderedDict
|
||||
|
||||
from ate import exception, utils
|
||||
@@ -308,3 +309,13 @@ class TestUtils(ApiServerUnittest):
|
||||
override_mapping = {"a": 3, "c": 4}
|
||||
with self.assertRaises(exception.ParamsError):
|
||||
utils.override_variables_binds(map_list, override_mapping)
|
||||
|
||||
def test_create_scaffold(self):
|
||||
project_path = os.path.join(os.getcwd(), "projectABC")
|
||||
utils.create_scaffold(project_path)
|
||||
self.assertTrue(os.path.isdir(os.path.join(project_path, "tests")))
|
||||
self.assertTrue(os.path.isdir(os.path.join(project_path, "tests", "api")))
|
||||
self.assertTrue(os.path.isdir(os.path.join(project_path, "tests", "suite")))
|
||||
self.assertTrue(os.path.isdir(os.path.join(project_path, "tests", "testcases")))
|
||||
self.assertTrue(os.path.isfile(os.path.join(project_path, "tests", "debugtalk.py")))
|
||||
shutil.rmtree(project_path)
|
||||
|
||||
Reference in New Issue
Block a user