Fixing issues in imports after movin tests to pip install -e for testlib

Signed-off-by: Aleksei Chetaev <alex.chetaev@gmail.com>
This commit is contained in:
Aleksei Chetaev 2023-02-22 15:45:36 +01:00 committed by Aleksey Chetaev
parent 4fd9d69701
commit 71b35d45c3
8 changed files with 51 additions and 55 deletions

View file

@ -1,4 +1,5 @@
from test_case import id, suite_name, suite_section, title from frostfs_testlib.analytics import test_case
from test_collector import TestCase, TestCaseCollector from frostfs_testlib.analytics.test_case import TestCasePriority
from test_exporter import TestExporter from frostfs_testlib.analytics.test_collector import TestCase, TestCaseCollector
from testrail_exporter import TestrailExporter from frostfs_testlib.analytics.test_exporter import TestExporter
from frostfs_testlib.analytics.testrail_exporter import TestrailExporter

View file

@ -1,6 +1,7 @@
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from test_collector import TestCase from frostfs_testlib.analytics.test_collector import TestCase
class TestExporter(ABC): class TestExporter(ABC):
test_cases_cache = [] test_cases_cache = []
@ -45,7 +46,9 @@ class TestExporter(ABC):
""" """
@abstractmethod @abstractmethod
def update_test_case(self, test_case: TestCase, test_case_in_tms, test_suite, test_suite_section) -> None: def update_test_case(
self, test_case: TestCase, test_case_in_tms, test_suite, test_suite_section
) -> None:
""" """
Update test case in TMS Update test case in TMS
""" """
@ -57,12 +60,11 @@ class TestExporter(ABC):
for test_case in test_cases: for test_case in test_cases:
test_suite = self.get_or_create_test_suite(test_case.suite_name) test_suite = self.get_or_create_test_suite(test_case.suite_name)
test_section = self.get_or_create_suite_section(test_suite, test_case.suite_section_name) test_section = self.get_or_create_suite_section(
test_suite, test_case.suite_section_name
)
test_case_in_tms = self.search_test_case_id(test_case.id) test_case_in_tms = self.search_test_case_id(test_case.id)
steps = [ steps = [{"content": value, "expected": " "} for key, value in test_case.steps.items()]
{"content": value, "expected": " "}
for key, value in test_case.steps.items()
]
if test_case: if test_case:
self.update_test_case(test_case, test_case_in_tms) self.update_test_case(test_case, test_case_in_tms)

View file

@ -1,7 +1,7 @@
from testrail_api import TestRailAPI from testrail_api import TestRailAPI
from test_collector import TestCase from frostfs_testlib.analytics.test_collector import TestCase
from test_exporter import TestExporter from frostfs_testlib.analytics.test_exporter import TestExporter
class TestrailExporter(TestExporter): class TestrailExporter(TestExporter):
@ -101,7 +101,9 @@ class TestrailExporter(TestExporter):
elif len(test_rail_suites) == 1: elif len(test_rail_suites) == 1:
return test_rail_suites.pop() return test_rail_suites.pop()
else: else:
raise RuntimeError(f"Too many results found in test rail for suite name {test_suite_name}") raise RuntimeError(
f"Too many results found in test rail for suite name {test_suite_name}"
)
def get_or_create_suite_section(self, test_rail_suite, section_name) -> object: def get_or_create_suite_section(self, test_rail_suite, section_name) -> object:
""" """
@ -137,17 +139,13 @@ class TestrailExporter(TestExporter):
"title": test_case.title, "title": test_case.title,
"section_id": test_suite_section["id"], "section_id": test_suite_section["id"],
self.test_case_id_field_name: test_case.id, self.test_case_id_field_name: test_case.id,
} }
if test_case.priority: if test_case.priority:
request_body["priority_id"] = self.tr_priority_map.get(test_case.priority) request_body["priority_id"] = self.tr_priority_map.get(test_case.priority)
if test_case.steps: if test_case.steps:
steps = [ steps = [{"content": value, "expected": " "} for key, value in test_case.steps.items()]
{"content": value, "expected": " "}
for key, value in test_case.steps.items()
]
request_body[self.tr_steps_field] = steps request_body[self.tr_steps_field] = steps
request_body["template_id"] = self.tr_template_id_with_steps request_body["template_id"] = self.tr_template_id_with_steps
else: else:
@ -157,7 +155,6 @@ class TestrailExporter(TestExporter):
return request_body return request_body
def create_test_case(self, test_case: TestCase, test_suite, test_suite_section) -> None: def create_test_case(self, test_case: TestCase, test_suite, test_suite_section) -> None:
""" """
Create test case in Testrail Create test case in Testrail
@ -166,13 +163,12 @@ class TestrailExporter(TestExporter):
self.api.cases.add_case(**request_body) self.api.cases.add_case(**request_body)
def update_test_case(
def update_test_case(self, test_case: TestCase, test_case_in_tms, test_suite, test_suite_section) -> None: self, test_case: TestCase, test_case_in_tms, test_suite, test_suite_section
) -> None:
""" """
Update test case in Testrail Update test case in Testrail
""" """
request_body = self.prepare_request_body(test_case, test_suite, test_suite_section) request_body = self.prepare_request_body(test_case, test_suite, test_suite_section)
self.api.cases.update_case(case_id=test_case_in_tms["id"], **request_body) self.api.cases.update_case(case_id=test_case_in_tms["id"], **request_body)

View file

@ -2,11 +2,10 @@ import json
from time import sleep from time import sleep
from typing import Optional from typing import Optional
from cli import NeoGo
from shell import Shell
from utils.converters import process_b64_bytearray
from frostfs_testlib.blockchain import Multisig from frostfs_testlib.blockchain import Multisig
from frostfs_testlib.cli import NeoGo
from frostfs_testlib.shell import Shell
from frostfs_testlib.utils.converting_utils import process_b64_bytearray
class RoleDesignation: class RoleDesignation:

View file

@ -1 +1 @@
import common from frostfs_testlib.resources import common

View file

@ -7,40 +7,40 @@ class TestConverters(TestCase):
def test_str_to_ascii_hex(self): def test_str_to_ascii_hex(self):
source_str = "" source_str = ""
result_str = "" result_str = ""
self.assertEqual(converters.str_to_ascii_hex(source_str), result_str) self.assertEqual(converting_utils.str_to_ascii_hex(source_str), result_str)
source_str = '"test_data" f0r ^convert*' source_str = '"test_data" f0r ^convert*'
result_str = "22746573745f646174612220663072205e636f6e766572742a" result_str = "22746573745f646174612220663072205e636f6e766572742a"
self.assertEqual(converters.str_to_ascii_hex(source_str), result_str) self.assertEqual(converting_utils.str_to_ascii_hex(source_str), result_str)
def test_ascii_hex_to_str(self): def test_ascii_hex_to_str(self):
source_str = "" source_str = ""
result_bytes = b"" result_bytes = b""
self.assertEqual(converters.ascii_hex_to_str(source_str), result_bytes) self.assertEqual(converting_utils.ascii_hex_to_str(source_str), result_bytes)
source_str = "22746573745f646174612220663072205e636f6e766572742a" source_str = "22746573745f646174612220663072205e636f6e766572742a"
result_bytes = b'"test_data" f0r ^convert*' result_bytes = b'"test_data" f0r ^convert*'
self.assertEqual(converters.ascii_hex_to_str(source_str), result_bytes) self.assertEqual(converting_utils.ascii_hex_to_str(source_str), result_bytes)
def test_process_b64_bytearray_reverse(self): def test_process_b64_bytearray_reverse(self):
source_str = "" source_str = ""
result_bytes = b"" result_bytes = b""
self.assertEqual(converters.process_b64_bytearray_reverse(source_str), result_bytes) self.assertEqual(converting_utils.process_b64_bytearray_reverse(source_str), result_bytes)
source_str = "InRlc3RfZGF0YSIgZjByIF5jb252ZXJ0Kg==" source_str = "InRlc3RfZGF0YSIgZjByIF5jb252ZXJ0Kg=="
result_bytes = b"2a747265766e6f635e207230662022617461645f7473657422" result_bytes = b"2a747265766e6f635e207230662022617461645f7473657422"
self.assertEqual(converters.process_b64_bytearray_reverse(source_str), result_bytes) self.assertEqual(converting_utils.process_b64_bytearray_reverse(source_str), result_bytes)
def test_process_b64_bytearray(self): def test_process_b64_bytearray(self):
source_str = "" source_str = ""
result_bytes = b"" result_bytes = b""
self.assertEqual(converters.process_b64_bytearray(source_str), result_bytes) self.assertEqual(converting_utils.process_b64_bytearray(source_str), result_bytes)
source_str = "InRlc3RfZGF0YSIgZjByIF5jb252ZXJ0Kg==" source_str = "InRlc3RfZGF0YSIgZjByIF5jb252ZXJ0Kg=="
result_bytes = b"22746573745f646174612220663072205e636f6e766572742a" result_bytes = b"22746573745f646174612220663072205e636f6e766572742a"
self.assertEqual(converters.process_b64_bytearray(source_str), result_bytes) self.assertEqual(converting_utils.process_b64_bytearray(source_str), result_bytes)
def test_contract_hash_to_address(self): def test_contract_hash_to_address(self):
source_str = "d01a381aae45f1ed181db9d554cc5ccc69c69f4e" source_str = "d01a381aae45f1ed181db9d554cc5ccc69c69f4e"
result_str = "NT5hJ5peVmvYdZCsFKUM5MTcEGw5TB4k89" result_str = "NT5hJ5peVmvYdZCsFKUM5MTcEGw5TB4k89"
self.assertEqual(converters.contract_hash_to_address(source_str), result_str) self.assertEqual(converting_utils.contract_hash_to_address(source_str), result_str)

View file

@ -2,8 +2,7 @@ from unittest import TestCase
from frostfs_testlib.shell.interfaces import CommandOptions, InteractiveInput from frostfs_testlib.shell.interfaces import CommandOptions, InteractiveInput
from frostfs_testlib.shell.local_shell import LocalShell from frostfs_testlib.shell.local_shell import LocalShell
from helpers import format_error_details, get_output_lines
from tests.helpers import format_error_details, get_output_lines
class TestLocalShellInteractive(TestCase): class TestLocalShellInteractive(TestCase):

View file

@ -3,8 +3,7 @@ from unittest import SkipTest, TestCase
from frostfs_testlib.shell.interfaces import CommandOptions, InteractiveInput from frostfs_testlib.shell.interfaces import CommandOptions, InteractiveInput
from frostfs_testlib.shell.ssh_shell import SSHShell from frostfs_testlib.shell.ssh_shell import SSHShell
from helpers import format_error_details, get_output_lines
from tests.helpers import format_error_details, get_output_lines
def init_shell() -> SSHShell: def init_shell() -> SSHShell: