Implement test analitics export into TMS systems
Signed-off-by: Aleksei Chetaev <alex.chetaev@gmail.com>
This commit is contained in:
parent
5d2963faea
commit
9d21d1c143
6 changed files with 527 additions and 0 deletions
82
src/frostfs_testlib/analytics/test_case.py
Normal file
82
src/frostfs_testlib/analytics/test_case.py
Normal file
|
@ -0,0 +1,82 @@
|
|||
import allure
|
||||
|
||||
from enum import Enum
|
||||
from types import FunctionType
|
||||
|
||||
class TestCasePriority(Enum):
|
||||
HIGHEST = 0
|
||||
HIGH = 1
|
||||
MEDIUM = 2
|
||||
LOW = 3
|
||||
|
||||
def __set_label__(name: str, value: str, allure_decorator: FunctionType = None):
|
||||
"""
|
||||
Generic function for do not duplicate set label code in each decorator.
|
||||
We get decorated function as an object and set needed argument inside.
|
||||
|
||||
Args:
|
||||
name: argument name to set into the function object
|
||||
value: argument value to set into the function object
|
||||
allure_decorator: allure decorator to decorate function and do not duplicate decorators with same value
|
||||
"""
|
||||
def wrapper(decorated_func):
|
||||
if allure_decorator:
|
||||
decorated_func = allure_decorator(value)(decorated_func)
|
||||
setattr(decorated_func, name, value)
|
||||
return decorated_func
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
def id(uuid: str):
|
||||
"""
|
||||
Decorator for set test case ID which can be used as unique value due export into TMS.
|
||||
|
||||
We prefer to use UUID4 format string for ID.
|
||||
ID have to be generated manually for each new test.
|
||||
|
||||
Args:
|
||||
uuid: id to set as test_case_id into test function
|
||||
"""
|
||||
return __set_label__("__test_case_id__", uuid)
|
||||
|
||||
|
||||
def title(title: str):
|
||||
"""
|
||||
Decorator for set test case title / name / summary / short description what we do.
|
||||
|
||||
Args:
|
||||
title: string with title to set into test function
|
||||
"""
|
||||
|
||||
return __set_label__("__test_case_title__", title, allure.title)
|
||||
|
||||
def priority(priority: str):
|
||||
"""
|
||||
Decorator for set test case title / name / summary / short description what we do.
|
||||
|
||||
Args:
|
||||
priority: string with priority to set into test function
|
||||
"""
|
||||
|
||||
return __set_label__("__test_case_priority__", priority)
|
||||
|
||||
|
||||
def suite_name(name: str):
|
||||
"""
|
||||
Decorator for set test case suite name.
|
||||
Suite name is usually using in TMS for create structure of test cases.
|
||||
|
||||
Args:
|
||||
name: string with test suite name for set into test function
|
||||
"""
|
||||
|
||||
return __set_label__("__test_case_suite_name__", name, allure.story)
|
||||
|
||||
|
||||
def suite_section(name: str):
|
||||
"""
|
||||
Decorator for set test case suite section.
|
||||
Suite section is usually using in TMS for create deep test cases structure.
|
||||
"""
|
||||
return __set_label__("__test_case_suite_section__", name)
|
Loading…
Add table
Add a link
Reference in a new issue