Permalink
Browse files

tox test, setup.py

  • Loading branch information...
1 parent 90dd138 commit 194b5427ebb883e5dc6f0b0739c6d2f1ff9fbd73 @ikeikeikeike committed Jun 30, 2012
Showing with 176 additions and 21 deletions.
  1. +2 −2 .gitignore
  2. +3 −0 HISTORY.rst
  3. +9 −0 LICENSE
  4. +6 −0 MANIFEST.in
  5. 0 README.rst
  6. +15 −10 queryset_client/client.py
  7. +5 −0 setup.cfg
  8. +72 −0 setup.py
  9. +4 −0 tests/__init__.py
  10. +2 −2 tests/lazy.py
  11. +6 −6 tests/many_to_many.py
  12. +2 −0 tests/requirements.txt
  13. +6 −1 tests/slice.py
  14. +44 −0 tox.ini
View
@@ -60,7 +60,7 @@ TAGS
##### setup.py
build
dist
-django_spine.egg-info
+tastypie_queryset_client.egg-info
##### scala
lib/vetags/lang/scala/sources
@@ -76,4 +76,4 @@ junit-py*
#########
examples/django_spine/set.sh
-examples/django_spine/unset.sh
+examples/django_spine/unset.sh
View
@@ -0,0 +1,3 @@
+History
+========
+
View
@@ -0,0 +1,9 @@
+The MIT Lisence
+
+Copyright © 2012 Tatsuo Ikeda
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
@@ -0,0 +1,6 @@
+include tox.ini
+include LICENSE
+include README.rst
+include HISTORY.rst
+recursive-include tests *
+recursive-include examples *
View
No changes.
View
@@ -130,14 +130,15 @@ def _previous(self):
return self._clone(self.model.client(url_override=url).get())
def __getitem__(self, index):
- if isinstance(index, slice):
- start = index.start
- step = index.step
- stop = index.stop
- # TODO: slice QuerySet
- return [self._wrap_response(self._objects[i]) for i in range(start, stop)]
try:
- return self._wrap_response(self._objects[index])
+ if isinstance(index, slice):
+ start = index.start
+ step = index.step
+ stop = index.stop
+ # TODO: slice QuerySet
+ return [self._wrap_response(self._objects[i]) for i in range(start, stop)]
+ else:
+ return self._wrap_response(self._objects[index])
except KeyError as err:
raise IndexError(err)
@@ -165,7 +166,11 @@ def filter(self, *args, **kwargs):
def _filter(self, *args, **kwargs):
kwargs_ = dict(self._query.items() + kwargs.items())
clone = self._clone(self.model.client.get(*args, **kwargs_))
- clone._query = {"id__in": [parse_id(klass.resource_uri) for klass in clone[0:20]]}
+ # TODO: ↓↓↓ ManyToManyで 一件も relationがない場合の処理, 現状元のQuerySetの結果が返される ↓↓↓↓
+ # <QuerySet <class 'queryset_client.client.Response'> (0/0)>
+ clone._query = {
+ "id__in": [parse_id(klass.resource_uri) for klass in clone[0:len(clone)]]
+ }
return clone
def all(self):
@@ -279,12 +284,12 @@ def get_query_set(self):
class Model(object):
def __init__(self, client, model_name, endpoint, schema, objects=None):
+ self.client = getattr(client, model_name)
+ self.objects = objects or Manager(self)
self._client = client
self._model_name = model_name
self._endpoint = endpoint
self._schema = schema
- self.objects = objects or Manager(self)
- self.client = getattr(client, model_name)
self._schema_data = self.client.schema.get()
self._base_url = client._store["base_url"]
View
@@ -0,0 +1,5 @@
+[egg_info]
+tag_build =
+tag_date = 0
+tag_svn_revision = 0
+
View
@@ -0,0 +1,72 @@
+import os
+from setuptools import setup, find_packages
+# from setuptools.command.test import test
+
+version = '0.1.3'
+name = 'tastypie-queryset-client'
+short_description = 'Client for Tastypie. Provide operation similar to the Django Model API'
+long_description = open(os.path.join(os.path.dirname(__file__), 'README.rst')).read()
+
+
+def fullsplit(path, result=None):
+ """
+ Split a pathname into components (the opposite of os.path.join) in a
+ platform-neutral way.
+ """
+ if result is None:
+ result = []
+ head, tail = os.path.split(path)
+ if head == '':
+ return [tail] + result
+ if head == path:
+ return result
+ return fullsplit(head, [tail] + result)
+
+
+packages, data_files = [], []
+root_dir = os.path.dirname(__file__)
+if root_dir != '':
+ os.chdir(root_dir)
+extensions_dir = 'queryset_client'
+
+for dirpath, dirnames, filenames in os.walk(extensions_dir):
+ # Ignore dirnames that start with '.'
+ for i, dirname in enumerate(dirnames):
+ if dirname.startswith('.'):
+ del dirnames[i]
+ if '__init__.py' in filenames:
+ packages.append('.'.join(fullsplit(dirpath)))
+ elif filenames:
+ data_files.append([dirpath, [os.path.join(dirpath, f) for f in filenames]])
+
+
+setup(
+ name=name,
+ version=version,
+ description=short_description,
+ long_description=long_description,
+ classifiers=[
+ "Development Status :: 3 - Alpha",
+ # "Development Status :: 4 - Beta",
+ "Framework :: Django",
+ 'Environment :: Console',
+ "Environment :: Web Environment",
+ "Intended Audience :: Developers",
+ 'License :: OSI Approved :: MIT License',
+ "Programming Language :: Python :: 2.6",
+ "Programming Language :: Python :: 2.7",
+ 'Topic :: Utilities',
+ 'Topic :: Software Development :: Libraries :: Python Modules',
+ ],
+ keywords=['tastypie', 'client', 'django', 'rest', 'api', ],
+ author='Tatsuo Ikeda',
+ author_email='jp.ne.co.jp at gmail',
+ url='https://github.com/ikeikeikeike/tastypie-queryset-client',
+ license='MIT License',
+ packages=find_packages(),
+ include_package_data=True,
+ data_files=data_files,
+ install_requires=[],
+ # cmdclass={'test': pytest_test},
+ # tests_require=['pytest'],
+)
View
@@ -0,0 +1,4 @@
+import foreignkey
+import lazy
+import many_to_many
+import slice
View
@@ -3,6 +3,6 @@
client = Client("http://192.168.57.132:8888/message/v1/")
fl = client.inbox_message_many.objects.filter()
-print fl
+assert fl
for f in fl:
- print f
+ assert f
View
@@ -1,19 +1,19 @@
-from queryset_client import Client
+from queryset_client.client import Client, QuerySet
client = Client("http://192.168.57.132:8888/message/v1/")
for i in xrange(99, 110):
many = client.inbox_message_many.objects.get(id=i)
- print many.inbox_message
- print many.inbox_message.filter()
+ assert many.inbox_message
+ assert isinstance(many.inbox_message.filter(), QuerySet)
for i in client.inbox_message_many.objects.filter(id__in=xrange(99, 110)):
- print i.inbox_message
+ assert i.inbox_message
for i in client.inbox_message_many.objects.filter(id__in=xrange(99, 102)):
- print i.inbox_message.all()
+ assert i.inbox_message.all()
for i in client.inbox_message_many.objects.all():
- print i
+ assert i
View
@@ -0,0 +1,2 @@
+pytest
+django-tastypie
View
@@ -2,7 +2,12 @@
client = Client("http://192.168.57.132:8888/message/v1/")
+al = client.inbox.objects.all()
+
+for i in al[0:8]:
+ assert i
+
al = client.inbox_message_many.objects.all()
for i in al[0:10]:
- print i
+ assert i
View
44 tox.ini
@@ -0,0 +1,44 @@
+#
+# tox.ini for tastypie-queryset-client
+#
+
+[tox]
+envlist =
+ py25,
+ py26,
+ py27,
+# py31,
+# py32,
+
+[testenv]
+setenv =
+ PYTHONPATH = {toxinidir}/tests:{toxinidir}
+commands =
+ pytest tests/__init__.py
+deps =
+ -r{toxinidir}/tests/requirements.txt
+
+[testenv:py25]
+basepython = python2.5
+deps =
+ -r{toxinidir}/tests/requirements.txt
+
+[testenv:py26]
+basepython = python2.6
+deps =
+ -r{toxinidir}/tests/requirements.txt
+
+[testenv:py27]
+basepython = python2.7
+deps =
+ -r{toxinidir}/tests/requirements.txt
+
+[testenv:py31]
+basepython = python3.2
+deps =
+ -r{toxinidir}/tests/requirements.txt
+
+[testenv:py32]
+basepython = python3.2
+deps =
+ -r{toxinidir}/tests/requirements.txt

0 comments on commit 194b542

Please sign in to comment.