[
  {
    "path": ".appveyor.sh",
    "content": "appveyor DownloadFile https://github.com/cayleygraph/cayley/releases/download/v0.7.0/cayley_0.7.0_windows_amd64.zip -Timeout 5000\n7z x cayley_0.7.0_windows_amd64.zip cayley_0.7.0_windows_amd64\ncd /?\ncd cayley_0.7.0_windows_amd64\ncd /?\ndir /a\ncayley.exe http --dbpath=30kmoviedata.nq.gz &\nsleep 2\n"
  },
  {
    "path": ".gitignore",
    "content": "# Byte-compiled / optimized / DLL files\n__pycache__/\n*.py[cod]\n\n# C extensions\n*.so\n\n#PyCharm project folder\n.idea/\n\n# Distribution / packaging\n.Python\nenv/\nbin/\nbuild/\ndevelop-eggs/\ndist/\neggs/\nlib/\nlib64/\nparts/\nsdist/\nvar/\n*.egg-info/\n.installed.cfg\n*.egg\n\n# Installer logs\npip-log.txt\npip-delete-this-directory.txt\n\n# Unit test / coverage reports\nhtmlcov/\n.tox/\n.coverage\n.cache\nnosetests.xml\ncoverage.xml\n\n# Translations\n*.mo\n\n# Mr Developer\n.mr.developer.cfg\n.project\n.pydevproject\n\n# Rope\n.ropeproject\n\n# Django stuff:\n*.log\n*.pot\n\n# Sphinx documentation\ndocs/_build/"
  },
  {
    "path": ".travis.sh",
    "content": "#!/bin/bash\nwget https://github.com/cayleygraph/cayley/releases/download/v0.7.0/cayley_0.7.0_linux_amd64.tar.gz\ntar -xvzf cayley_0.7.0_linux_amd64.tar.gz\ncd cayley_0.7.0_linux_amd64\n./cayley http --dbpath=30kmoviedata.nq.gz &\nsleep 2\n"
  },
  {
    "path": ".travis.yml",
    "content": "language: python\n\npython:\n  - \"2.7\"\n  - \"3.4\"\n  - \"3.5\"\n  - \"3.6\"\n  - \"3.7\"\n  - \"3.8\"\n\nbefore_script:\n  - /bin/bash ./.travis.sh\n\ninstall:\n  - pip install -r requirements.txt\n  - pip install -r requirements.testing.txt\n  - pip install .\n\nscript:\n  - nosetests --with-coverage --cover-package=pyley\n\nafter_success:\n  - coveralls\n"
  },
  {
    "path": "MANIFEST.in",
    "content": "include README.md\n"
  },
  {
    "path": "README.rst",
    "content": ".. image:: https://github.com/ziyasal/pyley/raw/master/pyley.png?raw=true\n\npyley\n=====\n\n.. image:: https://img.shields.io/pypi/v/pyley.svg\n    :target: https://pypi.org/project/pyley\n\n.. image:: https://img.shields.io/pypi/pyversions/pyley.svg\n    :target: https://pypi.org/project/pyley\n\n.. image:: https://travis-ci.org/ziyasal/pyley.svg?branch=master\n    :target: https://travis-ci.org/ziyasal/pyley\n\n.. image:: https://coveralls.io/repos/ziyasal/pyley/badge.svg?branch=master&service=github\n    :target: https://coveralls.io/github/ziyasal/pyley?branch=master\n\n`Python <https://www.python.org/>`_ client for an open-source graph database **Cayley** `<https://github.com/google/cayley>`_.\n\n    Cayley is an open-source graph inspired by the graph database behind `Freebase <http://freebase.com/>`_ and Google's `Knowledge Graph <http://www.google.com/insidesearch/features/search/knowledge.html>`_. Its goal is to be a part of the developer's toolbox where `Linked Data <http://linkeddata.org/>`_ and graph-shaped data (semantic webs, social networks, etc) in general are concerned.\n\nInstall via pip\n---------------\n\nYou can install pyley using::\n\n    $ pip install pyley\n\nSample\n------\n\n**Import pyley:**\n\n.. code-block:: python\n\n    from pyley import CayleyClient, GraphObject\n\n    # Create cayley client\n    # this creates client with default parameters `http://localhost:64210/api/v1/query/gizmo`\n    client = CayleyClient()\n    \n    # or  specify `url` and `version` parameters\n    client = CayleyClient(\"http://localhost:64210\", \"v1\")\n  \n    g = GraphObject()\n\n    # Query all vertices in the graph, limit to the first 5 vertices found.\n    g.Vertex().GetLimit(5)\n  \n    # Start with only one vertex, the literal name \"Humphrey Bogart\", and retrieve all of them.\n    query = g.Vertex(\"Humphrey Bogart\").All();\n    response = client.Send(query)\n    # response.result contains JSON data and response.r contains raw response\n    print response.result \n    \n    # `g` and `V` are synonyms for `graph` and `Vertex` respectively, as they are quite common.\n    query = g.V(\"Humphrey Bogart\").All()\n    response = client.Send(query)\n    \n    # \"Humphrey Bogart\" is a name, but not an entity. \n    # Let's find the entities with this name in our dataset.\n    # Follow links that are pointing In to our \"Humphrey Bogart\" node with the predicate \"name\".\n    query = g.V(\"Humphrey Bogart\").In(\"<name>\").All()\n    response = client.Send(query)\n  \n    # Notice that \"name\" is a generic predicate in our dataset. \n    # Starting with a movie gives a similar effect.\n    query = g.V(\"Casablanca\").In(\"name\").All()\n    response = client.Send(query)\n\n    # Relatedly, we can ask the reverse; all ids with the name \"Casablanca\"\n    query = g.V().Has(\"name\", \"Casablanca\").All()\n    response = client.Send(query)\n    \n    # Let's get the list of actors in the film\n    query = g.V().Has(\"name\", \"Casablanca\") \\\n                  .Out(\"/film/film/starring\") \\\n                  .Out(\"/film/performance/actor\") \\\n                  .Out(\"name\") \\\n                  .All()\n\n    response = client.Send(query)\n  \n    # But this is starting to get long. \n    # Let's use a morphism -- a pre-defined path stored in a variable -- as our linkage\n    film_to_actor = g.Morphism().Out(\"/film/film/starring\").Out(\"/film/performance/actor\")\n    query = g.V() \\\n            .Has(\"name\", \"Casablanca\") \\\n            .Follow(film_to_actor) \\\n            .Out(\"name\") \\\n            .All()\n    response = client.Send(query)\n\n    # Add data programatically to the JSON result list. Can be any JSON type.\n    query = g.Emit({'name': \"John Doe\", 'age': 41, 'isActor': True})\n    response = client.Send(query)\n\nBugs\n----\n\nIf you encounter a bug, performance issue, or malfunction, please add an `Issues <https://github.com/ziyasal/pyley/issues>`_ with steps on how to reproduce the problem\nor feel to free to open a pull request.\n\n\nTODO\n----\n\n- Improve Gizmo implementation (Basic steps implemented at the moment)\n- Add more tests\n- Add more documentation\n\nOpen Source  Projects in Use\n----------------------------\n\n- `requests <https://github.com/kennethreitz/requests>`_ by @kennethreitz\n\nLicense\n-------\n\n@ziλasal & @abdullahselek\n"
  },
  {
    "path": "UNLICENSE",
    "content": "This is free and unencumbered software released into the public domain.\n\nAnyone is free to copy, modify, publish, use, compile, sell, or\ndistribute this software, either in source code form or as a compiled\nbinary, for any purpose, commercial or non-commercial, and by any\nmeans.\n\nIn jurisdictions that recognize copyright laws, the author or authors\nof this software dedicate any and all copyright interest in the\nsoftware to the public domain. We make this dedication for the benefit\nof the public at large and to the detriment of our heirs and\nsuccessors. We intend this dedication to be an overt act of\nrelinquishment in perpetuity of all present and future rights to this\nsoftware under copyright law.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n\nFor more information, please refer to <http://unlicense.org/>\n"
  },
  {
    "path": "appveyor.yml",
    "content": "environment:\n\n  matrix:\n\n    - PYTHON: \"C:\\\\Python27\"\n    - PYTHON: \"C:\\\\Python34\"\n    - PYTHON: \"C:\\\\Python35\"\n    - PYTHON: \"C:\\\\Python27-x64\"\n      DISTUTILS_USE_SDK: \"1\"\n    - PYTHON: \"C:\\\\Python34-x64\"\n      DISTUTILS_USE_SDK: \"1\"\n    - PYTHON: \"C:\\\\Python35-x64\"\n    - PYTHON: \"C:\\\\Python36-x64\"\n      DIR_CAYLEY: C:\\cayley\n\ncache:\n  - '%DIR_CAYLEY% -> appveyor.yml'\n\ninstall:\n  - set PATH=%PYTHON%;%PYTHON%\\Scripts;C:\\OpenSSL-Win64;%DIR_CAYLEY%;%SystemRoot%\\system32;%PATH%\n  - if not exist %DIR_CAYLEY% (\n      appveyor DownloadFile https://github.com/cayleygraph/cayley/releases/download/v0.7.0/cayley_0.7.0_windows_amd64.zip &&\n      7z x cayley_0.7.0_windows_amd64.zip -y -aoa -oC:\\ > NULs\n    )\n  # - appveyor DownloadFile https://github.com/cayleygraph/cayley/releases/download/v0.7.0/cayley_0.7.0_windows_amd64.zip -Timeout 5000\n  # - 7z x cayley_0.7.0_windows_amd64.zip cayley_0.7.0_windows_amd64\n  # - cd cayley_0.7.0_windows_amd64\n  - ps: $CayleyProcess = Start-Process \"cayley http --dbpath=30kmoviedata.nq.gz\" -PassThru\n  # We need wheel installed to build wheels\n  - \"%PYTHON%\\\\python.exe -m pip install wheel\"\n  - \"%PYTHON%\\\\python.exe -m pip install -r requirements.txt\"\n  - \"%PYTHON%\\\\python.exe -m pip install -r requirements.testing.txt\"\n\nbuild: off\n\ntest_script:\n  - \"%PYTHON%\\\\python.exe -m nose --with-coverage --cover-package=pyley\"\n\nafter_test:\n  # This step builds your wheels.\n  - \"%PYTHON%\\\\python.exe setup.py bdist_wheel\"\n\nartifacts:\n  # bdist_wheel puts your built wheel in the dist directory\n  - path: dist\\*\n\non_finish:\n  - ps: Stop-Process -Id $CayleyProcess.Id\n"
  },
  {
    "path": "pyley/__init__.py",
    "content": "\"\"\"pyley Python client for an open-source graph database Cayley\"\"\"\n\n__title__        = 'pyley'\n__version__      = '0.2.2.2'\n__author__       = 'Ziya SARIKAYA @ziyasal'\n__email__        = 'sarikayaziya@gmail.com',\n__license__      = 'MIT License'\n__copyright__    = 'Copyright 2014 Ziya SARIKAYA @ziyasal'\n__url__          = 'https://github.com/ziyasal/pyley'\n__download_url__ = 'https://pypi.org/pypi/pyley'\n__description__  = 'Python client for an open-source graph database Cayley'\n\nfrom .pyley import (\n    CayleyResponse,\n    CayleyClient,\n    GraphObject\n)\n"
  },
  {
    "path": "pyley/pyley.py",
    "content": "import json\nimport requests\n\nclass CayleyResponse(object):\n\n    def __init__(self, raw_response, result):\n        self.r = raw_response\n        self.result = result\n\n\nclass CayleyClient(object):\n\n    def __init__(self, url=\"http://localhost:64210\", version=\"v1\"):\n        self.url = \"%s/api/%s/query/gizmo\" % (url, version)\n        self.write_url = \"%s/api/%s/write\" % (url, version)\n        self.delete_url = \"%s/api/%s/delete\" % (url, version)\n\n\n    def add_query_limit(self, limit):\n        if isinstance(limit, int):\n            self.url = self.url + '?limit=' + str(limit)\n        else:\n            raise Exception(\"Invalid parameter for adding query limit, should be integer.\")\n\n\n    def Send(self, query):\n        if isinstance(query, str):\n            r = requests.post(self.url, data=query.encode('utf-8'))\n            return CayleyResponse(r, r.json())\n        elif isinstance(query, _GizmoQuery):\n            r = requests.post(self.url, data=str(query).encode('utf-8'))\n            return CayleyResponse(r, r.json())\n        else:\n            raise Exception(\"Invalid query parameter in Send\")\n\n\n    def AddQuad(self, subject, predicate, object_, label=None):\n        return self.AddQuads([(subject, predicate, object_, label)])\n\n\n    def AddQuads(self, quads):\n        quads = [\n            {\n                \"subject\": q[0],\n                \"predicate\": q[1],\n                \"object\": q[2],\n                \"label\": None if len(q) < 4 else q[3]\n            }\n            for q in quads\n        ]\n        r = requests.post(self.write_url, json=quads)\n        return CayleyResponse(r, r.json())\n\n\n    def DeleteQuad(self, subject, predicate, object_, label=None):\n        return self.DeleteQuads([(subject, predicate, object_, label)])\n        \n\n    def DeleteQuads(self, quads):\n        quads = [\n            {\n                \"subject\": q[0],\n                \"predicate\": q[1],\n                \"object\": q[2],\n                \"label\": None if len(q) < 4 else q[3]\n            }\n            for q in quads\n        ]\n        r = requests.post(self.delete_url, json=quads)\n        return CayleyResponse(r, r.json())\n\n\nclass _GizmoQuery(object):\n    queryDeclarations = None\n\n    def __init__(self):\n        self.queryDeclarations = []\n\n\n    def __str__(self):\n        return \".\".join([str(d) for d in self.queryDeclarations])\n\n\n    def _put(self, token, *parameters):\n        q = _QueryDefinition(token, *parameters)\n        self.queryDeclarations.append(q)\n\n\nclass GraphObject(object):\n    def V(self):\n        return _Vertex(\"g.V()\")\n\n\n    def V(self, *node_ids):\n        builder = []\n        l = len(node_ids)\n        for index, node_id in enumerate(node_ids):\n            if index == l - 1:\n                builder.append(u\"'{0:s}'\".format(node_id))\n            else:\n                builder.append(u\"'{0:s}',\".format(node_id))\n\n        return _Vertex(u\"g.V({0:s})\".format(\"\".join(builder)))\n\n\n    def M(self):\n        return _Morphism(\"g.Morphism()\")\n\n\n    def Vertex(self):\n        return self.V()\n    \n\n    def Vertex(self, *node_ids):\n        if len(node_ids) == 0:\n            return self.V()\n        return self.V(*node_ids)\n\n\n    def Morphism(self):\n        return self.M()\n\n\n    def Emit(self, data):\n        return \"g.Emit({0:s})\".format(json.dumps(data, default=lambda o: o.__dict__, sort_keys=True))\n\n\nclass _Path(_GizmoQuery):\n\n    def __init__(self, parent):\n        _GizmoQuery.__init__(self)\n        self._put(parent)\n\n\n    def Out(self, predicate=None, tags=None):\n        self._bounds(\"Out\", predicate, tags)\n        return self\n\n\n    def In(self, predicate=None, tags=None):\n        self._bounds(\"In\", predicate, tags)\n        return self\n\n\n    def Both(self, predicate=None, tags=None):\n        self._bounds(\"Both\", predicate, tags)\n        return self\n\n\n    def _bounds(self, method, predicate=None, tags=None):\n        if predicate is None and tags is None:\n            self._put(\"%s()\", method)\n        elif tags is None:\n            self._put(\"%s(%s)\", method, self._format_input_bounds(predicate))\n        else:\n            self._put(\n                \"%s(%s, %s)\",\n                method,\n                self._format_input_bounds(predicate),\n                self._format_input_bounds(tags)\n            )\n        return self\n\n\n    def _format_input_bounds(self, value):\n        if type(value) is dict:\n            return json.dumps(value)\n\n        if type(value) is str:\n            return \"'%s'\" % value\n\n        if value is None:\n            return 'null'\n\n        return value\n\n\n    def Is(self, *nodes):\n        self._put(\"Is('%s')\", \"', '\".join(nodes))\n        return self\n\n\n    def Has(self, predicate, object):\n        self._put(\"Has('%s', '%s')\", predicate, object)\n        return self\n\n\n    def HasR(self, predicate, object):\n        self._put(\"Has('%s', '%s')\", object, predicate)\n        return self\n\n\n    def Tag(self, *tags):\n        self._put(\"Tag(%s)\", json.dumps(tags))\n\n        return self\n\n    def Back(self, tag):\n        self._put(\"Back('%s')\", tag)\n        return self\n\n\n    def Save(self, predicate, tag):\n        self._put(\"Save('%s', '%s')\", predicate, tag)\n        return self\n\n\n    def Intersect(self, query):\n        if not isinstance(query, _Vertex) and type(query) is not str:\n            raise Exception(\"Invalid parameter in intersect query\")\n\n        self._put(\"Intersect(%s)\", query)\n        return self\n\n\n    def Union(self, query):\n        if not isinstance(query, _Vertex) and type(query) is not str:\n            raise Exception(\"Invalid parameter in union query\")\n\n        self._put(\"Union(%s)\", query)\n        return self\n\n\n    def Follow(self, query):\n        if not isinstance(query, _Morphism) and type(query) is not str:\n            raise Exception(\"Invalid parameter in follow query\")\n\n        self._put(\"Follow(%s)\", query)\n        return self\n\n\n    def FollowR(self, query):\n        if not isinstance(query, _Morphism) and type(query) is not str:\n            raise Exception(\"Invalid parameter in followr query\")\n\n        self._put(\"FollowR(%s)\", query)\n        return self\n\n\n    def build(self):\n        return str(self)\n\n\nclass _Vertex(_Path):\n\n    def All(self):\n        self._put(\"All()\")\n        return self\n\n\n    def GetLimit(self, limit):\n        self._put(\"GetLimit(%d)\", limit)\n        return self\n\n\nclass _Morphism(_Path):\n    pass\n\n\nclass _QueryDefinition(object):\n\n    def __init__(self, token, *parameters):\n        self.token = token\n        self.parameters = parameters\n\n\n    def __str__(self):\n        if len(self.parameters) > 0:\n            return str(self.token) % self.parameters\n        else:\n            return str(self.token)\n"
  },
  {
    "path": "requirements.testing.txt",
    "content": "python-coveralls\ncoverage\nnose\n"
  },
  {
    "path": "requirements.txt",
    "content": "requests\n"
  },
  {
    "path": "setup.cfg",
    "content": "[bdist_wheel]\nuniversal = 1\n\n[aliases]\ntest = nosetest\n\n[check-manifest]\nignore =\n  .travis.yml\n"
  },
  {
    "path": "setup.py",
    "content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nfrom __future__ import absolute_import, print_function\n\nimport os\nimport re\nimport codecs\n\nfrom setuptools import setup, find_packages\n\ncwd = os.path.abspath(os.path.dirname(__file__))\n\ndef read(filename):\n    with codecs.open(os.path.join(cwd, filename), 'rb', 'utf-8') as h:\n        return h.read()\n\nmetadata = read(os.path.join(cwd, 'pyley', '__init__.py'))\n\ndef extract_metaitem(meta):\n    meta_match = re.search(r\"\"\"^__{meta}__\\s+=\\s+['\\\"]([^'\\\"]*)['\\\"]\"\"\".format(meta=meta),\n                           metadata, re.MULTILINE)\n    if meta_match:\n        return meta_match.group(1)\n    raise RuntimeError('Unable to find __{meta}__ string.'.format(meta=meta))\n\nsetup(\n    name='pyley',\n    version=extract_metaitem('version'),\n    license=extract_metaitem('license'),\n    description=extract_metaitem('description'),\n    long_description=(read('README.rst')),\n    author=extract_metaitem('author'),\n    author_email=extract_metaitem('email'),\n    url=extract_metaitem('url'),\n    download_url=extract_metaitem('download_url'),\n    packages=find_packages(exclude=('tests')),\n    platforms=['Any'],\n    install_requires=['requests'],\n    tests_require=['python-coveralls', 'coverage', 'nose'],\n    keywords='graph database, cayley, cayley python client, client',\n    include_package_data=True,\n    classifiers=[\n        'Intended Audience :: Developers',\n        'License :: OSI Approved :: MIT License',\n        'Operating System :: OS Independent',\n        'Topic :: Software Development :: Libraries :: Python Modules',\n        'Programming Language :: Python',\n        'Programming Language :: Python :: 2.7',\n        'Programming Language :: Python :: 3.3',\n        'Programming Language :: Python :: 3.4',\n        'Programming Language :: Python :: 3.5',\n        'Programming Language :: Python :: 3.6',\n    ],\n)"
  },
  {
    "path": "tests/__init__.py",
    "content": ""
  },
  {
    "path": "tests/test_cayley_client.py",
    "content": "from unittest import TestCase\nfrom pyley import CayleyClient, GraphObject\n\n_CLIENT_URL = 'http://localhost:64210'\n\n\nclass CayleyClientTests(TestCase):\n\n    def test_add_limit(self):\n        client = CayleyClient(_CLIENT_URL)\n        client.add_query_limit(10000)\n        self.assertEqual(client.url, 'http://localhost:64210/api/v1/query/gizmo?limit=10000')\n\n\n    def test_add_limit_fails(self):\n        client = CayleyClient(_CLIENT_URL)\n        with self.assertRaises(Exception):\n            client.add_query_limit('str')\n\n\n    def test_send(self):\n        client = CayleyClient(_CLIENT_URL)\n        g = GraphObject()\n        query = g.V().Has(\"name\", \"Casablanca\") \\\n            .Out(\"/film/film/starring\") \\\n            .Out(\"/film/performance/actor\") \\\n            .Out(\"name\") \\\n            .All()\n        response = client.Send(query)\n\n        self.assertTrue(response.r.status_code == 200)\n        self.assertTrue(response.r is not None)\n        self.assertTrue(len(response.result) > 0)\n\n        query = g.V().HasR(\"name\", \"Casablanca\") \\\n            .Out(\"/film/film/starring\") \\\n            .Out(\"/film/performance/actor\") \\\n            .Out(\"name\") \\\n            .All()\n        response = client.Send(query)\n\n        self.assertTrue(response.r.status_code == 200)\n        self.assertTrue(response.r is not None)\n        self.assertTrue(len(response.result) > 0)\n\n\n    def test_a_add_quad(self):\n        client = CayleyClient(_CLIENT_URL)\n        response = client.AddQuad('foo', 'to', 'bar')\n        self.assertEqual(response.r.status_code, 200)\n\n        g = GraphObject()\n        query = g.V(\"foo\").Out('to').Is('bar').All()\n        response = client.Send(query)\n        self.assertEqual(len(response.result['result']), 1)\n\n\n    def test_b_delete_quad(self):\n        client = CayleyClient(_CLIENT_URL)\n        response = client.DeleteQuad('foo', 'to', 'bar')\n        self.assertEqual(response.r.status_code, 200)\n\n        g = GraphObject()\n\n        query = g.V(\"foo\").Out('to').Is(\"bar\").All()\n        response = client.Send(query)\n        self.assertIsNone(response.result['result'])\n\n\n    def test_c_add_quads(self):\n        client = CayleyClient(_CLIENT_URL)\n        response = client.AddQuads([\n            ('foo', 'to', 'bar'),\n            ('baz', 'from', 'quux')\n        ])\n        self.assertEqual(response.r.status_code, 200)\n\n        g = GraphObject()\n\n        query = g.V(\"foo\").Out('to').Is(\"bar\").Union(\n            g.V(\"baz\").Out('from').Is(\"quux\")\n        ).All()\n        response = client.Send(query)\n        self.assertEqual(len(response.result['result']), 2)\n\n\n    def test_d_delete_quads(self):\n        client = CayleyClient(_CLIENT_URL)\n        response = client.DeleteQuads([\n            ('foo', 'to', 'bar'),\n            ('baz', 'from', 'quux')\n        ])\n        self.assertEqual(response.r.status_code, 200)\n\n        g = GraphObject()\n\n        query = g.V(\"foo\").Out('to').Is(\"bar\").Union(\n            g.V(\"baz\").Out('from').Is('quux')\n        ).All()\n        response = client.Send(query)\n        self.assertIsNone(response.result['result'])\n"
  },
  {
    "path": "tests/test_gizmo_query.py",
    "content": "import unittest\nfrom pyley import GraphObject\n\n\nclass GizmoQueryTests(unittest.TestCase):\n\n    def setUp(self):\n        self.opts = dict(url='http://localhost:64210/api/v1/query/gizmo')\n\n\n    def test_vertex_query(self):\n        g = GraphObject()\n        query = g.Vertex()\n        self.assertEqual(query.build(), \"g.V()\")\n\n\n    def test_vertex_query_with_parameters(self):\n        g = GraphObject()\n        query = g.V(\"Humphrey Bogart\")\n        actual = query.build()\n        self.assertEqual(actual, \"g.V('Humphrey Bogart')\")\n\n\n    def test_morphism_query(self):\n        g = GraphObject()\n        query = g.Morphism()\n        self.assertEqual(query.build(), \"g.Morphism()\")\n\n\n    def test_out_query(self):\n        g = GraphObject()\n        query = g.V().Out('name')\n        actual = query.build()\n        \n        self.assertEqual(actual, \"g.V().Out('name')\")\n\n\n    def test_out_query_with_predicate(self):\n        g = GraphObject()\n        query = g.V().Out(g.Vertex())\n        actual = query.build()\n\n        self.assertEqual(actual, \"g.V().Out(g.V())\")\n\n\n    def test_out_query_with_predicate_as_dict_and_label(self):\n        g = GraphObject()\n        query = g.V().Out(['foo', 'bar'], 'qux')\n        actual = query.build()\n\n        self.assertEqual(actual, \"g.V().Out(['foo', 'bar'], 'qux')\")\n\n\n    def test_out_query_with_predicate_as_none_and_label_as_dict(self):\n        g = GraphObject()\n        query = g.V().Out(None, ['foo', 'bar'])\n        actual = query.build()\n\n        self.assertEqual(actual, \"g.V().Out(null, ['foo', 'bar'])\")\n\n\n    def test_in_query(self):\n        g = GraphObject()\n        query = g.V().In(\"name\").All()\n        actual = query.build()\n        \n        self.assertEqual(actual, \"g.V().In('name').All()\")\n\n\n    def test_both(self):\n        g = GraphObject()\n        query = g.V(\"F\").Both(\"follows\")\n        actual = query.build()\n        print(actual)\n        self.assertEqual(actual, \"g.V('F').Both('follows')\")\n\n\n    def test_is(self):\n        g = GraphObject()\n        query = g.V().Is('B', 'C')\n        actual = query.build()\n\n        self.assertEqual(actual, \"g.V().Is('B', 'C')\")\n\n\n    def test_tag(self):\n        g = GraphObject()\n        query = g.V().Tag('B', 'C')\n        actual = query.build()\n\n        self.assertEqual(actual, 'g.V().Tag([\"B\", \"C\"])')\n\n\n    def test_save(self):\n        g = GraphObject()\n        query = g.V().Save('B', 'C')\n        actual = query.build()\n\n        self.assertEqual(actual, \"g.V().Save('B', 'C')\")\n\n\n    def test_back(self):\n        g = GraphObject()\n        query = g.V().Back('B')\n        actual = query.build()\n\n        self.assertEqual(actual, \"g.V().Back('B')\")\n\n\n    def test_all_query(self):\n        g = GraphObject()\n        query = g.V(\"Humphrey Bogart\").All()\n        actual = query.build()\n        \n        self.assertEqual(actual, \"g.V('Humphrey Bogart').All()\")\n\n\n    def test_has_query(self):\n        g = GraphObject()\n        query = g.V().Has(\"name\", \"Casablanca\").All()\n        actual = query.build()\n        \n        self.assertEqual(actual, \"g.V().Has('name', 'Casablanca').All()\")\n\n\n    def test_complex_query1(self):\n        g = GraphObject()\n        query = g.V().Has(\"name\", \"Casablanca\") \\\n            .Out(\"/film/film/starring\") \\\n            .Out(\"/film/performance/actor\") \\\n            .Out(\"name\") \\\n            .All()\n        actual = query.build()\n        \n        self.assertEqual(actual, \"g.V().Has('name', 'Casablanca')\"\n                                 \".Out('/film/film/starring')\"\n                                 \".Out('/film/performance/actor')\"\n                                 \".Out('name')\"\n                                 \".All()\")\n\n\n    def test_follow_with_morphism_path_and_typed_query(self):\n        g = GraphObject()\n        film_to_actor = g.Morphism().Out(\"/film/film/starring\").Out(\"/film/performance/actor\")\n        query = g.V().Has(\"name\", \"Casablanca\").Follow(film_to_actor).Out(\"name\").All()\n        actual = query.build()\n        \n        self.assertEqual(actual, \"g.V().Has('name', 'Casablanca')\"\n                                 \".Follow(\"\n                                 \"g.Morphism().Out('/film/film/starring').Out('/film/performance/actor')\"\n                                 \").Out('name')\"\n                                 \".All()\")\n\n\n    def test_follow_with_morphism_path_and_str_query(self):\n        g = GraphObject()\n        film_to_actor = g.Morphism().Out(\"/film/film/starring\").Out(\"/film/performance/actor\")\n        query = g.V().Has(\"name\", \"Casablanca\").Follow(film_to_actor.build()).Out(\"name\").All()\n        actual = query.build()\n        \n        self.assertEqual(actual, \"g.V().Has('name', 'Casablanca')\"\n                                 \".Follow(\"\n                                 \"g.Morphism().Out('/film/film/starring').Out('/film/performance/actor')\"\n                                 \").Out('name')\"\n                                 \".All()\")\n\n\n    def test_follow_with_vertex(self):\n        g = GraphObject()\n\n        with self.assertRaises(Exception):\n            g.V().Follow(g.V()).build()\n\n\n    def test_union(self):\n        g = GraphObject()\n\n        query = g.Vertex().Union(g.Vertex())\n        actual = query.build()\n\n        self.assertEqual(actual, \"g.V().Union(g.V())\")\n\n\n    def test_intersect(self):\n        g = GraphObject()\n\n        query = g.Vertex().Intersect(g.Vertex())\n        actual = query.build()\n\n        self.assertEqual(actual, \"g.V().Intersect(g.V())\")\n\n\n    def test_get_limit(self):\n        g = GraphObject()\n        query = g.Vertex().GetLimit(5)\n        actual = query.build()\n        \n        self.assertEqual(actual, \"g.V().GetLimit(5)\")\n\n\n    def test_emit(self):\n        g = GraphObject()\n        query = g.Emit({'name': 'John', 'lastName': 'DOE', 'age': 25})\n        \n        self.assertEqual(query, 'g.Emit({\"age\": 25, \"lastName\": \"DOE\", \"name\": \"John\"})')\n\n\nif __name__ == '__main__':\n    unittest.main()\n"
  },
  {
    "path": "tox.ini",
    "content": "[tox]\nenvlist = clean,py27,py3,py36,pypy,pypy3\nskip_missing_interpreters = True\n\n[testenv]\ndeps = -Ur{toxinidir}/requirements.testing.txt\ncommands = python -m nose\nwhitelist_externals = pyenv install -s 2.7.11\n\t                  pyenv install -s 3.6.1\n\t                  pyenv install -s pypy-5.3.1\n\t                  pyenv local 2.7.11 3.6.1 pypy-5.3.1\n\n[testenv:clean]\ndeps = coverage\ncommands = coverage erase\n\n[testenv:report]\ncommands = nosetests --with-coverage --cover-package=pyley\n"
  }
]