Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,14 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}
base-path: ./${{ matrix.package }}/src
flag-name: ${{ matrix.package }}
parallel: true

finish:
needs: validate
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
15 changes: 13 additions & 2 deletions testit-adapter-behave/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ Description of tags:
- `ExternalId` - unique internal autotest ID (used in Test IT)
- `Title` - autotest name specified in the autotest card. If not specified, the name from the displayName method is used
- `Description` - autotest description specified in the autotest card
- `Labels` - tags listed in the autotest card
- `Labels` - labels listed in the autotest card
- `Tags` - tags listed in the autotest card
- `Links` - links listed in the autotest card
- `NameSpace` - directory in the TMS system (default - file's name of test)
- `ClassName` - subdirectory in the TMS system (default - class's name of test)
Expand All @@ -113,9 +114,19 @@ If you want to insert a space in the tags, use the "\\_" character combination.

Description of methods:

- `testit.addWorkItemIds` - a dynamic method that links autotests with manual tests. Receives the array of manual tests' IDs
- `testit.addDisplayName` - a dynamic method for adding internal autotest name (used in Test IT)
- `testit.addExternalId` - a dynamic method for adding unique internal autotest ID (used in Test IT)
- `testit.addTitle` - a dynamic method for adding autotest name specified in the autotest card. If not specified, the name from the displayName method is used
- `testit.addDescription` - a dynamic method for adding autotest description specified in the autotest card
- `testit.addLabels` - a dynamic method for adding labels listed in the autotest card
- `testit.addTags` - a dynamic method for adding tags listed in the autotest card
- `testit.addLinks` - links in the autotest result
- `testit.addAttachments` - uploading files in the autotest result
- `testit.addMessage` - information about autotest in the autotest result
- `testit.addNameSpace` - a dynamic method for adding directory in the TMS system (default - file's name of test)
- `testit.addClassName` - a dynamic method for adding subdirectory in the TMS system (default - class's name of test)
- `testit.addParameter` - a dynamic method for adding parameter in the autotest result
- `testit.step` - usage in the "with" construct to designation a step in the body of the test

### Examples
Expand Down Expand Up @@ -173,7 +184,7 @@ Feature: Sample
@WorkItemIds=123
@Title=Title_in_the_autotest_card
@Description=Test_with_all_annotations
@Labels=Tag1,Tag2
@Tags=Tag1,Tag2
@Links={"url":"https://dumps.example.com/module/repository","title":"Repository","description":"Example_of_repository","type":"Repository"}
Scenario: Create new project, section and test case
When I create a project
Expand Down
2 changes: 1 addition & 1 deletion testit-adapter-behave/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import find_packages, setup

VERSION = "3.12.0"
VERSION = "3.12.1"

setup(
name='testit-adapter-behave',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ class TagType:
WORK_ITEM_IDS = 'WorkItemIds='
DESCRIPTION = 'Description='
LABELS = 'Labels='
TAGS = 'Tags='
NAMESPACE = 'NameSpace='
CLASSNAME = 'ClassName='
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from testit_python_commons.models.outcome_type import OutcomeType

from .models.tags import TagType
from .tags_parser import parse_tags
from .tags_parser import parse_test_tags

STATUS = {
'passed': OutcomeType.PASSED,
Expand All @@ -16,7 +16,7 @@


def parse_scenario(scenario):
tags = parse_tags(scenario.tags + scenario.feature.tags)
tags = parse_test_tags(scenario.tags + scenario.feature.tags)

# TODO: Add model to python-commons; implement via attrs
executable_test = {
Expand Down Expand Up @@ -45,6 +45,7 @@ def parse_scenario(scenario):
'description': None,
'links': [],
'labels': [],
'tags': [],
'workItemsID': [],
"externalKey": get_scenario_name(scenario)
# TODO: Add to python-commons
Expand All @@ -64,6 +65,9 @@ def parse_scenario(scenario):
if TagType.LABELS in tags:
executable_test['labels'] = tags[TagType.LABELS]

if TagType.TAGS in tags:
executable_test['tags'] = tags[TagType.TAGS]

if TagType.NAMESPACE in tags:
executable_test['namespace'] = tags[TagType.NAMESPACE]

Expand Down
52 changes: 33 additions & 19 deletions testit-adapter-behave/src/testit_adapter_behave/tags_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,69 +3,83 @@
from .models.url_link import get_url_to_link_model, get_dict_to_link_model


def parse_tags(tags):
def parse_test_tags(tags):
parsed_tags = {
TagType.LINKS: [],
TagType.LABELS: [],
TagType.TAGS: [],
TagType.WORK_ITEM_IDS: []
}

for tag in tags:
if TagType.EXTERNAL_ID in tag:
parsed_tags[TagType.EXTERNAL_ID] = parse_space_in_tag(tag[len(TagType.EXTERNAL_ID):])
parsed_tags[TagType.EXTERNAL_ID] = __parse_space_in_tag(tag[len(TagType.EXTERNAL_ID):])

elif TagType.DISPLAY_NAME in tag:
parsed_tags[TagType.DISPLAY_NAME] = parse_space_in_tag(tag[len(TagType.DISPLAY_NAME):])
parsed_tags[TagType.DISPLAY_NAME] = __parse_space_in_tag(tag[len(TagType.DISPLAY_NAME):])

elif TagType.LINKS in tag:
parsed_tags[TagType.LINKS].extend(
parse_links(
__parse_links(
tag[len(TagType.LINKS):]))

elif TagType.TITLE in tag:
parsed_tags[TagType.TITLE] = parse_space_in_tag(tag[len(TagType.TITLE):])
parsed_tags[TagType.TITLE] = __parse_space_in_tag(tag[len(TagType.TITLE):])

elif TagType.WORK_ITEM_IDS in tag:
parsed_tags[TagType.WORK_ITEM_IDS].extend(
parse_massive(
__parse_massive(
tag[len(TagType.WORK_ITEM_IDS):]))

elif TagType.DESCRIPTION in tag:
parsed_tags[TagType.DESCRIPTION] = parse_space_in_tag(tag[len(TagType.DESCRIPTION):])
parsed_tags[TagType.DESCRIPTION] = __parse_space_in_tag(tag[len(TagType.DESCRIPTION):])

elif TagType.LABELS in tag:
parsed_tags[TagType.LABELS].extend(
parse_labels(
__parse_labels(
tag[len(TagType.LABELS):]))

elif TagType.TAGS in tag:
parsed_tags[TagType.TAGS].extend(
__parse_tags(
tag[len(TagType.TAGS):]))

elif TagType.NAMESPACE in tag:
parsed_tags[TagType.NAMESPACE] = parse_space_in_tag(tag[len(TagType.NAMESPACE):])
parsed_tags[TagType.NAMESPACE] = __parse_space_in_tag(tag[len(TagType.NAMESPACE):])

elif TagType.CLASSNAME in tag:
parsed_tags[TagType.CLASSNAME] = parse_space_in_tag(tag[len(TagType.CLASSNAME):])
parsed_tags[TagType.CLASSNAME] = __parse_space_in_tag(tag[len(TagType.CLASSNAME):])

return parsed_tags


def parse_massive(tag: str):
def __parse_massive(tag: str):
return tag.split(',')


def parse_labels(tag):
def __parse_labels(tag):
parsed_labels = []

for label in parse_massive(tag):
for label in __parse_massive(tag):
parsed_labels.append(get_label_model(label))

return parsed_labels


def parse_links(tag: str):
def __parse_tags(tag):
parsed_tags = []

for tms_tag in __parse_massive(tag):
parsed_tags.append(tms_tag)

return parsed_tags


def __parse_links(tag: str):
parsed_links = []
json_links = parse_json(tag)
json_links = __parse_json(tag)

if not json_links:
for url in parse_massive(tag):
for url in __parse_massive(tag):
parsed_links.append(get_url_to_link_model(url))

if isinstance(json_links, tuple):
Expand All @@ -78,12 +92,12 @@ def parse_links(tag: str):
return parsed_links


def parse_json(json_string: str):
def __parse_json(json_string: str):
try:
return eval(json_string)
except Exception:
return


def parse_space_in_tag(tag: str) -> str:
def __parse_space_in_tag(tag: str) -> str:
return tag.replace('\\_', ' ')
9 changes: 5 additions & 4 deletions testit-adapter-behave/src/testit_adapter_behave/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from .models.option import Option
from .models.tags import TagType
from .scenario_parser import get_scenario_external_id, get_scenario_parameters
from .tags_parser import parse_tags
from .tags_parser import parse_test_tags


def parse_userdata(userdata):
Expand Down Expand Up @@ -82,7 +82,7 @@ def filter_out_scenarios(tests_for_launch, scenarios):


def validate_scenario(scenario, tests_for_launch) -> bool:
tags = parse_tags(scenario.tags + scenario.feature.tags)
tags = parse_test_tags(scenario.tags + scenario.feature.tags)
external_id = tags[TagType.EXTERNAL_ID] if \
TagType.EXTERNAL_ID in tags and tags[TagType.EXTERNAL_ID] else get_scenario_external_id(scenario)

Expand Down Expand Up @@ -141,8 +141,9 @@ def convert_executable_test_to_test_result_model(executable_test: dict) -> TestR
.set_title(executable_test['title'])\
.set_description(executable_test['description'])\
.set_links(executable_test['links'])\
.set_result_links(executable_test['resultLinks'])\
.set_labels(executable_test['labels'])\
.set_result_links(executable_test['resultLinks']) \
.set_labels(executable_test['labels']) \
.set_tags(executable_test['tags'])\
.set_work_item_ids(executable_test['workItemsID'])\
.set_message(executable_test['message'])\
.set_external_key(executable_test['externalKey'])
Expand Down
15 changes: 13 additions & 2 deletions testit-adapter-nose/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ Description of decorators:
- `testit.externalId` - unique internal autotest ID (used in Test IT)
- `testit.title` - autotest name specified in the autotest card. If not specified, the name from the displayName method is used
- `testit.description` - autotest description specified in the autotest card
- `testit.labels` - tags listed in the autotest card
- `testit.labels` - labels listed in the autotest card
- `testit.tags` - tags listed in the autotest card
- `testit.link` - links listed in the autotest card
- `testit.step` - the designation of the step called in the body of the test or other step
- `testit.nameSpace` - directory in the TMS system (default - file's name of test)
Expand All @@ -104,9 +105,19 @@ All decorators support the use of parameterization attributes

Description of methods:

- `testit.addWorkItemIds` - a dynamic method that links autotests with manual tests. Receives the array of manual tests' IDs
- `testit.addDisplayName` - a dynamic method for adding internal autotest name (used in Test IT)
- `testit.addExternalId` - a dynamic method for adding unique internal autotest ID (used in Test IT)
- `testit.addTitle` - a dynamic method for adding autotest name specified in the autotest card. If not specified, the name from the displayName method is used
- `testit.addDescription` - a dynamic method for adding autotest description specified in the autotest card
- `testit.addLabels` - a dynamic method for adding labels listed in the autotest card
- `testit.addTags` - a dynamic method for adding tags listed in the autotest card
- `testit.addLinks` - links in the autotest result
- `testit.addAttachments` - uploading files in the autotest result
- `testit.addMessage` - information about autotest in the autotest result
- `testit.addNameSpace` - a dynamic method for adding directory in the TMS system (default - file's name of test)
- `testit.addClassName` - a dynamic method for adding subdirectory in the TMS system (default - class's name of test)
- `testit.addParameter` - a dynamic method for adding parameter in the autotest result
- `testit.step` - usage in the "with" construct to designation a step in the body of the test

### Examples
Expand Down Expand Up @@ -163,7 +174,7 @@ from nose2.tools import params
@testit.displayName('param {num}')
@testit.title('Test with params')
@testit.description('E2E_autotest')
@testit.labels('parameters', 'test')
@testit.tags('parameters', 'test')
@testit.links(url='https://dumps.example.com/module/JCP-777')
@testit.links(url='https://dumps.example.com/module/JCP-777',
title='JCP-777',
Expand Down
2 changes: 1 addition & 1 deletion testit-adapter-nose/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages

VERSION = "3.12.0"
VERSION = "3.12.1"

setup(
name='testit-adapter-nose',
Expand Down
34 changes: 29 additions & 5 deletions testit-adapter-nose/src/testit_adapter_nose/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def form_test(item, top_level_directory):
'description': __get_description_from(item, function),
'links': __get_links_from(item, function),
'labels': __get_labels_from(item, function),
'tags': __get_tags_from(item, function),
'workItemsID': __get_work_item_ids_from(item, function),
'message': None,
'externalKey': __get_fullname(function, top_level_directory)
Expand Down Expand Up @@ -192,7 +193,7 @@ def __set_parameters_to_links(links, all_parameters):
return links_with_parameters


def __get_labels_from(item, function):
def __get_labels_from(item, function) -> List[dict]:
test_labels = __search_attribute(function, 'test_labels')

if not test_labels:
Expand All @@ -206,9 +207,9 @@ def __get_labels_from(item, function):
get_all_parameters(item))

if isinstance(result, __ARRAY_TYPES):
for label in result:
for l in result:
labels.append({
'name': str(label)
'name': str(l)
})
else:
labels.append({
Expand All @@ -218,6 +219,28 @@ def __get_labels_from(item, function):
return labels


def __get_tags_from(item, function) -> List[str]:
test_tags = __search_attribute(function, 'test_tags')

if not test_tags:
return []

tags = []

for tag in test_tags:
result = collect_parameters_in_mass_attribute(
tag,
get_all_parameters(item))

if isinstance(result, __ARRAY_TYPES):
for t in result:
tags.append(str(t))
else:
tags.append(str(result))

return tags


def __get_work_item_ids_from(item, function):
test_workitems_id = __search_attribute(function, 'test_workitems_id')

Expand Down Expand Up @@ -373,8 +396,9 @@ def convert_executable_test_to_test_result_model(executable_test: dict) -> TestR
.set_title(executable_test['title'])\
.set_description(executable_test['description'])\
.set_links(executable_test['links'])\
.set_result_links(executable_test['resultLinks'])\
.set_labels(executable_test['labels'])\
.set_result_links(executable_test['resultLinks']) \
.set_labels(executable_test['labels']) \
.set_tags(executable_test['tags'])\
.set_work_item_ids(executable_test['workItemsID'])\
.set_message(executable_test['message'])\
.set_external_key(executable_test['externalKey'])
Loading