Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Add tests folder to pylint #34

Merged
merged 16 commits into from
May 16, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ jobs:
python -m pip install pylint
- name: Run pylint
run: |-
pylint -dfixme polarion_rest_api_client || exit $(($? & ~24))
pylint -dfixme polarion_rest_api_client tests || exit $(($? & ~24))
4 changes: 4 additions & 0 deletions polarion_rest_api_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

from polarion_rest_api_client.client import OpenAPIPolarionProjectClient
from polarion_rest_api_client.data_models import (
SelectTestCasesBy,
TestRecord,
TestRun,
TextContent,
WorkItem,
WorkItemAttachment,
WorkItemLink,
Expand Down
111 changes: 111 additions & 0 deletions polarion_rest_api_client/base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class DefaultFields:
_linkedworkitems: str = "id,role,suspect"
_workitem_attachments: str = "@basic"
_documents: str = "@basic"
_testrecords: str = "@basic"
_testruns: str = "@basic"

@property
def workitems(self):
Expand Down Expand Up @@ -55,6 +57,24 @@ def documents(self):
def documents(self, value):
self._documents = value

@property
def testruns(self):
"""Return the fields dict for document."""
return {"testruns": self._testruns}

@testruns.setter
def testruns(self, value):
self._testruns = value

@property
def testrecords(self):
"""Return the fields dict for document."""
return {"testrecords": self._testrecords}

@testrecords.setter
def testrecords(self, value):
self._testrecords = value

@property
def all_types(self):
"""Return all fields dicts merged together."""
Expand All @@ -63,6 +83,8 @@ def all_types(self):
| self.workitems
| self.linkedworkitems
| self.documents
| self.testruns
| self.testrecords
)


Expand Down Expand Up @@ -360,3 +382,92 @@ def delete_work_item_link(self, work_item_link: dm.WorkItemLink):
"""Delete the links between the work items in work_item_link."""
self._set_project(work_item_link)
self._delete_work_item_links([work_item_link])

def get_all_test_runs(
self,
query: str = "",
fields: dict[str, str] | None = None,
) -> list[dm.TestRun]:
"""Get all test runs matching the given query.

Will handle pagination automatically. Define a fields dictionary
as described in the Polarion API documentation to get certain
fields.
"""
return self._request_all_items(
self.get_test_runs, fields=fields, query=query
)

@abc.abstractmethod
def get_test_runs(
self,
query: str = "",
fields: dict[str, str] | None = None,
page_size: int = 100,
page_number: int = 1,
retry: bool = True,
) -> tuple[list[dm.TestRun], bool]:
"""Return the test runs on a defined page matching the given query.

In addition, a flag whether a next page is available is
returned. Define a fields dictionary as described in the
Polarion API documentation to get certain fields.
"""
raise NotImplementedError

def get_all_test_records(
self,
test_run_id: str,
fields: dict[str, str] | None = None,
) -> list[dm.TestRecord]:
"""Get all test records matching the given query.

Will handle pagination automatically. Define a fields dictionary
as described in the Polarion API documentation to get certain
fields.
"""
return self._request_all_items(
self.get_test_records, fields=fields, test_run_id=test_run_id
)

@abc.abstractmethod
def get_test_records(
self,
test_run_id: str,
fields: dict[str, str] | None = None,
page_size: int = 100,
page_number: int = 1,
retry: bool = True,
) -> tuple[list[dm.TestRecord], bool]:
"""Return the test records on a defined page matching the given query.

In addition, a flag whether a next page is available is
returned. Define a fields dictionary as described in the
Polarion API documentation to get certain fields.
"""
raise NotImplementedError

@abc.abstractmethod
def create_test_runs(
self, test_runs: list[dm.TestRun], retry: bool = True
):
"""Create the given list of test runs."""
raise NotImplementedError

def create_test_run(self, test_run: dm.TestRun):
"""Create the given test run."""
self.create_test_runs([test_run])

@abc.abstractmethod
def create_test_records(
self,
test_run_id: str,
test_records: list[dm.TestRecord],
retry: bool = True,
):
"""Create the given list of test records."""
raise NotImplementedError

def create_test_record(self, test_run_id: str, test_record: dm.TestRecord):
"""Create the given list of test records."""
self.create_test_records(test_run_id, [test_record])
Loading
Loading