change: add weight attribute in config

This commit is contained in:
debugtalk
2020-06-18 17:19:34 +08:00
parent 2dcbee79e0
commit fed8d5adaf
2 changed files with 13 additions and 2 deletions

View File

@@ -41,6 +41,7 @@ class TConfig(BaseModel):
# teardown_hooks: Hooks = [] # teardown_hooks: Hooks = []
export: Export = [] export: Export = []
path: Text = None path: Text = None
weight: int = 1
class TRequest(BaseModel): class TRequest(BaseModel):

View File

@@ -17,18 +17,23 @@ class Config(object):
self.__base_url = "" self.__base_url = ""
self.__verify = False self.__verify = False
self.__export = [] self.__export = []
self.__weight = 1
caller_frame = inspect.stack()[1] caller_frame = inspect.stack()[1]
self.__path = caller_frame.filename self.__path = caller_frame.filename
@property @property
def name(self): def name(self) -> Text:
return self.__name return self.__name
@property @property
def path(self): def path(self) -> Text:
return self.__path return self.__path
@property
def weight(self) -> int:
return self.__weight
def variables(self, **variables) -> "Config": def variables(self, **variables) -> "Config":
self.__variables.update(variables) self.__variables.update(variables)
return self return self
@@ -45,6 +50,10 @@ class Config(object):
self.__export.extend(export_var_name) self.__export.extend(export_var_name)
return self return self
def locust_weight(self, weight: int) -> "Config":
self.__weight = weight
return self
def perform(self) -> TConfig: def perform(self) -> TConfig:
return TConfig( return TConfig(
name=self.__name, name=self.__name,
@@ -53,6 +62,7 @@ class Config(object):
variables=self.__variables, variables=self.__variables,
export=list(set(self.__export)), export=list(set(self.__export)),
path=self.__path, path=self.__path,
weight=self.__weight,
) )