Skip to content

Commit 8f28249

Browse files
committed
Added new link types and fixed a few overrides
1 parent b4d2957 commit 8f28249

File tree

12 files changed

+131
-13
lines changed

12 files changed

+131
-13
lines changed

src/eiffel_graphql_api/graphql/schemas/events/activity_finished.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2019-2020 Axis Communications AB.
1+
# Copyright 2019-2023 Axis Communications AB.
22
#
33
# For a full list of individual contributors, please see the commit history.
44
#
@@ -30,6 +30,7 @@ class ActivityFinished(EiffelObjectType):
3030
load("EiffelActivityFinishedEvent.json").get("data").get("properties"),
3131
override_name={
3232
"persistentLogs": "activityPersistentLogs",
33+
"tags": "activityPersistentLogTags",
3334
"outcome": "activityOutcome",
3435
},
3536
)

src/eiffel_graphql_api/graphql/schemas/events/activity_started.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2019-2020 Axis Communications AB.
1+
# Copyright 2019-2023 Axis Communications AB.
22
#
33
# For a full list of individual contributors, please see the commit history.
44
#
@@ -28,7 +28,7 @@ class ActivityStarted(EiffelObjectType):
2828
data = json_schema_to_graphql(
2929
"ActivityStartedData",
3030
load("EiffelActivityStartedEvent.json").get("data").get("properties"),
31-
override_name={"liveLogs": "activityLiveLogs"},
31+
override_name={"liveLogs": "activityLiveLogs", "tags": "activityLiveLogTags"},
3232
)
3333
mongo = None
3434

src/eiffel_graphql_api/graphql/schemas/events/artifact_created.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2019-2020 Axis Communications AB.
1+
# Copyright 2019-2023 Axis Communications AB.
22
#
33
# For a full list of individual contributors, please see the commit history.
44
#
@@ -28,7 +28,10 @@ class ArtifactCreated(EiffelObjectType):
2828
data = json_schema_to_graphql(
2929
"ArtifactCreatedData",
3030
load("EiffelArtifactCreatedEvent.json").get("data").get("properties"),
31-
override_name={"tags": "artifactTags"},
31+
override_name={
32+
"tags": "artifactTags",
33+
"integrityProtection": "artifactIntegrityProtection",
34+
},
3235
)
3336
mongo = None
3437

src/eiffel_graphql_api/graphql/schemas/events/test_case_finished.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2019-2020 Axis Communications AB.
1+
# Copyright 2019-2023 Axis Communications AB.
22
#
33
# For a full list of individual contributors, please see the commit history.
44
#
@@ -31,6 +31,7 @@ class TestCaseFinished(EiffelObjectType):
3131
override_name={
3232
"outcome": "testCaseOutcome",
3333
"persistentLogs": "testCasePersistentLogs",
34+
"tags": "testCasePersistentLogTags",
3435
},
3536
)
3637
mongo = None

src/eiffel_graphql_api/graphql/schemas/events/test_case_started.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2019-2020 Axis Communications AB.
1+
# Copyright 2019-2023 Axis Communications AB.
22
#
33
# For a full list of individual contributors, please see the commit history.
44
#
@@ -28,7 +28,10 @@ class TestCaseStarted(EiffelObjectType):
2828
data = json_schema_to_graphql(
2929
"TestCaseStartedData",
3030
load("EiffelTestCaseStartedEvent.json").get("data").get("properties"),
31-
override_name={"liveLogs": "testCaseLiveLogs"},
31+
override_name={
32+
"liveLogs": "testCaseLiveLogs",
33+
"tags": "testCaseLiveLogTags",
34+
},
3235
)
3336
mongo = None
3437

src/eiffel_graphql_api/graphql/schemas/events/test_suite_finished.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2019-2020 Axis Communications AB.
1+
# Copyright 2019-2023 Axis Communications AB.
22
#
33
# For a full list of individual contributors, please see the commit history.
44
#
@@ -30,6 +30,7 @@ class TestSuiteFinished(EiffelObjectType):
3030
load("EiffelTestSuiteFinishedEvent.json").get("data").get("properties"),
3131
override_name={
3232
"persistentLogs": "testSuitePersistentLogs",
33+
"tags": "testSuitePersistentLogTags",
3334
"outcome": "testSuiteOutcome",
3435
},
3536
)

src/eiffel_graphql_api/graphql/schemas/events/test_suite_started.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2019-2020 Axis Communications AB.
1+
# Copyright 2019-2023 Axis Communications AB.
22
#
33
# For a full list of individual contributors, please see the commit history.
44
#
@@ -30,6 +30,7 @@ class TestSuiteStarted(EiffelObjectType):
3030
load("EiffelTestSuiteStartedEvent.json").get("data").get("properties"),
3131
override_name={
3232
"liveLogs": "testSuiteLiveLogs",
33+
"tags": "testSuiteLiveLogTags",
3334
"categories": "testSuiteCategories",
3435
},
3536
)

src/eiffel_graphql_api/graphql/schemas/links/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2019-2020 Axis Communications AB.
1+
# Copyright 2019-2023 Axis Communications AB.
22
#
33
# For a full list of individual contributors, please see the commit history.
44
#
@@ -26,6 +26,8 @@
2626
from .issues import *
2727
from .iut import IUT
2828
from .modified_announcement import ModifiedAnnouncement
29+
from .precursor import Precursor
30+
from .runtime_environment import RuntimeEnvironment
2931
from .source_change_base import *
3032
from .subject import Subject
3133
from .tercc import Tercc
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Copyright 2023 Axis Communications AB.
2+
#
3+
# For a full list of individual contributors, please see the commit history.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
"""Eiffel precursor links."""
17+
import graphene
18+
19+
from eiffel_graphql_api.graphql.schemas.events import ActivityTriggered
20+
21+
from ..utils import find_one
22+
23+
24+
class Precursor(graphene.ObjectType):
25+
"""Activity precursor link."""
26+
27+
activity_triggered = graphene.Field(ActivityTriggered)
28+
29+
def __init__(self, link):
30+
"""Initialize link."""
31+
# pylint:disable=super-init-not-called
32+
self.link = link
33+
34+
def resolve_activity_triggered(self, _):
35+
"""Resolve activity triggered link."""
36+
from ..union import NotFound # pylint:disable=import-outside-toplevel
37+
38+
event = find_one(
39+
"EiffelActivityTriggeredEvent", {"meta.id": self.link.get("target")}
40+
)
41+
if event is None:
42+
return NotFound(self.link, "Could not find event in database.")
43+
return ActivityTriggered(event)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright 2023 Axis Communications AB.
2+
#
3+
# For a full list of individual contributors, please see the commit history.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
"""Eiffel subject link."""
17+
import graphene
18+
19+
from ..utils import find_type, search
20+
21+
22+
class RuntimeEnvironment(graphene.ObjectType):
23+
"""Runtime environment link."""
24+
25+
link = graphene.Field(
26+
"eiffel_graphql_api.graphql.schemas.union.EiffelRuntimeEnvironmentLink"
27+
)
28+
29+
def __init__(self, link):
30+
"""Initialize link."""
31+
# pylint:disable=super-init-not-called
32+
self.link = link
33+
34+
def resolve_link(self, _):
35+
"""Resolve runtime environment link."""
36+
from ..union import NotFound # pylint:disable=import-outside-toplevel
37+
38+
mongo = search({"meta.id": self.link.get("target")})
39+
if mongo is None:
40+
return NotFound(self.link, "Could not find event in database.")
41+
event = find_type(mongo["meta"]["type"])
42+
return event(mongo)

src/eiffel_graphql_api/graphql/schemas/links/utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2019-2020 Axis Communications AB.
1+
# Copyright 2019-2023 Axis Communications AB.
22
#
33
# For a full list of individual contributors, please see the commit history.
44
#
@@ -27,19 +27,24 @@
2727
from .issues import *
2828
from .iut import IUT
2929
from .modified_announcement import ModifiedAnnouncement
30+
from .precursor import Precursor
31+
from .runtime_environment import RuntimeEnvironment
3032
from .source_change_base import *
3133
from .subject import Subject
3234
from .tercc import Tercc
3335
from .test_case_execution import *
3436
from .test_suite_execution import *
3537
from .verification_basis import VerificationBasis
3638

39+
3740
LINKS = {
3841
"CONTEXT": Context,
3942
"FLOW_CONTEXT": FlowContext,
4043
"CAUSE": Cause,
4144
"ACTIVITY_EXECUTION": ActivityExecution,
45+
"PRECURSOR": Precursor,
4246
"PREVIOUS_ACTIVITY_EXECUTION": PreviousActivityExecution,
47+
"RUNTIME_ENVIRONMENT": RuntimeEnvironment,
4348
"MODIFIED_ANNOUNCEMENT": ModifiedAnnouncement,
4449
"COMPOSITION": Composition,
4550
"PREVIOUS_VERSION": {

src/eiffel_graphql_api/graphql/schemas/union.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2019-2020 Axis Communications AB.
1+
# Copyright 2019-2023 Axis Communications AB.
22
#
33
# For a full list of individual contributors, please see the commit history.
44
#
@@ -106,6 +106,20 @@ class Meta: # pylint: disable=too-few-public-methods
106106
)
107107

108108

109+
class EiffelRuntimeEnvironmentLink(
110+
graphene.Union
111+
): # pylint: disable=too-few-public-methods
112+
"""Runtime environment union."""
113+
114+
class Meta: # pylint: disable=too-few-public-methods
115+
"""Possible response object types."""
116+
117+
types = (
118+
CompositionDefined,
119+
ArtifactCreated,
120+
)
121+
122+
109123
class EiffelEventUnion(graphene.Union): # pylint: disable=too-few-public-methods
110124
"""Base event union."""
111125

@@ -170,8 +184,10 @@ class Meta: # pylint: disable=too-few-public-methods
170184
Base,
171185
SourceCreatedPreviousVersion,
172186
PartiallyResolvedIssue,
187+
Precursor,
173188
ResolvedIssue,
174189
DeresolvedIssue,
190+
RuntimeEnvironment,
175191
SourceChange,
176192
SourceSubmittedPreviousVersion,
177193
TestCaseExecution,

0 commit comments

Comments
 (0)