Skip to content
This repository has been archived by the owner on Oct 16, 2023. It is now read-only.

gh-993: Cherry-pick HasTrait into gafferpy #994

Merged
merged 1 commit into from
Mar 25, 2022
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
22 changes: 21 additions & 1 deletion python-shell/src/gafferpy/gaffer_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ class GetTraits(Operation):
CLASS = 'uk.gov.gchq.gaffer.store.operation.GetTraits'

def __init__(self,
current_traits,
current_traits=True,
options=None):
super().__init__(
_class_name=self.CLASS, options=options)
Expand All @@ -696,6 +696,26 @@ def to_json(self):
operation['currentTraits'] = self.current_traits
return operation

class HasTrait(Operation):
CLASS = 'uk.gov.gchq.gaffer.store.operation.HasTrait'

def __init__(self,
trait,
current_traits=True,
options=None):
super().__init__(
_class_name=self.CLASS, options=options)

self.trait = trait
self.current_traits = current_traits

def to_json(self):
operation = super().to_json()

operation['trait'] = self.trait
operation['currentTraits'] = self.current_traits
return operation


class AddElements(Operation):
"""
Expand Down
1 change: 1 addition & 0 deletions python-shell/src/test/test_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ def test_execute_get(self):
"uk.gov.gchq.gaffer.operation.impl.function.Filter",
"uk.gov.gchq.gaffer.operation.impl.function.Transform",
"uk.gov.gchq.gaffer.operation.impl.function.Aggregate",
"uk.gov.gchq.gaffer.store.operation.HasTrait",
"uk.gov.gchq.gaffer.store.operation.GetTraits",
"uk.gov.gchq.gaffer.mapstore.operation.CountAllElementsDefaultView",
"uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherAuthorisedGraph",
Expand Down
1 change: 1 addition & 0 deletions python-shell/src/test/test_connector_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ def test_execute_get(self):
"uk.gov.gchq.gaffer.operation.impl.function.Filter",
"uk.gov.gchq.gaffer.operation.impl.function.Transform",
"uk.gov.gchq.gaffer.operation.impl.function.Aggregate",
"uk.gov.gchq.gaffer.store.operation.HasTrait",
"uk.gov.gchq.gaffer.store.operation.GetTraits",
"uk.gov.gchq.gaffer.mapstore.operation.CountAllElementsDefaultView",
"uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherAuthorisedGraph",
Expand Down
13 changes: 13 additions & 0 deletions python-shell/src/test/test_gaffer_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -4996,6 +4996,19 @@ class GafferOperationsTest(unittest.TestCase):
operation=g.GetElements()
)
],
[
'''
{
"class" : "uk.gov.gchq.gaffer.store.operation.HasTrait",
"trait": "VISIBILITY",
"currentTraits" : true
}
''',
g.HasTrait(
trait="VISIBILITY",
current_traits=True
)
],
[
'''
{
Expand Down