diff --git a/.eggs/README.txt b/.eggs/README.txt new file mode 100644 index 0000000000000000000000000000000000000000..5d01668824f45c3a6683e12d1b9048bb1d273041 --- /dev/null +++ b/.eggs/README.txt @@ -0,0 +1,6 @@ +This directory contains eggs that were downloaded by setuptools to build, test, and run plug-ins. + +This directory caches those eggs to prevent repeated downloads. + +However, it is safe to delete this directory. + diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a33dbc4bf38684de8760ef54ec6d22c6590deead..f12250bdda8bbd481153baea2277ab6c2209fca7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,14 +1,18 @@ image: goblinogm/goblin-buildchain + cache: paths: - vendor test: + services: + - name: goblinogm/gremlin-server-python:latest + alias: gremlin-server + image: goblinogm/goblin-buildchain script: - pip install -U -r requirements.txt - - cd docs - - make html + - python setup.py test except: - master diff --git a/builds/0/project-0 b/builds/0/project-0 new file mode 160000 index 0000000000000000000000000000000000000000..110cd16336d7e67d40c3656cd5a651a5db49229d --- /dev/null +++ b/builds/0/project-0 @@ -0,0 +1 @@ +Subproject commit 110cd16336d7e67d40c3656cd5a651a5db49229d diff --git a/builds/0/project-0.tmp/git-template/config b/builds/0/project-0.tmp/git-template/config new file mode 100644 index 0000000000000000000000000000000000000000..63543c888f087ee5aef63bc0a7e5018988dd78aa --- /dev/null +++ b/builds/0/project-0.tmp/git-template/config @@ -0,0 +1,2 @@ +[fetch] + recurseSubmodules = false diff --git a/requirements.txt b/requirements.txt index 963671dbfa486e16d58f0a8d9eb065c1f6850a4c..169b160ab819f1a4c2ca2a4ad6becd5f3b4c82ad 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,16 @@ gremlinpython==3.3.0 PyYAML>=3.12 + +#required foir kobalos +six==1.10.0 +aenum==1.4.5 +aiohttp==2.3.10 +inflection==0.3.1 + +#for kobalos testing +pytest-asyncio>=0.8.0 +pytest-cache>=1.0 +pytest-cov>=2.5.1 +pytest-pep8>=1.0.6 +pytest>=3.2.1 + diff --git a/tests/conftest.py b/tests/conftest.py index abce5a0876ffb116ecb3678857db8892aadbb7bf..44d1240eef8a3ea3e7899d4b1df3f81f77c9581d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -16,9 +16,13 @@ # along with Goblin. If not, see <http://www.gnu.org/licenses/>. import asyncio import pytest + +from aiogremlin.structure.graph import Graph +from gremlin_python.process.traversal import T from aiogremlin import driver from aiogremlin.driver.provider import TinkerGraph from gremlin_python.driver import serializer +from aiogremlin.remote.driver_remote_connection import DriverRemoteConnection # def pytest_generate_tests(metafunc): @@ -29,7 +33,7 @@ from gremlin_python.driver import serializer def pytest_addoption(parser): parser.addoption('--provider', default='tinkergraph', choices=('tinkergraph', 'dse',)) - parser.addoption('--gremlin-host', default='localhost') + parser.addoption('--gremlin-host', default='gremlin-server') parser.addoption('--gremlin-port', default='8182') @@ -63,7 +67,7 @@ def gremlin_server(): @pytest.fixture def unused_server_url(unused_tcp_port): - return 'http://localhost:{}/gremlin'.format(unused_tcp_port) + return 'https://localhost:{}/gremlin'.format(unused_tcp_port) @pytest.fixture @@ -78,7 +82,7 @@ def gremlin_port(request): @pytest.fixture def gremlin_url(gremlin_host, gremlin_port): - return "http://{}:{}/gremlin".format(gremlin_host, gremlin_port) + return "ws://{}:{}/gremlin".format(gremlin_host, gremlin_port) @pytest.fixture @@ -133,3 +137,37 @@ def cluster(request, gremlin_host, gremlin_port, event_loop, provider, aliases): @pytest.fixture def cluster_class(event_loop): return driver.Cluster + +@pytest.fixture +def remote_connection(event_loop, gremlin_url): + try: + remote_conn = event_loop.run_until_complete( + DriverRemoteConnection.open(gremlin_url, 'g')) + except OSError: + pytest.skip('Gremlin Server is not running') + else: + return remote_conn + +@pytest.fixture(autouse=True) +def run_around_tests(remote_connection, event_loop): + g = Graph().traversal().withRemote(remote_connection) + + async def create_graph(): + await g.V().drop().iterate() + software1 = await g.addV("software").property("name", "lop").property("lang", "java").property(T.id, 3).next() + software2 = await g.addV("software").property("name", "ripple").property("lang", "java").property(T.id, 5).next() + person1 = await g.addV("person").property("name", "marko").property("age", "29").property(T.id, 1).next() + person2 = await g.addV("person").property("name", "vadas").property("age", "27").property(T.id, 2).next() + person3 = await g.addV("person").property("name", "josh").property("age", "32").property(T.id, 4).next() + person4 = await g.addV("person").property("name", "peter").property("age", "35").property(T.id, 6).next() + + knows1 = await g.addE("knows").from_(person1).to(person2).property("weight", 0.5).property(T.id, 7).next() + knows2 = await g.addE("knows").from_(person1).to(person3).property("weight", 1,0).property(T.id, 8).next() + created1 = await g.addE("created").from_(person1).to(software1).property("weight", 0.4).property(T.id, 9).next() + created2 = await g.addE("created").from_(person3).to(software2).property("weight", 1.0).property(T.id, 10).next() + created3 = await g.addE("created").from_(person3).to(software1).property("weight", 1.0).property(T.id, 11).next() + created4 = await g.addE("created").from_(person4).to(software1).property("weight", 0.2).property(T.id, 12).next() + + event_loop.run_until_complete(create_graph()) + + yield diff --git a/tests/test_aliases.py b/tests/test_aliases.py index 6926f6f52bf12dc7091340c1883f4f404b16ce6f..21d22718c6cc42508fe41a847cc95fb74383d559 100644 --- a/tests/test_aliases.py +++ b/tests/test_aliases.py @@ -9,7 +9,7 @@ from gremlin_python.driver import request, serializer @pytest.mark.asyncio async def test_gremlin_query(event_loop, cluster): alias = { 'g': 'g' } - cluster = await driver.Cluster.open(event_loop, aliases=alias) + cluster = await driver.Cluster.open(event_loop, aliases=alias, hosts=['gremlin-server']) client = await cluster.connect() assert client.aliases == alias resp = await client.submit("1 + 1") @@ -22,7 +22,7 @@ async def test_gremlin_query(event_loop, cluster): async def test_alias_serialization(event_loop): alias = { 'g': 'g' } message = '1 + 1' - cluster = await driver.Cluster.open(event_loop, aliases=alias) + cluster = await driver.Cluster.open(event_loop, aliases=alias, hosts=['gremlin-server']) client = await cluster.connect() # This is the code client/conn uses on submit message = request.RequestMessage( diff --git a/tests/test_client.py b/tests/test_client.py index 226e4dd2f2834ce992681f43f73455840b1cd7c6..a366a3a93d5c0609ffaefada9aebee93bdda82e4 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -25,7 +25,7 @@ from aiogremlin.driver.server import GremlinServer @pytest.mark.asyncio async def test_client_auto_release(cluster): - client = await cluster.connect() + client = await cluster.connect(hostname='gremlin-server') resp = await client.submit("1 + 1") async for msg in resp: pass @@ -37,7 +37,7 @@ async def test_client_auto_release(cluster): @pytest.mark.asyncio async def test_alias(cluster): - client = await cluster.connect() + client = await cluster.connect(hostname='gremlin-server') aliased_client = client.alias({"g": "g1"}) assert aliased_client._aliases == {"g": "g1"} assert aliased_client._cluster is client._cluster @@ -47,11 +47,11 @@ async def test_alias(cluster): @pytest.mark.asyncio async def test_client_auto_release(cluster): - client = await cluster.connect(hostname='localhost') + client = await cluster.connect(hostname='gremlin-server') resp = await client.submit("1 + 1") async for msg in resp: assert msg == 2 - assert client._hostname == 'localhost' + assert client._hostname == 'gremlin-server' await cluster.close() diff --git a/tests/test_config.py b/tests/test_config.py index 7b4185493db52bc9e680f9d568811b90e980c8cd..9ee43ec370a38d01775dc0c5b503000fed036f2b 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -79,7 +79,7 @@ def test_cluster_config_from_json(event_loop, cluster_class): def test_cluster_config_from_yaml(event_loop, cluster_class): - cluster = cluster_class(event_loop) + cluster = cluster_class(event_loop, host='gremlin-server') cluster.config_from_file(dirname + '/tests/config/config.yml') assert cluster.config['scheme'] == 'wss' assert cluster.config['hosts'] == ['localhost'] diff --git a/tests/test_gremlin_python/conftest.py b/tests/test_gremlin_python/conftest.py index 468fbf6a827821764d762853b3a85ffb7291f775..217284560a9e114c354c829abc728208fe177bec 100644 --- a/tests/test_gremlin_python/conftest.py +++ b/tests/test_gremlin_python/conftest.py @@ -19,11 +19,12 @@ under the License. '''THIS FILE HAS BEEN MODIFIED BY DAVID M. BROWN TO SUPPORT PEP 492''' import pytest -from aiogremlin.remote.driver_remote_connection import ( - DriverRemoteConnection) +from aiogremlin.structure.graph import Graph +from aiogremlin.remote.driver_remote_connection import DriverRemoteConnection from aiogremlin.driver.protocol import GremlinServerWSProtocol from aiogremlin.driver.aiohttp.transport import AiohttpTransport from gremlin_python.driver.serializer import GraphSONMessageSerializer +from gremlin_python.process.traversal import T @pytest.fixture @@ -44,3 +45,27 @@ def remote_connection(event_loop, gremlin_url): pytest.skip('Gremlin Server is not running') else: return remote_conn + +@pytest.fixture(autouse=True) +def run_around_tests(remote_connection, event_loop): + g = Graph().traversal().withRemote(remote_connection) + + async def create_graph(): + await g.V().drop().iterate() + software1 = await g.addV("software").property("name", "lop").property("lang", "java").property(T.id, 3).next() + software2 = await g.addV("software").property("name", "ripple").property("lang", "java").property(T.id, 5).next() + person1 = await g.addV("person").property("name", "marko").property("age", "29").property(T.id, 1).next() + person2 = await g.addV("person").property("name", "vadas").property("age", "27").property(T.id, 2).next() + person3 = await g.addV("person").property("name", "josh").property("age", "32").property(T.id, 4).next() + person4 = await g.addV("person").property("name", "peter").property("age", "35").property(T.id, 6).next() + + knows1 = await g.addE("knows").from_(person1).to(person2).property("weight", 0.5).property(T.id, 7).next() + knows2 = await g.addE("knows").from_(person1).to(person3).property("weight", 1,0).property(T.id, 8).next() + created1 = await g.addE("created").from_(person1).to(software1).property("weight", 0.4).property(T.id, 9).next() + created2 = await g.addE("created").from_(person3).to(software2).property("weight", 1.0).property(T.id, 10).next() + created3 = await g.addE("created").from_(person3).to(software1).property("weight", 1.0).property(T.id, 11).next() + created4 = await g.addE("created").from_(person4).to(software1).property("weight", 0.2).property(T.id, 12).next() + + event_loop.run_until_complete(create_graph()) + + yield