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

testit-tms / adapters-python / 21511770700

30 Jan 2026 09:56AM UTC coverage: 37.233% (+16.4%) from 20.816%
21511770700

Pull #226

github

web-flow
Merge d20a365b2 into 786f4dcb1
Pull Request #226: release: support tms 5.6.

21 of 45 new or added lines in 7 files covered. (46.67%)

1327 of 3564 relevant lines covered (37.23%)

0.74 hits per line

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

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

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

14

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

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

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

37
            self.__update_test_run_name(test_run_id)
×
38

39
            return test_run_id
×
40

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

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

47
        if not test_run_name:
×
48
            return
×
49

50
        test_run = self.__api_client.get_test_run(test_run_id)
×
51

52
        if test_run_name == test_run.name:
×
53
            return
×
54

55
        test_run.name = test_run_name
×
56

57
        self.__api_client.update_test_run(test_run)
×
58

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

64
        return
×
65

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

71
            return
×
72

73
        self.__test_results.append(test_result)
×
74

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

80
        ext_id = test_result.get_external_id()
×
81
        test_result_id = self.__api_client.write_test(test_result)
×
82
      
83
        if (ext_id is None or test_result_id is None):
×
NEW
84
            logging.warning("test_result got empty external_id or test_result_id")
×
NEW
85
            logging.warning(test_result)
×
86
            return
×
87

88
        self.__test_result_map[ext_id] = test_result_id
×
89

90
    @adapter_logger
2✔
91
    def write_tests(self) -> None:
2✔
92
        if self.__config.should_import_realtime():
2✔
93
            self.__load_setup_and_teardown_step_results()
2✔
94

95
            return
2✔
96

97
        self.__write_tests_after_all()
×
98

99
    @adapter_logger
2✔
100
    def __load_setup_and_teardown_step_results(self) -> None:
2✔
101
        self.__api_client.update_test_results(self.__fixture_manager.get_all_items(), self.__test_result_map)
2✔
102

103
    @adapter_logger
2✔
104
    def __write_tests_after_all(self) -> None:
2✔
105
        fixtures = self.__fixture_manager.get_all_items()
×
106

107
        self.__api_client.write_tests(self.__test_results, fixtures)
×
108

109
    @adapter_logger
2✔
110
    def load_attachments(self, attach_paths: list or tuple):
2✔
111
        return self.__api_client.load_attachments(attach_paths)
2✔
112

113
    @adapter_logger
2✔
114
    def create_attachment(self, body, name: str):
2✔
115
        if name is None:
2✔
116
            name = str(uuid.uuid4()) + '-attachment.txt'
×
117

118
        path = os.path.join(os.path.abspath(''), name)
2✔
119

120
        with open(path, 'wb') as attached_file:
2✔
121
            attached_file.write(
2✔
122
                Utils.convert_body_of_attachment(body))
123

124
        attachment_id = self.__api_client.load_attachments((path,))
2✔
125

126
        os.remove(path)
2✔
127

128
        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