Skip to content
This repository was archived by the owner on Jun 13, 2024. It is now read-only.

Commit b8f0f00

Browse files
authored
ETOS client now supports multiple suites from ESR (#25)
1 parent dcc07b6 commit b8f0f00

File tree

5 files changed

+143
-124
lines changed

5 files changed

+143
-124
lines changed

docs/conf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@
9292
master_doc = "index"
9393

9494
# General information about the project.
95-
project = u"etos_client"
96-
copyright = u"2020, Axis Communications AB"
95+
project = "etos_client"
96+
copyright = "2020, Axis Communications AB"
9797

9898
# The version info for the project you're documenting, acts as replacement for
9999
# |version| and |release|, also used in various other places throughout the
@@ -241,7 +241,7 @@
241241
# Grouping the document tree into LaTeX files. List of tuples
242242
# (source start file, target name, title, author, documentclass [howto/manual]).
243243
latex_documents = [
244-
("index", "user_guide.tex", u"etos_client Documentation", u"", "manual"),
244+
("index", "user_guide.tex", "etos_client Documentation", "", "manual"),
245245
]
246246

247247
# The name of an image file (relative to this directory) to place at the top of

src/etos_client/lib/graphql.py

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2020-2021 Axis Communications AB.
1+
# Copyright 2020-2022 Axis Communications AB.
22
#
33
# For a full list of individual contributors, please see the commit history.
44
#
@@ -18,6 +18,7 @@
1818
ARTIFACTS,
1919
ACTIVITY_TRIGGERED,
2020
ACTIVITY_CANCELED,
21+
MAIN_TEST_SUITES_STARTED,
2122
TEST_SUITE_STARTED,
2223
TEST_SUITE_FINISHED,
2324
TEST_SUITE,
@@ -127,34 +128,48 @@ def request_test_suite_started(etos, activity_id):
127128
return None # StopIteration
128129

129130

130-
def request_test_suite_finished(etos, test_suite_ids):
131-
"""Request test suite finished from graphql.
131+
def request_main_test_suites_started(etos, activity_id):
132+
"""Request test suite started from graphql.
132133
133134
:param etos: Etos Library instance for communicating with ETOS.
134135
:type etos: :obj:`etos_lib.etos.ETOS`
135-
:param test_suite_ids: list of test suite started IDs of which finished to search for.
136-
:type test_suite_ids: list
137-
:return: Iterator of test suite finished graphql responses.
136+
:param activity_id: ID of activity in which the test suites started
137+
:type activity_id: str
138+
:return: Iterator of test suite started graphql responses.
138139
:rtype: iterator
139140
"""
140-
or_query = "{'$or': ["
141-
or_query += ", ".join(
142-
[
143-
f"{{'links.type': 'TEST_SUITE_EXECUTION', 'links.target': '{test_suite_id}'}}"
144-
for test_suite_id in test_suite_ids
145-
]
146-
)
147-
or_query += "]}"
148-
for response in request(etos, TEST_SUITE_FINISHED % or_query):
141+
for response in request(etos, MAIN_TEST_SUITES_STARTED % activity_id):
149142
if response:
150-
for _, test_suite_finished in etos.graphql.search_for_nodes(
151-
response, "testSuiteFinished"
143+
for _, test_suite_started in etos.graphql.search_for_nodes(
144+
response, "testSuiteStarted"
152145
):
153-
yield test_suite_finished
146+
yield test_suite_started
154147
return None # StopIteration
155148
return None # StopIteration
156149

157150

151+
def request_test_suite_finished(etos, test_suite_id):
152+
"""Request test suite finished from graphql.
153+
154+
:param etos: Etos Library instance for communicating with ETOS.
155+
:type etos: :obj:`etos_lib.etos.ETOS`
156+
:param test_suite_id: Test suite started ID of which finished to search for.
157+
:type test_suite_id: list
158+
:return: Test suite finished graphql response.
159+
:rtype: dict
160+
"""
161+
for response in request(etos, TEST_SUITE_FINISHED % test_suite_id):
162+
if response:
163+
try:
164+
_, test_suite_finished = next(
165+
etos.graphql.search_for_nodes(response, "testSuiteFinished")
166+
)
167+
except StopIteration:
168+
return None
169+
return test_suite_finished
170+
return None
171+
172+
158173
def request_announcements(etos, ids):
159174
"""Request announcements from graphql.
160175

src/etos_client/lib/graphql_queries.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2020-2021 Axis Communications AB.
1+
# Copyright 2020-2022 Axis Communications AB.
22
#
33
# For a full list of individual contributors, please see the commit history.
44
#
@@ -61,14 +61,24 @@
6161

6262
TEST_SUITE_STARTED = """
6363
{
64-
testSuiteStarted(search:"{'links.type': 'CONTEXT', 'links.target': '%s'}") {
64+
testSuiteStarted(search:"{'links.type': 'CAUSE', 'links.target': '%s'}") {
6565
edges {
6666
node {
67-
data {
68-
testSuiteCategories {
69-
type
70-
}
67+
meta {
68+
id
7169
}
70+
}
71+
}
72+
}
73+
}
74+
"""
75+
76+
77+
MAIN_TEST_SUITES_STARTED = """
78+
{
79+
testSuiteStarted(search:"{'links.type': 'CONTEXT', 'links.target': '%s', 'data.categories': {'$ne': 'Sub suite'}}") {
80+
edges {
81+
node {
7282
meta {
7383
id
7484
}
@@ -81,7 +91,7 @@
8191

8292
TEST_SUITE_FINISHED = """
8393
{
84-
testSuiteFinished(search: "%s") {
94+
testSuiteFinished(search: "{'links.type': 'TEST_SUITE_EXECUTION', 'links.target': '%s'}" last: 1) {
8595
edges {
8696
node {
8797
data {
@@ -93,15 +103,6 @@
93103
verdict
94104
}
95105
}
96-
links {
97-
... on TestSuiteExecution {
98-
testSuiteStarted {
99-
meta {
100-
id
101-
}
102-
}
103-
}
104-
}
105106
}
106107
}
107108
}

src/etos_client/lib/log_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2020-2021 Axis Communications AB.
1+
# Copyright 2020-2022 Axis Communications AB.
22
#
33
# For a full list of individual contributors, please see the commit history.
44
#

0 commit comments

Comments
 (0)