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

Commit

Permalink
Merge pull request #130 from gchq/gh-20-travis-python
Browse files Browse the repository at this point in the history
Gh 20 travis python
  • Loading branch information
p013570 authored Jun 19, 2017
2 parents a53855c + 903cfa1 commit a79ee23
Show file tree
Hide file tree
Showing 7 changed files with 168 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ target/
.idea
*/.classpath
__pycache__
*.pem
*.pem
*.pyc
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,19 @@ addons:
apt:
packages:
- oracle-java8-installer
- python3
env:
global:
- secure: "G58eMiza1eSFALXesop4TO+mWELR3fj9BSgxZ1kW8+mrGAmaI7OdKIcloyNoPE06+BoO2vJGGoyA9H7RqPOOh4PG71VJY0R8o9KGJMtTGyWMiKHhnrKC1/LUb7d+yAXYGxJE6abZ+JsU551zI7i4/Y8/8G0EkxXpny3MyLdMbZ2ZuQsdKPyQfQMhknhv0MxyE5StbZzV3d+UVSCadMSb1sMk698D7QnUi+QVXzPhdiq2+YBqJBXE++z8sZmF/9I1NbU5r6s+IFMUaqCgLHg3BxCko4UXxB5M8CuDr35Bkto9QJmUIaJawN3JmEotmBwplz1wVPDW0fVXILegCOznm1AbNbuu+LGPIPemAmQDh8G6H2QXoMJipyBNuW5kwscST5IL7PWyyRc/vd0BJQZvuZDY1pnM/8IAjEDT6WyDhS9ARBOlNjh9fEA9BEvZ9uVvjYldXcqpvOaItunPTGygmegTeky9FwaQJXHXyWqSRttgrs0ePVCfKH8U8sNfuiFo+4WMuSlIfuPwuPWIncuaImWIE8WTRroLShq1Or8bADdS1GmVXMYWOoW61nzgQjFVJx/pNJu05Eu1uChAtH371Y804R5vVUlmmC9Rn3VmVLwJxTcSSLKxsiOzJxGDT6kp9BfP3h+3gCpEhKfKVkc1wcpHAthzS7w4G613GfaFcx0="
- secure: "W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PqlCxwbM8xg/3ZOTSbqwAf1ygYfgf0fo6giKB/crKLQ49vq8m9CQb3ikjMU3D5ksppjWh7DBASOi2B7ok0ENnAy8gdw/8rJ+RnJGlMolsWFkk65i0q+rtvbS9nHGbejKA3+MmKQYNaT29mweRibjNZ6IbhLLndG2iz+AW5DAVHa3JcY3OTy9BQmKr+1gwnJvLnG0mQ+77JMDo5cVkEeS8bqwl36vgeFnJRN24PbpcXSn+m5GViBIZfxZd/d9r1XI3f6VcHCv1h1PG+APQPtTrIgalQ="
- secure: "2mIgYi3USn9sB+3gQ0ULyRXspQUmpR/5M8StHzfMQ2aBGeSV9MaZ3mHxBZGoGIMejpLxE1dGLFagUZRbuH/gk+OI7tphEanfYN7quAdou0f/SzEMXEi5hlBkqFjl3eXE3FpMt5huxO5hBj2UD7dpMTe2AmIAM2LcEr1zybrQ78G19fDVJX6L5C5APC/5IKpPY4l50iFpv/A9GyT/i2Ax/FskCp73K3z5u3vCX+FsAAKu5iS63VKSdVzmjP5B+vRvLOZd80SvldDMmQM6gXTzpGiM6PoH+gehINT3Csq54mTsh6qDGMn1fPiFaczIRXc5Goe31UzhdN3aCVsnhPSoT+hTMwgNeCFcJRZbBntXoO9oUHtkjRkE9Vaz+0i//Yz6xs5k1CyN3Cm/iAQmSPsc3uS9sAlTTKH+oO6U4vcr7CAEUI78wUGLYMxiy0YEVfHHpFFiSyiPVwiVo4Y+EN1qtJp0zN4z7xecWpxgcnz7tORkK07QICiYpOnRKgbnM4Sz+8a//j9JZnZh/MTLudTCwZtWyJfqQkdWiKO4hHHWXiNF1rRY61EHrScx9w331Esk+EILSjuyZiqTIDlG/cd9gWIR26XxRiE2c4o4vELZMGngB0EWiIzlnSssh3nZ4XBjN2YX6S9ZNUE/hoQjBjCFivqUWZ7NOdV439eNx8zvBPE="
install: mvn -q install -P quick,travis -B -V
script: mvn -q test -P travis,build-extras -B
script:
- mvn -q test -P travis,build-extras -B
- mvn install -P quick,road-traffic-demo -pl ui &
- sleep 2m
- cd python-shell && python3 -m unittest discover -s src
after_success:
- ./cd/before_deploy.sh
- ./cd/deploy.sh
12 changes: 9 additions & 3 deletions python-shell/src/gafferpy/gaffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ def to_json(self):
"""
raise NotImplementedError('Use an implementation')

def __str__(self):
return str(self.to_json())

def __eq__(self, other):
return self.to_json() == other.to_json()


class ResultConverter:
@staticmethod
Expand Down Expand Up @@ -114,12 +120,12 @@ def __init__(self, source, destination, directed):
super().__init__()
self.source = source
self.destination = destination
if isinstance(directed, DirectedType):
if isinstance(directed, str):
self.directed = directed
elif directed:
self.directed = True
self.directed = DirectedType.DIRECTED
else:
self.directed = False
self.directed = DirectedType.UNDIRECTED

def to_json(self):
return {
Expand Down
Empty file.
47 changes: 47 additions & 0 deletions python-shell/src/test/test_connector.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#
# Copyright 2016 Crown Copyright
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an 'AS IS' BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import unittest

from gafferpy import gaffer as g
from gafferpy import gaffer_connector


class GafferConnectorTest(unittest.TestCase):
def test_execute_operation(self):
gc = gaffer_connector.GafferConnector('http://localhost:8080/rest/v1')
elements = gc.execute_operation(
g.GetElements(
seeds=[
g.EntitySeed('M5:10')
],
view=g.View(
edges=[
g.ElementDefinition(
group='JunctionLocatedAt'
)
]
)
)
)

self.assertEqual(
[g.Edge("JunctionLocatedAt", "M5:10", "390466,225615", True, {})],
elements)


if __name__ == "__main__":
unittest.main()
28 changes: 28 additions & 0 deletions python-shell/src/test/test_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#
# Copyright 2016 Crown Copyright
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an 'AS IS' BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import unittest

import example


class ExampleTest(unittest.TestCase):
def test_example_does_not_error(self):
example.run('http://localhost:8080/rest/v1')


if __name__ == "__main__":
unittest.main()
76 changes: 76 additions & 0 deletions python-shell/src/test/test_gaffer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#
# Copyright 2016 Crown Copyright
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an 'AS IS' BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import unittest

from gafferpy import gaffer as g


class GafferTest(unittest.TestCase):
def test_create_edge_seed(self):
self.assertEqual(
{
'class': 'uk.gov.gchq.gaffer.operation.data.EdgeSeed',
'source': 'src',
'destination': 'dest',
'directed': 'DIRECTED'
},
g.EdgeSeed("src", "dest", g.DirectedType.DIRECTED).to_json()
)

self.assertEqual(
{
'class': 'uk.gov.gchq.gaffer.operation.data.EdgeSeed',
'source': 'src',
'destination': 'dest',
'directed': 'UNDIRECTED'
},
g.EdgeSeed("src", "dest", g.DirectedType.UNDIRECTED).to_json()
)

self.assertEqual(
{
'class': 'uk.gov.gchq.gaffer.operation.data.EdgeSeed',
'source': 'src',
'destination': 'dest',
'directed': 'EITHER'
},
g.EdgeSeed("src", "dest", g.DirectedType.EITHER).to_json()
)

self.assertEqual(
{
'class': 'uk.gov.gchq.gaffer.operation.data.EdgeSeed',
'source': 1,
'destination': 2,
'directed': 'DIRECTED'
},
g.EdgeSeed(1, 2, True).to_json()
)

self.assertEqual(
{
'class': 'uk.gov.gchq.gaffer.operation.data.EdgeSeed',
'source': 1,
'destination': 2,
'directed': 'UNDIRECTED'
},
g.EdgeSeed(1, 2, False).to_json()
)


if __name__ == "__main__":
unittest.main()

0 comments on commit a79ee23

Please sign in to comment.