• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

testit-tms / adapters-python / 18900873859

29 Oct 2025 07:54AM UTC coverage: 36.921% (+0.03%) from 36.89%
18900873859

Pull #211

github

web-flow
Merge 26623bc01 into b45a2cdad
Pull Request #211: feat: TMS-35016: support for updating the test run name for all adapt…

32 of 68 new or added lines in 4 files covered. (47.06%)

75 existing lines in 1 file now uncovered.

1307 of 3540 relevant lines covered (36.92%)

0.74 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

72.15
/testit-python-commons/src/testit_python_commons/services/adapter_manager.py
1
import os
2✔
2
import uuid
2✔
3

4
from testit_python_commons.client.api_client import ApiClientWorker
2✔
5
from testit_python_commons.client.client_configuration import ClientConfiguration
2✔
6
from testit_python_commons.models.adapter_mode import AdapterMode
2✔
7
from testit_python_commons.models.test_result import TestResult
2✔
8
from testit_python_commons.services.fixture_manager import FixtureManager
2✔
9
from testit_python_commons.services.adapter_manager_configuration import AdapterManagerConfiguration
2✔
10
from testit_python_commons.services.logger import adapter_logger
2✔
11
from testit_python_commons.services.utils import Utils
2✔
12

13

14
class AdapterManager:
2✔
15
    def __init__(
2✔
16
            self,
17
            adapter_configuration: AdapterManagerConfiguration,
18
            client_configuration: ClientConfiguration,
19
            fixture_manager: FixtureManager):
20
        self.__config = adapter_configuration
2✔
21
        self.__api_client = ApiClientWorker(client_configuration)
2✔
22
        self.__fixture_manager = fixture_manager
2✔
23
        self.__test_result_map = {}
2✔
24
        self.__test_results = []
2✔
25

26
    @adapter_logger
2✔
27
    def set_test_run_id(self, test_run_id: str) -> None:
2✔
28
        self.__config.set_test_run_id(test_run_id)
2✔
29
        self.__api_client.set_test_run_id(test_run_id)
2✔
30

31
    @adapter_logger
2✔
32
    def get_test_run_id(self) -> str:
2✔
33
        if self.__config.get_mode() != AdapterMode.NEW_TEST_RUN:
2✔
NEW
34
            test_run_id = self.__config.get_test_run_id()
×
35

NEW
36
            self.__update_test_run_name(test_run_id)
×
37

NEW
38
            return test_run_id
×
39

40
        return self.__api_client.create_test_run(self.__config.get_test_run_name())
2✔
41

42
    @adapter_logger
2✔
43
    def __update_test_run_name(self, test_run_id: str) -> None:
2✔
NEW
44
        test_run_name = self.__config.get_test_run_name()
×
45

NEW
46
        if not test_run_name:
×
NEW
47
            return
×
48

NEW
49
        test_run = self.__api_client.get_test_run(test_run_id)
×
50

NEW
51
        if test_run_name == test_run.name:
×
NEW
52
            return
×
53

NEW
54
        test_run.name = test_run_name
×
55

NEW
56
        self.__api_client.update_test_run(test_run)
×
57

58
    @adapter_logger
2✔
59
    def get_autotests_for_launch(self):
2✔
60
        if self.__config.get_mode() == AdapterMode.USE_FILTER:
2✔
61
            return self.__api_client.get_external_ids_for_test_run_id()
2✔
62

63
        return
×
64

65
    @adapter_logger
2✔
66
    def write_test(self, test_result: TestResult) -> None:
2✔
67
        if self.__config.should_import_realtime():
×
68
            self.__write_test_realtime(test_result)
×
69

70
            return
×
71

72
        self.__test_results.append(test_result)
×
73

74
    @adapter_logger
2✔
75
    def __write_test_realtime(self, test_result: TestResult) -> None:
2✔
76
        test_result.set_automatic_creation_test_cases(
×
77
            self.__config.should_automatic_creation_test_cases())
78

79
        self.__test_result_map[test_result.get_external_id()] = self.__api_client.write_test(test_result)
×
80

81
    @adapter_logger
2✔
82
    def write_tests(self) -> None:
2✔
83
        if self.__config.should_import_realtime():
2✔
84
            self.__load_setup_and_teardown_step_results()
2✔
85

86
            return
2✔
87

88
        self.__write_tests_after_all()
×
89

90
    @adapter_logger
2✔
91
    def __load_setup_and_teardown_step_results(self) -> None:
2✔
92
        self.__api_client.update_test_results(self.__fixture_manager.get_all_items(), self.__test_result_map)
2✔
93

94
    @adapter_logger
2✔
95
    def __write_tests_after_all(self) -> None:
2✔
96
        fixtures = self.__fixture_manager.get_all_items()
×
97

98
        self.__api_client.write_tests(self.__test_results, fixtures)
×
99

100
    @adapter_logger
2✔
101
    def load_attachments(self, attach_paths: list or tuple):
2✔
102
        return self.__api_client.load_attachments(attach_paths)
2✔
103

104
    @adapter_logger
2✔
105
    def create_attachment(self, body, name: str):
2✔
106
        if name is None:
2✔
107
            name = str(uuid.uuid4()) + '-attachment.txt'
×
108

109
        path = os.path.join(os.path.abspath(''), name)
2✔
110

111
        with open(path, 'wb') as attached_file:
2✔
112
            attached_file.write(
2✔
113
                Utils.convert_body_of_attachment(body))
114

115
        attachment_id = self.__api_client.load_attachments((path,))
2✔
116

117
        os.remove(path)
2✔
118

119
        return attachment_id
2✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc