From 3be9aa567a58a6a684476cd7285d2b9014c23a6d Mon Sep 17 00:00:00 2001 From: Joe Paul Date: Tue, 28 Jun 2016 11:33:56 +0530 Subject: [PATCH 1/6] Initial Boilerplate --- .editorconfig | 21 +++ .github/ISSUE_TEMPLATE.md | 15 +++ .gitignore | 59 ++++++++ .travis.yml | 12 ++ CONTRIBUTING.rst | 114 ++++++++++++++++ HISTORY.rst | 8 ++ LICENSE | 31 +++++ MANIFEST.in | 11 ++ Makefile | 88 ++++++++++++ README.rst | 31 ++++- docs/Makefile | 177 ++++++++++++++++++++++++ docs/conf.py | 275 ++++++++++++++++++++++++++++++++++++++ docs/contributing.rst | 1 + docs/history.rst | 1 + docs/index.rst | 25 ++++ docs/installation.rst | 51 +++++++ docs/make.bat | 242 +++++++++++++++++++++++++++++++++ docs/readme.rst | 1 + docs/usage.rst | 7 + log.txt | 0 requirements_dev.txt | 10 ++ setup.cfg | 18 +++ setup.py | 53 ++++++++ spree/__init__.py | 5 + spree/spree.py | 1 + tests/__init__.py | 1 + tests/test_spree.py | 29 ++++ 27 files changed, 1286 insertions(+), 1 deletion(-) create mode 100644 .editorconfig create mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 CONTRIBUTING.rst create mode 100755 HISTORY.rst create mode 100755 LICENSE create mode 100644 MANIFEST.in create mode 100644 Makefile create mode 100644 docs/Makefile create mode 100755 docs/conf.py create mode 100644 docs/contributing.rst create mode 100644 docs/history.rst create mode 100644 docs/index.rst create mode 100644 docs/installation.rst create mode 100644 docs/make.bat create mode 100644 docs/readme.rst create mode 100644 docs/usage.rst create mode 100644 log.txt create mode 100644 requirements_dev.txt create mode 100644 setup.cfg create mode 100644 setup.py create mode 100644 spree/__init__.py create mode 100644 spree/spree.py create mode 100644 tests/__init__.py create mode 100644 tests/test_spree.py diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..d4a2c44 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,21 @@ +# http://editorconfig.org + +root = true + +[*] +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true +insert_final_newline = true +charset = utf-8 +end_of_line = lf + +[*.bat] +indent_style = tab +end_of_line = crlf + +[LICENSE] +insert_final_newline = false + +[Makefile] +indent_style = tab diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..02c2459 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,15 @@ +* spree version: +* Python version: +* Operating System: + +### Description + +Describe what you were trying to get done. +Tell us what happened, what went wrong, and what you expected to happen. + +### What I Did + +``` +Paste the command(s) you ran and the output. +If there was a crash, please include the traceback here. +``` diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7d44098 --- /dev/null +++ b/.gitignore @@ -0,0 +1,59 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +.hypothesis/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..0b8002e --- /dev/null +++ b/.travis.yml @@ -0,0 +1,12 @@ +language: python +python: + - "2.7" + - "3.3" + - "3.4" + - "3.5" +# command to install dependencies +install: "pip install -r requirements_dev.txt" +# before script run flake8 +before_script: flake8 . +# command to run tests +script: python setup.py test diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst new file mode 100644 index 0000000..f93510e --- /dev/null +++ b/CONTRIBUTING.rst @@ -0,0 +1,114 @@ +.. highlight:: shell + +============ +Contributing +============ + +Contributions are welcome, and they are greatly appreciated! Every +little bit helps, and credit will always be given. + +You can contribute in many ways: + +Types of Contributions +---------------------- + +Report Bugs +~~~~~~~~~~~ + +Report bugs at https://github.com/audreyr/spree/issues. + +If you are reporting a bug, please include: + +* Your operating system name and version. +* Any details about your local setup that might be helpful in troubleshooting. +* Detailed steps to reproduce the bug. + +Fix Bugs +~~~~~~~~ + +Look through the GitHub issues for bugs. Anything tagged with "bug" +and "help wanted" is open to whoever wants to implement it. + +Implement Features +~~~~~~~~~~~~~~~~~~ + +Look through the GitHub issues for features. Anything tagged with "enhancement" +and "help wanted" is open to whoever wants to implement it. + +Write Documentation +~~~~~~~~~~~~~~~~~~~ + +spree could always use more documentation, whether as part of the +official spree docs, in docstrings, or even on the web in blog posts, +articles, and such. + +Submit Feedback +~~~~~~~~~~~~~~~ + +The best way to send feedback is to file an issue at https://github.com/audreyr/spree/issues. + +If you are proposing a feature: + +* Explain in detail how it would work. +* Keep the scope as narrow as possible, to make it easier to implement. +* Remember that this is a volunteer-driven project, and that contributions + are welcome :) + +Get Started! +------------ + +Ready to contribute? Here's how to set up `spree` for local development. + +1. Fork the `spree` repo on GitHub. +2. Clone your fork locally:: + + $ git clone git@github.com:your_name_here/spree.git + +3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:: + + $ mkvirtualenv spree + $ cd spree/ + $ python setup.py develop + +4. Create a branch for local development:: + + $ git checkout -b name-of-your-bugfix-or-feature + + Now you can make your changes locally. + +5. When you're done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:: + + $ flake8 spree tests + $ python setup.py test or py.test + $ tox + + To get flake8 and tox, just pip install them into your virtualenv. + +6. Commit your changes and push your branch to GitHub:: + + $ git add . + $ git commit -m "Your detailed description of your changes." + $ git push origin name-of-your-bugfix-or-feature + +7. Submit a pull request through the GitHub website. + +Pull Request Guidelines +----------------------- + +Before you submit a pull request, check that it meets these guidelines: + +1. The pull request should include tests. +2. If the pull request adds functionality, the docs should be updated. Put + your new functionality into a function with a docstring, and add the + feature to the list in README.rst. +3. The pull request should work for Python 2.6, 2.7, 3.3, 3.4 and 3.5, and for PyPy. Check + https://travis-ci.org/audreyr/spree/pull_requests + and make sure that the tests pass for all supported Python versions. + +Tips +---- + +To run a subset of tests:: + +$ py.test tests.test_spree + diff --git a/HISTORY.rst b/HISTORY.rst new file mode 100755 index 0000000..89c708f --- /dev/null +++ b/HISTORY.rst @@ -0,0 +1,8 @@ +======= +History +======= + +0.1.0 (2016-06-27) +------------------ + +* First release on PyPI. diff --git a/LICENSE b/LICENSE new file mode 100755 index 0000000..2d386d2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,31 @@ + +BSD License + +Copyright (c) 2016, Fulfil.IO Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. + +* Neither the name of spree nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..965b2dd --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,11 @@ +include AUTHORS.rst +include CONTRIBUTING.rst +include HISTORY.rst +include LICENSE +include README.rst + +recursive-include tests * +recursive-exclude * __pycache__ +recursive-exclude * *.py[co] + +recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..686635f --- /dev/null +++ b/Makefile @@ -0,0 +1,88 @@ +.PHONY: clean clean-test clean-pyc clean-build docs help +.DEFAULT_GOAL := help +define BROWSER_PYSCRIPT +import os, webbrowser, sys +try: + from urllib import pathname2url +except: + from urllib.request import pathname2url + +webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1]))) +endef +export BROWSER_PYSCRIPT + +define PRINT_HELP_PYSCRIPT +import re, sys + +for line in sys.stdin: + match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line) + if match: + target, help = match.groups() + print("%-20s %s" % (target, help)) +endef +export PRINT_HELP_PYSCRIPT +BROWSER := python -c "$$BROWSER_PYSCRIPT" + +help: + @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) + +clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts + + +clean-build: ## remove build artifacts + rm -fr build/ + rm -fr dist/ + rm -fr .eggs/ + find . -name '*.egg-info' -exec rm -fr {} + + find . -name '*.egg' -exec rm -f {} + + +clean-pyc: ## remove Python file artifacts + find . -name '*.pyc' -exec rm -f {} + + find . -name '*.pyo' -exec rm -f {} + + find . -name '*~' -exec rm -f {} + + find . -name '__pycache__' -exec rm -fr {} + + +clean-test: ## remove test and coverage artifacts + rm -fr .tox/ + rm -f .coverage + rm -fr htmlcov/ + +lint: ## check style with flake8 + flake8 spree tests + +test: ## run tests quickly with the default Python + py.test + + +test-all: ## run tests on every Python version with tox + tox + +coverage: ## check code coverage quickly with the default Python + coverage run --source spree py.test + + coverage report -m + coverage html + $(BROWSER) htmlcov/index.html + +docs: ## generate Sphinx HTML documentation, including API docs + rm -f docs/spree.rst + rm -f docs/modules.rst + sphinx-apidoc -o docs/ spree + $(MAKE) -C docs clean + $(MAKE) -C docs html + $(BROWSER) docs/_build/html/index.html + +servedocs: docs ## compile the docs watching for changes + watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D . + +release: clean ## package and upload a release + python setup.py sdist upload + python setup.py bdist_wheel upload + +dist: clean ## builds source and wheel package + python setup.py sdist + python setup.py bdist_wheel + ls -l dist + +install: clean ## install the package to the active Python's site-packages + python setup.py install diff --git a/README.rst b/README.rst index 42857da..57f3c83 100644 --- a/README.rst +++ b/README.rst @@ -1,2 +1,31 @@ +=============================== Spree API Client in Python -========================== +=============================== + + +.. image:: https://img.shields.io/pypi/v/spree.svg + :target: https://pypi.python.org/pypi/spree + +.. image:: https://img.shields.io/travis/audreyr/spree.svg + :target: https://travis-ci.org/audreyr/spree + +.. image:: https://readthedocs.org/projects/spree/badge/?version=latest + :target: https://spree.readthedocs.io/en/latest/?badge=latest + :alt: Documentation Status + +.. image:: https://pyup.io/repos/github/audreyr/cookiecutter-django/shield.svg + :target: https://pyup.io/repos/github/audreyr/spree/ + :alt: Updates + + +Spree python api client + + +* Free software: BSD license +* Documentation: https://spree.readthedocs.io. + + +Features +-------- + +* TODO diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..2ad2909 --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,177 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = _build + +# User-friendly check for sphinx-build +ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) +$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) +endif + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . +# the i18n builder cannot share the environment and doctrees with the others +I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . + +.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext + +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " singlehtml to make a single large HTML file" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " devhelp to make HTML files and a Devhelp project" + @echo " epub to make an epub" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " latexpdf to make LaTeX files and run them through pdflatex" + @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" + @echo " text to make text files" + @echo " man to make manual pages" + @echo " texinfo to make Texinfo files" + @echo " info to make Texinfo files and run them through makeinfo" + @echo " gettext to make PO message catalogs" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " xml to make Docutils-native XML files" + @echo " pseudoxml to make pseudoxml-XML files for display purposes" + @echo " linkcheck to check all external links for integrity" + @echo " doctest to run all doctests embedded in the documentation (if enabled)" + +clean: + rm -rf $(BUILDDIR)/* + +html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +dirhtml: + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +singlehtml: + $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml + @echo + @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." + +pickle: + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +json: + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @echo + @echo "Build finished; now you can process the JSON files." + +htmlhelp: + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in $(BUILDDIR)/htmlhelp." + +qthelp: + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp + @echo + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ + ".qhcp project file in $(BUILDDIR)/qthelp, like this:" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/spree.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/spree.qhc" + +devhelp: + $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp + @echo + @echo "Build finished." + @echo "To view the help file:" + @echo "# mkdir -p $$HOME/.local/share/devhelp/spree" + @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/spree" + @echo "# devhelp" + +epub: + $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub + @echo + @echo "Build finished. The epub file is in $(BUILDDIR)/epub." + +latex: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." + @echo "Run \`make' in that directory to run these through (pdf)latex" \ + "(use \`make latexpdf' here to do that automatically)." + +latexpdf: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through pdflatex..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +latexpdfja: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through platex and dvipdfmx..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +text: + $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text + @echo + @echo "Build finished. The text files are in $(BUILDDIR)/text." + +man: + $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man + @echo + @echo "Build finished. The manual pages are in $(BUILDDIR)/man." + +texinfo: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo + @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." + @echo "Run \`make' in that directory to run these through makeinfo" \ + "(use \`make info' here to do that automatically)." + +info: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo "Running Texinfo files through makeinfo..." + make -C $(BUILDDIR)/texinfo info + @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." + +gettext: + $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale + @echo + @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." + +changes: + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @echo + @echo "The overview file is in $(BUILDDIR)/changes." + +linkcheck: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/linkcheck/output.txt." + +doctest: + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest + @echo "Testing of doctests in the sources finished, look at the " \ + "results in $(BUILDDIR)/doctest/output.txt." + +xml: + $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml + @echo + @echo "Build finished. The XML files are in $(BUILDDIR)/xml." + +pseudoxml: + $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml + @echo + @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." diff --git a/docs/conf.py b/docs/conf.py new file mode 100755 index 0000000..e188439 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,275 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# spree documentation build configuration file, created by +# sphinx-quickstart on Tue Jul 9 22:26:36 2013. +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys +import os + +# If extensions (or modules to document with autodoc) are in another +# directory, add these directories to sys.path here. If the directory is +# relative to the documentation root, use os.path.abspath to make it +# absolute, like shown here. +#sys.path.insert(0, os.path.abspath('.')) + +# Get the project root dir, which is the parent dir of this +cwd = os.getcwd() +project_root = os.path.dirname(cwd) + +# Insert the project root dir as the first element in the PYTHONPATH. +# This lets us ensure that the source package is imported, and that its +# version is used. +sys.path.insert(0, project_root) + +import spree + +# -- General configuration --------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode'] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'spree' +copyright = u"2016, Fulfil.IO Inc." + +# The version info for the project you're documenting, acts as replacement +# for |version| and |release|, also used in various other places throughout +# the built documents. +# +# The short X.Y version. +version = spree.__version__ +# The full version, including alpha/beta/rc tags. +release = spree.__version__ + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +#language = None + +# There are two options for replacing |today|: either, you set today to +# some non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ['_build'] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built +# documents. +#keep_warnings = False + + +# -- Options for HTML output ------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'default' + +# Theme options are theme-specific and customize the look and feel of a +# theme further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as +# html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the +# top of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon +# of the docs. This file should be a Windows icon file (.ico) being +# 16x16 or 32x32 pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) +# here, relative to this directory. They are copied after the builtin +# static files, so a file named "default.css" will overwrite the builtin +# "default.css". +html_static_path = ['_static'] + +# If not '', a 'Last updated on:' timestamp is inserted at every page +# bottom, using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names +# to template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_domain_indices = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. +# Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. +# Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages +# will contain a tag referring to it. The value of this option +# must be the base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Output file base name for HTML help builder. +htmlhelp_basename = 'spreedoc' + + +# -- Options for LaTeX output ------------------------------------------ + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + #'papersize': 'letterpaper', + + # The font size ('10pt', '11pt' or '12pt'). + #'pointsize': '10pt', + + # Additional stuff for the LaTeX preamble. + #'preamble': '', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass +# [howto/manual]). +latex_documents = [ + ('index', 'spree.tex', + u'spree Documentation', + u'Fulfil.IO Inc.', 'manual'), +] + +# The name of an image file (relative to this directory) to place at +# the top of the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings +# are parts, not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True + + +# -- Options for manual page output ------------------------------------ + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ('index', 'spree', + u'spree Documentation', + [u'Fulfil.IO Inc.'], 1) +] + +# If true, show URL addresses after external links. +#man_show_urls = False + + +# -- Options for Texinfo output ---------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ('index', 'spree', + u'spree Documentation', + u'Fulfil.IO Inc.', + 'spree', + 'One line description of project.', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +#texinfo_appendices = [] + +# If false, no module index is generated. +#texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +#texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +#texinfo_no_detailmenu = False diff --git a/docs/contributing.rst b/docs/contributing.rst new file mode 100644 index 0000000..e582053 --- /dev/null +++ b/docs/contributing.rst @@ -0,0 +1 @@ +.. include:: ../CONTRIBUTING.rst diff --git a/docs/history.rst b/docs/history.rst new file mode 100644 index 0000000..2506499 --- /dev/null +++ b/docs/history.rst @@ -0,0 +1 @@ +.. include:: ../HISTORY.rst diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..d10d4a7 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,25 @@ +.. spree documentation master file, created by + sphinx-quickstart on Tue Jul 9 22:26:36 2013. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to spree's documentation! +====================================== + +Contents: + +.. toctree:: + :maxdepth: 2 + + readme + installation + usage + contributing + history + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/docs/installation.rst b/docs/installation.rst new file mode 100644 index 0000000..c154fd7 --- /dev/null +++ b/docs/installation.rst @@ -0,0 +1,51 @@ +.. highlight:: shell + +============ +Installation +============ + + +Stable release +-------------- + +To install spree, run this command in your terminal: + +.. code-block:: console + + $ pip install spree + +This is the preferred method to install spree, as it will always install the most recent stable release. + +If you don't have `pip`_ installed, this `Python installation guide`_ can guide +you through the process. + +.. _pip: https://pip.pypa.io +.. _Python installation guide: http://docs.python-guide.org/en/latest/starting/installation/ + + +From sources +------------ + +The sources for spree can be downloaded from the `Github repo`_. + +You can either clone the public repository: + +.. code-block:: console + + $ git clone git://github.com/audreyr/spree + +Or download the `tarball`_: + +.. code-block:: console + + $ curl -OL https://github.com/audreyr/spree/tarball/master + +Once you have a copy of the source, you can install it with: + +.. code-block:: console + + $ python setup.py install + + +.. _Github repo: https://github.com/audreyr/spree +.. _tarball: https://github.com/audreyr/spree/tarball/master diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..7f3d3e8 --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,242 @@ +@ECHO OFF + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set BUILDDIR=_build +set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . +set I18NSPHINXOPTS=%SPHINXOPTS% . +if NOT "%PAPER%" == "" ( + set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% + set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% +) + +if "%1" == "" goto help + +if "%1" == "help" ( + :help + echo.Please use `make ^` where ^ is one of + echo. html to make standalone HTML files + echo. dirhtml to make HTML files named index.html in directories + echo. singlehtml to make a single large HTML file + echo. pickle to make pickle files + echo. json to make JSON files + echo. htmlhelp to make HTML files and a HTML help project + echo. qthelp to make HTML files and a qthelp project + echo. devhelp to make HTML files and a Devhelp project + echo. epub to make an epub + echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter + echo. text to make text files + echo. man to make manual pages + echo. texinfo to make Texinfo files + echo. gettext to make PO message catalogs + echo. changes to make an overview over all changed/added/deprecated items + echo. xml to make Docutils-native XML files + echo. pseudoxml to make pseudoxml-XML files for display purposes + echo. linkcheck to check all external links for integrity + echo. doctest to run all doctests embedded in the documentation if enabled + goto end +) + +if "%1" == "clean" ( + for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i + del /q /s %BUILDDIR%\* + goto end +) + + +%SPHINXBUILD% 2> nul +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +if "%1" == "html" ( + %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/html. + goto end +) + +if "%1" == "dirhtml" ( + %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. + goto end +) + +if "%1" == "singlehtml" ( + %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. + goto end +) + +if "%1" == "pickle" ( + %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can process the pickle files. + goto end +) + +if "%1" == "json" ( + %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can process the JSON files. + goto end +) + +if "%1" == "htmlhelp" ( + %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can run HTML Help Workshop with the ^ +.hhp project file in %BUILDDIR%/htmlhelp. + goto end +) + +if "%1" == "qthelp" ( + %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can run "qcollectiongenerator" with the ^ +.qhcp project file in %BUILDDIR%/qthelp, like this: + echo.^> qcollectiongenerator %BUILDDIR%\qthelp\spree.qhcp + echo.To view the help file: + echo.^> assistant -collectionFile %BUILDDIR%\qthelp\spree.ghc + goto end +) + +if "%1" == "devhelp" ( + %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. + goto end +) + +if "%1" == "epub" ( + %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The epub file is in %BUILDDIR%/epub. + goto end +) + +if "%1" == "latex" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "latexpdf" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + cd %BUILDDIR%/latex + make all-pdf + cd %BUILDDIR%/.. + echo. + echo.Build finished; the PDF files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "latexpdfja" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + cd %BUILDDIR%/latex + make all-pdf-ja + cd %BUILDDIR%/.. + echo. + echo.Build finished; the PDF files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "text" ( + %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The text files are in %BUILDDIR%/text. + goto end +) + +if "%1" == "man" ( + %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The manual pages are in %BUILDDIR%/man. + goto end +) + +if "%1" == "texinfo" ( + %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. + goto end +) + +if "%1" == "gettext" ( + %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The message catalogs are in %BUILDDIR%/locale. + goto end +) + +if "%1" == "changes" ( + %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes + if errorlevel 1 exit /b 1 + echo. + echo.The overview file is in %BUILDDIR%/changes. + goto end +) + +if "%1" == "linkcheck" ( + %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck + if errorlevel 1 exit /b 1 + echo. + echo.Link check complete; look for any errors in the above output ^ +or in %BUILDDIR%/linkcheck/output.txt. + goto end +) + +if "%1" == "doctest" ( + %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest + if errorlevel 1 exit /b 1 + echo. + echo.Testing of doctests in the sources finished, look at the ^ +results in %BUILDDIR%/doctest/output.txt. + goto end +) + +if "%1" == "xml" ( + %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The XML files are in %BUILDDIR%/xml. + goto end +) + +if "%1" == "pseudoxml" ( + %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. + goto end +) + +:end diff --git a/docs/readme.rst b/docs/readme.rst new file mode 100644 index 0000000..72a3355 --- /dev/null +++ b/docs/readme.rst @@ -0,0 +1 @@ +.. include:: ../README.rst diff --git a/docs/usage.rst b/docs/usage.rst new file mode 100644 index 0000000..344696b --- /dev/null +++ b/docs/usage.rst @@ -0,0 +1,7 @@ +===== +Usage +===== + +To use spree in a project:: + + import spree diff --git a/log.txt b/log.txt new file mode 100644 index 0000000..e69de29 diff --git a/requirements_dev.txt b/requirements_dev.txt new file mode 100644 index 0000000..be2f1a1 --- /dev/null +++ b/requirements_dev.txt @@ -0,0 +1,10 @@ +pip==8.1.2 +bumpversion==0.5.3 +wheel==0.29.0 +watchdog==0.8.3 +flake8==2.6.0 +tox==2.3.1 +coverage==4.1 +Sphinx==1.4.4 + +pytest==2.9.2 diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..e01aaac --- /dev/null +++ b/setup.cfg @@ -0,0 +1,18 @@ +[bumpversion] +current_version = 0.1.0 +commit = True +tag = True + +[bumpversion:file:setup.py] +search = version='{current_version}' +replace = version='{new_version}' + +[bumpversion:file:spree/__init__.py] +search = __version__ = '{current_version}' +replace = __version__ = '{new_version}' + +[wheel] +universal = 1 + +[flake8] +exclude = docs diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..5d22907 --- /dev/null +++ b/setup.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from setuptools import setup + +with open('README.rst') as readme_file: + readme = readme_file.read() + +with open('HISTORY.rst') as history_file: + history = history_file.read() + +requirements = [ + 'pyactiveresource', +] + +test_requirements = [ + 'pytest', +] + +setup( + name='spree', + version='0.1.0', + description="Spree python api client", + long_description=readme + '\n\n' + history, + author="Fulfil.IO Inc.", + author_email='info@fulfil.io', + url='https://github.com/audreyr/spree', + packages=[ + 'spree', + ], + package_dir={'spree': + 'spree'}, + include_package_data=True, + install_requires=requirements, + license="BSD license", + zip_safe=False, + keywords='spree', + classifiers=[ + 'Development Status :: 2 - Pre-Alpha', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: BSD License', + 'Natural Language :: English', + "Programming Language :: Python :: 2", + 'Programming Language :: Python :: 2.6', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + ], + test_suite='tests', + tests_require=test_requirements +) diff --git a/spree/__init__.py b/spree/__init__.py new file mode 100644 index 0000000..8a5e943 --- /dev/null +++ b/spree/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- + +__author__ = 'Fulfil.IO Inc.' +__email__ = 'info@fulfil.io' +__version__ = '0.1.0' diff --git a/spree/spree.py b/spree/spree.py new file mode 100644 index 0000000..40a96af --- /dev/null +++ b/spree/spree.py @@ -0,0 +1 @@ +# -*- coding: utf-8 -*- diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..40a96af --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1 @@ +# -*- coding: utf-8 -*- diff --git a/tests/test_spree.py b/tests/test_spree.py new file mode 100644 index 0000000..008bb0e --- /dev/null +++ b/tests/test_spree.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +test_spree +---------------------------------- + +Tests for `spree` module. +""" + +import pytest # noqa + + +from spree import spree + + +class TestSpree(object): + + @classmethod + def setup_class(cls): + spree + pass + + def test_something(self): + pass + + @classmethod + def teardown_class(cls): + pass From eb976034f0efa9f4a9711093a233746345aaeb26 Mon Sep 17 00:00:00 2001 From: Joe Paul Date: Wed, 29 Jun 2016 18:13:54 +0530 Subject: [PATCH 2/6] Provision for importing products and orders --- .travis.yml | 2 +- docs/conf.py | 88 ++++++++--------- requirements_dev.txt | 1 + spree/__init__.py | 2 + spree/spree.py | 134 ++++++++++++++++++++++++++ tests/conftest.py | 57 +++++++++++ tests/responses/create_product.json | 1 + tests/responses/order-R123456789.json | 1 + tests/responses/orders.json | 1 + tests/responses/product-2.json | 1 + tests/responses/product-26.json | 1 + tests/responses/products.json | 1 + tests/test_pagination.py | 7 ++ tests/test_spree.py | 61 +++++++++--- 14 files changed, 302 insertions(+), 56 deletions(-) create mode 100644 tests/conftest.py create mode 100644 tests/responses/create_product.json create mode 100644 tests/responses/order-R123456789.json create mode 100644 tests/responses/orders.json create mode 100644 tests/responses/product-2.json create mode 100644 tests/responses/product-26.json create mode 100644 tests/responses/products.json create mode 100644 tests/test_pagination.py diff --git a/.travis.yml b/.travis.yml index 0b8002e..5432747 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,4 +9,4 @@ install: "pip install -r requirements_dev.txt" # before script run flake8 before_script: flake8 . # command to run tests -script: python setup.py test +script: py.test diff --git a/docs/conf.py b/docs/conf.py index e188439..3c93091 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -20,7 +20,7 @@ # directory, add these directories to sys.path here. If the directory is # relative to the documentation root, use os.path.abspath to make it # absolute, like shown here. -#sys.path.insert(0, os.path.abspath('.')) +# sys.path.insert(0, os.path.abspath('.')) # Get the project root dir, which is the parent dir of this cwd = os.getcwd() @@ -36,7 +36,7 @@ # -- General configuration --------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. -#needs_sphinx = '1.0' +# needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. @@ -49,7 +49,7 @@ source_suffix = '.rst' # The encoding of source files. -#source_encoding = 'utf-8-sig' +# source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' @@ -69,13 +69,13 @@ # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. -#language = None +# language = None # There are two options for replacing |today|: either, you set today to # some non-false value, then it is used: -#today = '' +# today = '' # Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' +# today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. @@ -83,28 +83,28 @@ # The reST default role (used for this markup: `text`) to use for all # documents. -#default_role = None +# default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True +# add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). -#add_module_names = True +# add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. -#show_authors = False +# show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] +# modindex_common_prefix = [] # If true, keep warnings as "system message" paragraphs in the built # documents. -#keep_warnings = False +# keep_warnings = False # -- Options for HTML output ------------------------------------------- @@ -116,27 +116,27 @@ # Theme options are theme-specific and customize the look and feel of a # theme further. For a list of options available for each theme, see the # documentation. -#html_theme_options = {} +# html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. -#html_theme_path = [] +# html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". -#html_title = None +# html_title = None # A shorter title for the navigation bar. Default is the same as # html_title. -#html_short_title = None +# html_short_title = None # The name of an image file (relative to this directory) to place at the # top of the sidebar. -#html_logo = None +# html_logo = None # The name of an image file (within the static path) to use as favicon # of the docs. This file should be a Windows icon file (.ico) being # 16x16 or 32x32 pixels large. -#html_favicon = None +# html_favicon = None # Add any paths that contain custom static files (such as style sheets) # here, relative to this directory. They are copied after the builtin @@ -146,46 +146,46 @@ # If not '', a 'Last updated on:' timestamp is inserted at every page # bottom, using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' +# html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. -#html_use_smartypants = True +# html_use_smartypants = True # Custom sidebar templates, maps document names to template names. -#html_sidebars = {} +# html_sidebars = {} # Additional templates that should be rendered to pages, maps page names # to template names. -#html_additional_pages = {} +# html_additional_pages = {} # If false, no module index is generated. -#html_domain_indices = True +# html_domain_indices = True # If false, no index is generated. -#html_use_index = True +# html_use_index = True # If true, the index is split into individual pages for each letter. -#html_split_index = False +# html_split_index = False # If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True +# html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. # Default is True. -#html_show_sphinx = True +# html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. # Default is True. -#html_show_copyright = True +# html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages # will contain a tag referring to it. The value of this option # must be the base URL from which the finished HTML is served. -#html_use_opensearch = '' +# html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None +# html_file_suffix = None # Output file base name for HTML help builder. htmlhelp_basename = 'spreedoc' @@ -195,13 +195,13 @@ latex_elements = { # The paper size ('letterpaper' or 'a4paper'). - #'papersize': 'letterpaper', + # 'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). - #'pointsize': '10pt', + # 'pointsize': '10pt', # Additional stuff for the LaTeX preamble. - #'preamble': '', + # 'preamble': '', } # Grouping the document tree into LaTeX files. List of tuples @@ -215,23 +215,23 @@ # The name of an image file (relative to this directory) to place at # the top of the title page. -#latex_logo = None +# latex_logo = None # For "manual" documents, if this is true, then toplevel headings # are parts, not chapters. -#latex_use_parts = False +# latex_use_parts = False # If true, show page references after internal links. -#latex_show_pagerefs = False +# latex_show_pagerefs = False # If true, show URL addresses after external links. -#latex_show_urls = False +# latex_show_urls = False # Documents to append as an appendix to all manuals. -#latex_appendices = [] +# latex_appendices = [] # If false, no module index is generated. -#latex_domain_indices = True +# latex_domain_indices = True # -- Options for manual page output ------------------------------------ @@ -245,7 +245,7 @@ ] # If true, show URL addresses after external links. -#man_show_urls = False +# man_show_urls = False # -- Options for Texinfo output ---------------------------------------- @@ -263,13 +263,13 @@ ] # Documents to append as an appendix to all manuals. -#texinfo_appendices = [] +# texinfo_appendices = [] # If false, no module index is generated. -#texinfo_domain_indices = True +# texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. -#texinfo_show_urls = 'footnote' +# texinfo_show_urls = 'footnote' # If true, do not generate a @detailmenu in the "Top" node's menu. -#texinfo_no_detailmenu = False +# texinfo_no_detailmenu = False diff --git a/requirements_dev.txt b/requirements_dev.txt index be2f1a1..6551eb4 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -8,3 +8,4 @@ coverage==4.1 Sphinx==1.4.4 pytest==2.9.2 +responses==0.5.1 \ No newline at end of file diff --git a/spree/__init__.py b/spree/__init__.py index 8a5e943..95d3f37 100644 --- a/spree/__init__.py +++ b/spree/__init__.py @@ -3,3 +3,5 @@ __author__ = 'Fulfil.IO Inc.' __email__ = 'info@fulfil.io' __version__ = '0.1.0' + +from .spree import Spree # noqa diff --git a/spree/spree.py b/spree/spree.py index 40a96af..fb46833 100644 --- a/spree/spree.py +++ b/spree/spree.py @@ -1 +1,135 @@ # -*- coding: utf-8 -*- +import requests + + +class Spree(object): + + def __init__(self, url, api_key): + self.url = url + self.api_key = api_key + self.session = requests.Session() + self.session.headers['X-Spree-Token'] = api_key + + @property + def product(self): + return Product(connection=self) + + @property + def orders(self): + return Orders(connection=self) + + @property + def stock_items(self): + return StockItems(connection=self) + + +class Pagination(object): + def __init__(self, data, items_attribute): + self.data = data + self.items = data[items_attribute] + self.current_index = -1 + + @property + def count(self): + return self.data['count'] + + def __iter__(self): + return self + + def __getitem__(self, key): + return self.data + + def next(self): + self.current_index += 1 + return self.items[self.current_index] + + +class Resource(object): + """ + A base class for all Resources to extend + """ + + def __init__(self, connection): + self.connection = connection + + @property + def url(self): + return self.connection.url + self.path + + def load_payload(self, data): + return data + + def all(self): + return Pagination( + self.connection.session.get(self.url).json(), + self.path[1:] + ) + + def find(self, id): + "find a given record" + # str() - ordernumber is a string + path = self.url + '/%s' % str(id) + return self.connection.session.get(path).json() + + def create(self, data): + "create a record with the given data" + payload = self.load_payload(data) + return self.connection.session.post(self.url, data=payload).json() + + def update(self, id, data): + "update the record with given data" + path = self.url + '/%d' % id + payload = self.load_payload(data) + return self.connection.session.put(path, data=payload).json() + + def delete(self, id): + "delete a given record" + path = self.url + '/%d' % id + return self.connection.session.delete(path).json() + + +class Product(Resource): + path = '/products' + + def load_payload(self, data): + payload = { + 'product[name]': data['name'] + } + if 'price' in data: + payload['product[price]'] = data['price'] + if 'shipping_category_id' in data: + payload['product[shipping_category_id]'] = \ + data['shipping_category_id'] + if 'sku' in data: + payload['product[sku]'] = data['sku'] + if 'description' in data: + payload['product[description]'] = data['description'] + if 'display_price' in data: + payload['product[display_price]'] = data['display_price'] + if 'available_on' in data: + payload['product[available_on]'] = data['available_on'] + if 'meta_description' in data: + payload['product[meta_description]'] = data['meta_description'] + if 'meta_keywords' in data: + payload['product[meta_keywords]'] = data['meta_keywords'] + if 'weight' in data: + payload['product[weight]'] = data['weight'] + if 'height' in data: + payload['product[height]'] = data['height'] + if 'width' in data: + payload['product[width]'] = data['width'] + if 'depth' in data: + payload['product[depth]'] = data['depth'] + if 'cost_price' in data: + payload['product[cost_price]'] = data['cost_price'] + + return super(Product, self).load_payload(payload) + + +class Orders(Resource): + path = '/orders' + + +class StockItems(Resource): + # TODO + path = '/stock_locations' diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..ae86a0a --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,57 @@ +import os +import pytest +import responses +from spree import Spree + + +@pytest.fixture +def fp(): + def wrapper(rel_path): + "return the full path of given rel_path" + return os.path.abspath( + os.path.join( + os.path.dirname(__file__), + rel_path + ) + ) + return wrapper + + +@pytest.fixture +def spree(): + return Spree('http://mystore/api', 'some-key') + + +@pytest.yield_fixture +def resp(fp): + rsps = responses.RequestsMock(False) + rsps.start() + + "Products" + rsps.add( + responses.GET, + 'http://mystore/api/products', + body=open(fp('responses/products.json'), 'r').read() + ) + rsps.add( + responses.GET, + 'http://mystore/api/products/2', + body=open(fp('responses/product-2.json'), 'r').read() + ) + + "Orders" + rsps.add( + responses.GET, + 'http://mystore/api/orders', + body=open(fp('responses/orders.json'), 'r').read() + ) + rsps.add( + responses.GET, + 'http://mystore/api/orders/R123456789', + body=open(fp('responses/order-R123456789.json'), 'r').read() + ) + + yield rsps + + rsps.stop() + rsps.reset() diff --git a/tests/responses/create_product.json b/tests/responses/create_product.json new file mode 100644 index 0000000..cf8791a --- /dev/null +++ b/tests/responses/create_product.json @@ -0,0 +1 @@ +{"id":27,"name":"iphone","description":null,"price":"100.0","display_price":"$100.00","available_on":"2016-06-28T19:44:49.600Z","slug":"iphone-f559d233-ac22-4da0-bb16-3ba7c7a26fd5","meta_description":null,"meta_keywords":null,"shipping_category_id":2,"taxon_ids":[],"total_on_hand":0,"has_variants":false,"master":{"id":37,"name":"iphone","sku":"","price":"100.0","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"iphone-f559d233-ac22-4da0-bb16-3ba7c7a26fd5","description":null,"track_inventory":true,"cost_price":null,"display_price":"$100.00","options_text":"","in_stock":false,"is_backorderable":true,"total_on_hand":0,"is_destroyed":false,"option_values":[],"images":[]},"variants":[],"option_types":[],"product_properties":[],"classifications":[]} \ No newline at end of file diff --git a/tests/responses/order-R123456789.json b/tests/responses/order-R123456789.json new file mode 100644 index 0000000..4b61717 --- /dev/null +++ b/tests/responses/order-R123456789.json @@ -0,0 +1 @@ +{"id":1,"number":"R123456789","item_total":"15.99","total":"17.63","ship_total":"0.0","state":"complete","adjustment_total":"1.64","user_id":null,"created_at":"2016-06-27T11:10:57.000Z","updated_at":"2016-06-27T11:10:59.000Z","completed_at":"2016-06-26T11:10:58.000Z","payment_total":"0.0","shipment_state":"pending","payment_state":"balance_due","email":"spree@example.com","special_instructions":null,"channel":"spree","included_tax_total":"0.0","additional_tax_total":"0.8","display_included_tax_total":"$0.00","display_additional_tax_total":"$0.80","tax_total":"0.8","currency":"USD","display_item_total":"$15.99","total_quantity":1,"display_total":"$17.63","display_ship_total":"$0.00","display_tax_total":"$0.80","token":"aAoojFjB1_PCBeLR1VPnIg","checkout_steps":["address","delivery","payment","confirm","complete"],"permissions":{"can_update":true},"bill_address":{"id":2,"firstname":"Cleve","lastname":"Lang","full_name":"Cleve Lang","address1":"980 Lind Centers","address2":"Suite 272","city":"Beerton","zipcode":"16804","phone":"937-786-0871","company":null,"alternative_phone":null,"country_id":232,"state_id":3561,"state_name":null,"state_text":"NY","country":{"id":232,"iso_name":"UNITED STATES","iso":"US","iso3":"USA","name":"United States","numcode":840},"state":{"id":3561,"name":"New York","abbr":"NY","country_id":232}},"ship_address":{"id":1,"firstname":"Barney","lastname":"Eichmann","full_name":"Barney Eichmann","address1":"5542 Legros Hollow","address2":"Suite 576","city":"Adriennemouth","zipcode":"16804","phone":"1-472-089-8821 x2157","company":null,"alternative_phone":null,"country_id":232,"state_id":3561,"state_name":null,"state_text":"NY","country":{"id":232,"iso_name":"UNITED STATES","iso":"US","iso3":"USA","name":"United States","numcode":840},"state":{"id":3561,"name":"New York","abbr":"NY","country_id":232}},"line_items":[{"id":1,"quantity":1,"price":"15.99","variant_id":1,"single_display_amount":"$15.99","display_amount":"$15.99","total":"16.79","variant":{"id":1,"name":"Ruby on Rails Tote","sku":"ROR-00011","price":"15.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"1467110886_ruby-on-rails-tote","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"17.0","display_price":"$15.99","options_text":"","in_stock":false,"is_backorderable":false,"total_on_hand":0,"is_destroyed":false,"option_values":[],"images":[],"product_id":1},"adjustments":[{"id":2,"source_type":"Spree::TaxRate","source_id":1,"adjustable_type":"Spree::LineItem","adjustable_id":1,"amount":"0.8","label":"North America 5.0%","mandatory":null,"eligible":true,"created_at":"2016-06-27T11:10:57.000Z","updated_at":"2016-06-27T11:10:58.000Z","display_amount":"$0.80"}]}],"payments":[{"id":1,"source_type":"Spree::CreditCard","source_id":1,"amount":"17.63","display_amount":"$17.63","payment_method_id":1,"response_code":"12345","state":"pending","avs_response":null,"created_at":"2016-06-27T11:10:59.000Z","updated_at":"2016-06-27T11:10:59.000Z","payment_method":{"id":1,"name":"Credit Card"},"source":{"id":1,"month":12,"year":2018,"cc_type":"visa","last_digits":"1111","name":"Sean Schofield","gateway_customer_profile_id":"BGS-1234","gateway_payment_profile_id":null}}],"shipments":[{"id":1,"tracking":null,"number":"H27539843006","cost":"5.0","shipped_at":null,"state":"pending","order_id":"R123456789","stock_location_name":"default","shipping_rates":[{"id":10,"name":"UPS Ground (USD)","cost":"5.0","selected":true,"shipping_method_id":1,"shipping_method_code":null,"display_cost":"$5.00"},{"id":11,"name":"UPS Two Day (USD)","cost":"10.0","selected":false,"shipping_method_id":2,"shipping_method_code":null,"display_cost":"$10.00"},{"id":12,"name":"UPS One Day (USD)","cost":"15.0","selected":false,"shipping_method_id":3,"shipping_method_code":null,"display_cost":"$15.00"}],"selected_shipping_rate":{"id":10,"name":"UPS Ground (USD)","cost":"5.0","selected":true,"shipping_method_id":1,"shipping_method_code":null,"display_cost":"$5.00"},"shipping_methods":[{"id":1,"code":null,"name":"UPS Ground (USD)","zones":[{"id":2,"name":"North America","description":"USA + Canada"}],"shipping_categories":[{"id":1,"name":"Default"}]},{"id":2,"code":null,"name":"UPS Two Day (USD)","zones":[{"id":2,"name":"North America","description":"USA + Canada"}],"shipping_categories":[{"id":1,"name":"Default"}]},{"id":3,"code":null,"name":"UPS One Day (USD)","zones":[{"id":2,"name":"North America","description":"USA + Canada"}],"shipping_categories":[{"id":1,"name":"Default"}]}],"manifest":[{"quantity":1,"states":{"on_hand":1},"variant_id":1}],"adjustments":[]}],"adjustments":[{"id":5,"source_type":"Spree::TaxRate","source_id":1,"adjustable_type":"Spree::Order","adjustable_id":1,"amount":"0.84","label":"Tax","mandatory":true,"eligible":true,"created_at":"2016-06-27T11:10:58.000Z","updated_at":"2016-06-27T11:10:58.000Z","display_amount":"$0.84"}],"credit_cards":[{"id":1,"month":12,"year":2018,"cc_type":"visa","last_digits":"1111","name":"Sean Schofield","gateway_customer_profile_id":"BGS-1234","gateway_payment_profile_id":null}]} \ No newline at end of file diff --git a/tests/responses/orders.json b/tests/responses/orders.json new file mode 100644 index 0000000..ea82652 --- /dev/null +++ b/tests/responses/orders.json @@ -0,0 +1 @@ +{"count":2,"current_page":1,"pages":1,"orders":[{"id":1,"number":"R123456789","item_total":"15.99","total":"17.63","ship_total":"0.0","state":"complete","adjustment_total":"1.64","user_id":null,"created_at":"2016-06-27T11:10:57.000Z","updated_at":"2016-06-27T11:10:59.000Z","completed_at":"2016-06-26T11:10:58.000Z","payment_total":"0.0","shipment_state":"pending","payment_state":"balance_due","email":"spree@example.com","special_instructions":null,"channel":"spree","included_tax_total":"0.0","additional_tax_total":"0.8","display_included_tax_total":"$0.00","display_additional_tax_total":"$0.80","tax_total":"0.8","currency":"USD","display_item_total":"$15.99","total_quantity":1,"display_total":"$17.63","display_ship_total":"$0.00","display_tax_total":"$0.80","token":"aAoojFjB1_PCBeLR1VPnIg","checkout_steps":["address","delivery","payment","confirm","complete"]},{"id":2,"number":"R987654321","item_total":"22.99","total":"25.35","ship_total":"0.0","state":"complete","adjustment_total":"2.36","user_id":null,"created_at":"2016-06-27T11:10:57.000Z","updated_at":"2016-06-27T11:10:59.000Z","completed_at":"2016-06-26T11:10:58.000Z","payment_total":"0.0","shipment_state":"pending","payment_state":"balance_due","email":"spree@example.com","special_instructions":null,"channel":"spree","included_tax_total":"0.0","additional_tax_total":"1.15","display_included_tax_total":"$0.00","display_additional_tax_total":"$1.15","tax_total":"1.15","currency":"USD","display_item_total":"$22.99","total_quantity":1,"display_total":"$25.35","display_ship_total":"$0.00","display_tax_total":"$1.15","token":"IzE88oZwCCOdyx4sI8xizw","checkout_steps":["address","delivery","payment","confirm","complete"]}]} \ No newline at end of file diff --git a/tests/responses/product-2.json b/tests/responses/product-2.json new file mode 100644 index 0000000..e7c6db0 --- /dev/null +++ b/tests/responses/product-2.json @@ -0,0 +1 @@ +{"id":2,"name":"Ruby on Rails Bag","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","price":"22.99","display_price":"$22.99","available_on":"2016-06-27T11:10:17.000Z","slug":"ruby-on-rails-bag","meta_description":null,"meta_keywords":null,"shipping_category_id":1,"taxon_ids":[3,11],"total_on_hand":10,"has_variants":false,"master":{"id":2,"name":"Ruby on Rails Bag","sku":"ROR-00012","price":"22.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"ruby-on-rails-bag","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"21.0","display_price":"$22.99","options_text":"","in_stock":true,"is_backorderable":true,"total_on_hand":10,"is_destroyed":false,"option_values":[],"images":[{"id":23,"position":1,"attachment_content_type":"image/jpeg","attachment_file_name":"ror_bag.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:44.000Z","attachment_width":360,"attachment_height":360,"alt":null,"viewable_type":"Spree::Variant","viewable_id":2,"mini_url":"/spree/products/23/mini/ror_bag.jpeg?1467025844","small_url":"/spree/products/23/small/ror_bag.jpeg?1467025844","product_url":"/spree/products/23/product/ror_bag.jpeg?1467025844","large_url":"/spree/products/23/large/ror_bag.jpeg?1467025844"}]},"variants":[],"option_types":[],"product_properties":[{"id":28,"product_id":2,"property_id":9,"value":"Messenger","property_name":"Type"},{"id":29,"product_id":2,"property_id":10,"value":"14 1/2\" x 12\" x 5\"","property_name":"Size"},{"id":30,"product_id":2,"property_id":11,"value":"600 Denier Polyester","property_name":"Material"}],"classifications":[{"taxon_id":3,"position":2,"taxon":{"id":3,"name":"Bags","pretty_name":"Categories -\u003e Bags","permalink":"categories/bags","parent_id":1,"taxonomy_id":1,"taxons":[]}},{"taxon_id":11,"position":2,"taxon":{"id":11,"name":"Rails","pretty_name":"Brand -\u003e Rails","permalink":"brand/rails","parent_id":2,"taxonomy_id":2,"taxons":[]}}]} \ No newline at end of file diff --git a/tests/responses/product-26.json b/tests/responses/product-26.json new file mode 100644 index 0000000..81089c1 --- /dev/null +++ b/tests/responses/product-26.json @@ -0,0 +1 @@ +{"id":26,"name":"iphone","description":null,"price":"10.0","display_price":"$10.00","available_on":"2016-06-28T19:44:08.000Z","slug":"iphone-f511f3e0-3e46-4705-8043-d3cab0c6e25b","meta_description":null,"meta_keywords":null,"shipping_category_id":2,"taxon_ids":[],"total_on_hand":0,"has_variants":false,"master":{"id":36,"name":"iphone","sku":"","price":"10.0","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"iphone-f511f3e0-3e46-4705-8043-d3cab0c6e25b","description":null,"track_inventory":true,"cost_price":null,"display_price":"$10.00","options_text":"","in_stock":false,"is_backorderable":true,"total_on_hand":0,"is_destroyed":false,"option_values":[],"images":[]},"variants":[],"option_types":[],"product_properties":[],"classifications":[]} \ No newline at end of file diff --git a/tests/responses/products.json b/tests/responses/products.json new file mode 100644 index 0000000..b18c845 --- /dev/null +++ b/tests/responses/products.json @@ -0,0 +1 @@ +{"count":16,"total_count":16,"current_page":1,"per_page":25,"pages":1,"products":[{"id":1,"name":"Ruby on Rails Tote","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","price":"15.99","display_price":"$15.99","available_on":"2016-06-27T11:10:17.000Z","slug":"ruby-on-rails-tote","meta_description":null,"meta_keywords":null,"shipping_category_id":1,"taxon_ids":[3,11],"total_on_hand":10,"has_variants":false,"master":{"id":1,"name":"Ruby on Rails Tote","sku":"ROR-00011","price":"15.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"ruby-on-rails-tote","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"17.0","display_price":"$15.99","options_text":"","in_stock":true,"is_backorderable":true,"total_on_hand":10,"is_destroyed":false,"option_values":[],"images":[{"id":21,"position":1,"attachment_content_type":"image/jpeg","attachment_file_name":"ror_tote.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:43.000Z","attachment_width":360,"attachment_height":360,"alt":null,"viewable_type":"Spree::Variant","viewable_id":1,"mini_url":"/spree/products/21/mini/ror_tote.jpeg?1467025843","small_url":"/spree/products/21/small/ror_tote.jpeg?1467025843","product_url":"/spree/products/21/product/ror_tote.jpeg?1467025843","large_url":"/spree/products/21/large/ror_tote.jpeg?1467025843"},{"id":22,"position":2,"attachment_content_type":"image/jpeg","attachment_file_name":"ror_tote_back.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:44.000Z","attachment_width":360,"attachment_height":360,"alt":null,"viewable_type":"Spree::Variant","viewable_id":1,"mini_url":"/spree/products/22/mini/ror_tote_back.jpeg?1467025844","small_url":"/spree/products/22/small/ror_tote_back.jpeg?1467025844","product_url":"/spree/products/22/product/ror_tote_back.jpeg?1467025844","large_url":"/spree/products/22/large/ror_tote_back.jpeg?1467025844"}]},"variants":[],"option_types":[],"product_properties":[{"id":27,"product_id":1,"property_id":11,"value":"Canvas","property_name":"Material"},{"id":26,"product_id":1,"property_id":10,"value":"15\" x 18\" x 6\"","property_name":"Size"},{"id":25,"product_id":1,"property_id":9,"value":"Tote","property_name":"Type"}],"classifications":[{"taxon_id":3,"position":1,"taxon":{"id":3,"name":"Bags","pretty_name":"Categories -\u003e Bags","permalink":"categories/bags","parent_id":1,"taxonomy_id":1,"taxons":[]}},{"taxon_id":11,"position":1,"taxon":{"id":11,"name":"Rails","pretty_name":"Brand -\u003e Rails","permalink":"brand/rails","parent_id":2,"taxonomy_id":2,"taxons":[]}}]},{"id":2,"name":"Ruby on Rails Bag","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","price":"22.99","display_price":"$22.99","available_on":"2016-06-27T11:10:17.000Z","slug":"ruby-on-rails-bag","meta_description":null,"meta_keywords":null,"shipping_category_id":1,"taxon_ids":[3,11],"total_on_hand":10,"has_variants":false,"master":{"id":2,"name":"Ruby on Rails Bag","sku":"ROR-00012","price":"22.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"ruby-on-rails-bag","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"21.0","display_price":"$22.99","options_text":"","in_stock":true,"is_backorderable":true,"total_on_hand":10,"is_destroyed":false,"option_values":[],"images":[{"id":23,"position":1,"attachment_content_type":"image/jpeg","attachment_file_name":"ror_bag.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:44.000Z","attachment_width":360,"attachment_height":360,"alt":null,"viewable_type":"Spree::Variant","viewable_id":2,"mini_url":"/spree/products/23/mini/ror_bag.jpeg?1467025844","small_url":"/spree/products/23/small/ror_bag.jpeg?1467025844","product_url":"/spree/products/23/product/ror_bag.jpeg?1467025844","large_url":"/spree/products/23/large/ror_bag.jpeg?1467025844"}]},"variants":[],"option_types":[],"product_properties":[{"id":30,"product_id":2,"property_id":11,"value":"600 Denier Polyester","property_name":"Material"},{"id":29,"product_id":2,"property_id":10,"value":"14 1/2\" x 12\" x 5\"","property_name":"Size"},{"id":28,"product_id":2,"property_id":9,"value":"Messenger","property_name":"Type"}],"classifications":[{"taxon_id":3,"position":2,"taxon":{"id":3,"name":"Bags","pretty_name":"Categories -\u003e Bags","permalink":"categories/bags","parent_id":1,"taxonomy_id":1,"taxons":[]}},{"taxon_id":11,"position":2,"taxon":{"id":11,"name":"Rails","pretty_name":"Brand -\u003e Rails","permalink":"brand/rails","parent_id":2,"taxonomy_id":2,"taxons":[]}}]},{"id":3,"name":"Ruby on Rails Baseball Jersey","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","price":"19.99","display_price":"$19.99","available_on":"2016-06-27T11:10:17.000Z","slug":"ruby-on-rails-baseball-jersey","meta_description":null,"meta_keywords":null,"shipping_category_id":1,"taxon_ids":[7,11],"total_on_hand":110,"has_variants":true,"master":{"id":3,"name":"Ruby on Rails Baseball Jersey","sku":"ROR-001","price":"19.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"ruby-on-rails-baseball-jersey","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"17.0","display_price":"$19.99","options_text":"","in_stock":true,"is_backorderable":true,"total_on_hand":10,"is_destroyed":false,"option_values":[],"images":[{"id":24,"position":1,"attachment_content_type":"image/jpeg","attachment_file_name":"ror_baseball.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:45.000Z","attachment_width":360,"attachment_height":360,"alt":null,"viewable_type":"Spree::Variant","viewable_id":3,"mini_url":"/spree/products/24/mini/ror_baseball.jpeg?1467025845","small_url":"/spree/products/24/small/ror_baseball.jpeg?1467025845","product_url":"/spree/products/24/product/ror_baseball.jpeg?1467025845","large_url":"/spree/products/24/large/ror_baseball.jpeg?1467025845"},{"id":25,"position":2,"attachment_content_type":"image/jpeg","attachment_file_name":"ror_baseball_back.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:45.000Z","attachment_width":360,"attachment_height":360,"alt":null,"viewable_type":"Spree::Variant","viewable_id":3,"mini_url":"/spree/products/25/mini/ror_baseball_back.jpeg?1467025845","small_url":"/spree/products/25/small/ror_baseball_back.jpeg?1467025845","product_url":"/spree/products/25/product/ror_baseball_back.jpeg?1467025845","large_url":"/spree/products/25/large/ror_baseball_back.jpeg?1467025845"}]},"variants":[{"id":17,"name":"Ruby on Rails Baseball Jersey","sku":"ROR-00001","price":"19.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":false,"slug":"ruby-on-rails-baseball-jersey","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"17.0","display_price":"$19.99","options_text":"Size: S, Color: Red","in_stock":true,"is_backorderable":true,"total_on_hand":10,"is_destroyed":false,"option_values":[{"id":1,"name":"Small","presentation":"S","option_type_name":"tshirt-size","option_type_id":1,"option_type_presentation":"Size"},{"id":5,"name":"Red","presentation":"Red","option_type_name":"tshirt-color","option_type_id":2,"option_type_presentation":"Color"}],"images":[{"id":1,"position":1,"attachment_content_type":"image/png","attachment_file_name":"ror_baseball_jersey_red.png","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:34.000Z","attachment_width":240,"attachment_height":240,"alt":null,"viewable_type":"Spree::Variant","viewable_id":17,"mini_url":"/spree/products/1/mini/ror_baseball_jersey_red.png?1467025834","small_url":"/spree/products/1/small/ror_baseball_jersey_red.png?1467025834","product_url":"/spree/products/1/product/ror_baseball_jersey_red.png?1467025834","large_url":"/spree/products/1/large/ror_baseball_jersey_red.png?1467025834"},{"id":2,"position":2,"attachment_content_type":"image/png","attachment_file_name":"ror_baseball_jersey_back_red.png","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:34.000Z","attachment_width":240,"attachment_height":240,"alt":null,"viewable_type":"Spree::Variant","viewable_id":17,"mini_url":"/spree/products/2/mini/ror_baseball_jersey_back_red.png?1467025834","small_url":"/spree/products/2/small/ror_baseball_jersey_back_red.png?1467025834","product_url":"/spree/products/2/product/ror_baseball_jersey_back_red.png?1467025834","large_url":"/spree/products/2/large/ror_baseball_jersey_back_red.png?1467025834"}]},{"id":18,"name":"Ruby on Rails Baseball Jersey","sku":"ROR-00002","price":"19.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":false,"slug":"ruby-on-rails-baseball-jersey","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"17.0","display_price":"$19.99","options_text":"Size: S, Color: Blue","in_stock":true,"is_backorderable":true,"total_on_hand":10,"is_destroyed":false,"option_values":[{"id":1,"name":"Small","presentation":"S","option_type_name":"tshirt-size","option_type_id":1,"option_type_presentation":"Size"},{"id":7,"name":"Blue","presentation":"Blue","option_type_name":"tshirt-color","option_type_id":2,"option_type_presentation":"Color"}],"images":[{"id":3,"position":1,"attachment_content_type":"image/png","attachment_file_name":"ror_baseball_jersey_blue.png","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:35.000Z","attachment_width":240,"attachment_height":240,"alt":null,"viewable_type":"Spree::Variant","viewable_id":18,"mini_url":"/spree/products/3/mini/ror_baseball_jersey_blue.png?1467025835","small_url":"/spree/products/3/small/ror_baseball_jersey_blue.png?1467025835","product_url":"/spree/products/3/product/ror_baseball_jersey_blue.png?1467025835","large_url":"/spree/products/3/large/ror_baseball_jersey_blue.png?1467025835"},{"id":4,"position":2,"attachment_content_type":"image/png","attachment_file_name":"ror_baseball_jersey_back_blue.png","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:35.000Z","attachment_width":240,"attachment_height":240,"alt":null,"viewable_type":"Spree::Variant","viewable_id":18,"mini_url":"/spree/products/4/mini/ror_baseball_jersey_back_blue.png?1467025835","small_url":"/spree/products/4/small/ror_baseball_jersey_back_blue.png?1467025835","product_url":"/spree/products/4/product/ror_baseball_jersey_back_blue.png?1467025835","large_url":"/spree/products/4/large/ror_baseball_jersey_back_blue.png?1467025835"}]},{"id":19,"name":"Ruby on Rails Baseball Jersey","sku":"ROR-00003","price":"19.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":false,"slug":"ruby-on-rails-baseball-jersey","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"17.0","display_price":"$19.99","options_text":"Size: S, Color: Green","in_stock":true,"is_backorderable":true,"total_on_hand":10,"is_destroyed":false,"option_values":[{"id":1,"name":"Small","presentation":"S","option_type_name":"tshirt-size","option_type_id":1,"option_type_presentation":"Size"},{"id":6,"name":"Green","presentation":"Green","option_type_name":"tshirt-color","option_type_id":2,"option_type_presentation":"Color"}],"images":[{"id":5,"position":1,"attachment_content_type":"image/png","attachment_file_name":"ror_baseball_jersey_green.png","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:36.000Z","attachment_width":240,"attachment_height":240,"alt":null,"viewable_type":"Spree::Variant","viewable_id":19,"mini_url":"/spree/products/5/mini/ror_baseball_jersey_green.png?1467025836","small_url":"/spree/products/5/small/ror_baseball_jersey_green.png?1467025836","product_url":"/spree/products/5/product/ror_baseball_jersey_green.png?1467025836","large_url":"/spree/products/5/large/ror_baseball_jersey_green.png?1467025836"},{"id":6,"position":2,"attachment_content_type":"image/png","attachment_file_name":"ror_baseball_jersey_back_green.png","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:36.000Z","attachment_width":240,"attachment_height":240,"alt":null,"viewable_type":"Spree::Variant","viewable_id":19,"mini_url":"/spree/products/6/mini/ror_baseball_jersey_back_green.png?1467025836","small_url":"/spree/products/6/small/ror_baseball_jersey_back_green.png?1467025836","product_url":"/spree/products/6/product/ror_baseball_jersey_back_green.png?1467025836","large_url":"/spree/products/6/large/ror_baseball_jersey_back_green.png?1467025836"}]},{"id":20,"name":"Ruby on Rails Baseball Jersey","sku":"ROR-00004","price":"19.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":false,"slug":"ruby-on-rails-baseball-jersey","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"17.0","display_price":"$19.99","options_text":"Size: M, Color: Red","in_stock":true,"is_backorderable":true,"total_on_hand":10,"is_destroyed":false,"option_values":[{"id":2,"name":"Medium","presentation":"M","option_type_name":"tshirt-size","option_type_id":1,"option_type_presentation":"Size"},{"id":5,"name":"Red","presentation":"Red","option_type_name":"tshirt-color","option_type_id":2,"option_type_presentation":"Color"}],"images":[{"id":7,"position":1,"attachment_content_type":"image/png","attachment_file_name":"ror_baseball_jersey_red.png","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:37.000Z","attachment_width":240,"attachment_height":240,"alt":null,"viewable_type":"Spree::Variant","viewable_id":20,"mini_url":"/spree/products/7/mini/ror_baseball_jersey_red.png?1467025837","small_url":"/spree/products/7/small/ror_baseball_jersey_red.png?1467025837","product_url":"/spree/products/7/product/ror_baseball_jersey_red.png?1467025837","large_url":"/spree/products/7/large/ror_baseball_jersey_red.png?1467025837"},{"id":8,"position":2,"attachment_content_type":"image/png","attachment_file_name":"ror_baseball_jersey_back_red.png","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:37.000Z","attachment_width":240,"attachment_height":240,"alt":null,"viewable_type":"Spree::Variant","viewable_id":20,"mini_url":"/spree/products/8/mini/ror_baseball_jersey_back_red.png?1467025837","small_url":"/spree/products/8/small/ror_baseball_jersey_back_red.png?1467025837","product_url":"/spree/products/8/product/ror_baseball_jersey_back_red.png?1467025837","large_url":"/spree/products/8/large/ror_baseball_jersey_back_red.png?1467025837"}]},{"id":21,"name":"Ruby on Rails Baseball Jersey","sku":"ROR-00005","price":"19.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":false,"slug":"ruby-on-rails-baseball-jersey","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"17.0","display_price":"$19.99","options_text":"Size: M, Color: Blue","in_stock":true,"is_backorderable":true,"total_on_hand":10,"is_destroyed":false,"option_values":[{"id":2,"name":"Medium","presentation":"M","option_type_name":"tshirt-size","option_type_id":1,"option_type_presentation":"Size"},{"id":7,"name":"Blue","presentation":"Blue","option_type_name":"tshirt-color","option_type_id":2,"option_type_presentation":"Color"}],"images":[{"id":9,"position":1,"attachment_content_type":"image/png","attachment_file_name":"ror_baseball_jersey_blue.png","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:38.000Z","attachment_width":240,"attachment_height":240,"alt":null,"viewable_type":"Spree::Variant","viewable_id":21,"mini_url":"/spree/products/9/mini/ror_baseball_jersey_blue.png?1467025838","small_url":"/spree/products/9/small/ror_baseball_jersey_blue.png?1467025838","product_url":"/spree/products/9/product/ror_baseball_jersey_blue.png?1467025838","large_url":"/spree/products/9/large/ror_baseball_jersey_blue.png?1467025838"},{"id":10,"position":2,"attachment_content_type":"image/png","attachment_file_name":"ror_baseball_jersey_back_blue.png","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:38.000Z","attachment_width":240,"attachment_height":240,"alt":null,"viewable_type":"Spree::Variant","viewable_id":21,"mini_url":"/spree/products/10/mini/ror_baseball_jersey_back_blue.png?1467025838","small_url":"/spree/products/10/small/ror_baseball_jersey_back_blue.png?1467025838","product_url":"/spree/products/10/product/ror_baseball_jersey_back_blue.png?1467025838","large_url":"/spree/products/10/large/ror_baseball_jersey_back_blue.png?1467025838"}]},{"id":22,"name":"Ruby on Rails Baseball Jersey","sku":"ROR-00006","price":"19.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":false,"slug":"ruby-on-rails-baseball-jersey","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"17.0","display_price":"$19.99","options_text":"Size: M, Color: Green","in_stock":true,"is_backorderable":true,"total_on_hand":10,"is_destroyed":false,"option_values":[{"id":2,"name":"Medium","presentation":"M","option_type_name":"tshirt-size","option_type_id":1,"option_type_presentation":"Size"},{"id":6,"name":"Green","presentation":"Green","option_type_name":"tshirt-color","option_type_id":2,"option_type_presentation":"Color"}],"images":[{"id":11,"position":1,"attachment_content_type":"image/png","attachment_file_name":"ror_baseball_jersey_green.png","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:38.000Z","attachment_width":240,"attachment_height":240,"alt":null,"viewable_type":"Spree::Variant","viewable_id":22,"mini_url":"/spree/products/11/mini/ror_baseball_jersey_green.png?1467025838","small_url":"/spree/products/11/small/ror_baseball_jersey_green.png?1467025838","product_url":"/spree/products/11/product/ror_baseball_jersey_green.png?1467025838","large_url":"/spree/products/11/large/ror_baseball_jersey_green.png?1467025838"},{"id":12,"position":2,"attachment_content_type":"image/png","attachment_file_name":"ror_baseball_jersey_back_green.png","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:39.000Z","attachment_width":240,"attachment_height":240,"alt":null,"viewable_type":"Spree::Variant","viewable_id":22,"mini_url":"/spree/products/12/mini/ror_baseball_jersey_back_green.png?1467025839","small_url":"/spree/products/12/small/ror_baseball_jersey_back_green.png?1467025839","product_url":"/spree/products/12/product/ror_baseball_jersey_back_green.png?1467025839","large_url":"/spree/products/12/large/ror_baseball_jersey_back_green.png?1467025839"}]},{"id":23,"name":"Ruby on Rails Baseball Jersey","sku":"ROR-00007","price":"19.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":false,"slug":"ruby-on-rails-baseball-jersey","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"17.0","display_price":"$19.99","options_text":"Size: L, Color: Red","in_stock":true,"is_backorderable":true,"total_on_hand":10,"is_destroyed":false,"option_values":[{"id":3,"name":"Large","presentation":"L","option_type_name":"tshirt-size","option_type_id":1,"option_type_presentation":"Size"},{"id":5,"name":"Red","presentation":"Red","option_type_name":"tshirt-color","option_type_id":2,"option_type_presentation":"Color"}],"images":[{"id":13,"position":1,"attachment_content_type":"image/png","attachment_file_name":"ror_baseball_jersey_red.png","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:40.000Z","attachment_width":240,"attachment_height":240,"alt":null,"viewable_type":"Spree::Variant","viewable_id":23,"mini_url":"/spree/products/13/mini/ror_baseball_jersey_red.png?1467025840","small_url":"/spree/products/13/small/ror_baseball_jersey_red.png?1467025840","product_url":"/spree/products/13/product/ror_baseball_jersey_red.png?1467025840","large_url":"/spree/products/13/large/ror_baseball_jersey_red.png?1467025840"},{"id":14,"position":2,"attachment_content_type":"image/png","attachment_file_name":"ror_baseball_jersey_back_red.png","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:40.000Z","attachment_width":240,"attachment_height":240,"alt":null,"viewable_type":"Spree::Variant","viewable_id":23,"mini_url":"/spree/products/14/mini/ror_baseball_jersey_back_red.png?1467025840","small_url":"/spree/products/14/small/ror_baseball_jersey_back_red.png?1467025840","product_url":"/spree/products/14/product/ror_baseball_jersey_back_red.png?1467025840","large_url":"/spree/products/14/large/ror_baseball_jersey_back_red.png?1467025840"}]},{"id":24,"name":"Ruby on Rails Baseball Jersey","sku":"ROR-00008","price":"19.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":false,"slug":"ruby-on-rails-baseball-jersey","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"17.0","display_price":"$19.99","options_text":"Size: L, Color: Blue","in_stock":true,"is_backorderable":true,"total_on_hand":10,"is_destroyed":false,"option_values":[{"id":3,"name":"Large","presentation":"L","option_type_name":"tshirt-size","option_type_id":1,"option_type_presentation":"Size"},{"id":7,"name":"Blue","presentation":"Blue","option_type_name":"tshirt-color","option_type_id":2,"option_type_presentation":"Color"}],"images":[{"id":15,"position":1,"attachment_content_type":"image/png","attachment_file_name":"ror_baseball_jersey_blue.png","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:40.000Z","attachment_width":240,"attachment_height":240,"alt":null,"viewable_type":"Spree::Variant","viewable_id":24,"mini_url":"/spree/products/15/mini/ror_baseball_jersey_blue.png?1467025840","small_url":"/spree/products/15/small/ror_baseball_jersey_blue.png?1467025840","product_url":"/spree/products/15/product/ror_baseball_jersey_blue.png?1467025840","large_url":"/spree/products/15/large/ror_baseball_jersey_blue.png?1467025840"},{"id":16,"position":2,"attachment_content_type":"image/png","attachment_file_name":"ror_baseball_jersey_back_blue.png","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:41.000Z","attachment_width":240,"attachment_height":240,"alt":null,"viewable_type":"Spree::Variant","viewable_id":24,"mini_url":"/spree/products/16/mini/ror_baseball_jersey_back_blue.png?1467025841","small_url":"/spree/products/16/small/ror_baseball_jersey_back_blue.png?1467025841","product_url":"/spree/products/16/product/ror_baseball_jersey_back_blue.png?1467025841","large_url":"/spree/products/16/large/ror_baseball_jersey_back_blue.png?1467025841"}]},{"id":25,"name":"Ruby on Rails Baseball Jersey","sku":"ROR-00009","price":"19.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":false,"slug":"ruby-on-rails-baseball-jersey","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"17.0","display_price":"$19.99","options_text":"Size: L, Color: Green","in_stock":true,"is_backorderable":true,"total_on_hand":10,"is_destroyed":false,"option_values":[{"id":3,"name":"Large","presentation":"L","option_type_name":"tshirt-size","option_type_id":1,"option_type_presentation":"Size"},{"id":6,"name":"Green","presentation":"Green","option_type_name":"tshirt-color","option_type_id":2,"option_type_presentation":"Color"}],"images":[{"id":17,"position":1,"attachment_content_type":"image/png","attachment_file_name":"ror_baseball_jersey_green.png","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:41.000Z","attachment_width":240,"attachment_height":240,"alt":null,"viewable_type":"Spree::Variant","viewable_id":25,"mini_url":"/spree/products/17/mini/ror_baseball_jersey_green.png?1467025841","small_url":"/spree/products/17/small/ror_baseball_jersey_green.png?1467025841","product_url":"/spree/products/17/product/ror_baseball_jersey_green.png?1467025841","large_url":"/spree/products/17/large/ror_baseball_jersey_green.png?1467025841"},{"id":18,"position":2,"attachment_content_type":"image/png","attachment_file_name":"ror_baseball_jersey_back_green.png","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:42.000Z","attachment_width":240,"attachment_height":240,"alt":null,"viewable_type":"Spree::Variant","viewable_id":25,"mini_url":"/spree/products/18/mini/ror_baseball_jersey_back_green.png?1467025842","small_url":"/spree/products/18/small/ror_baseball_jersey_back_green.png?1467025842","product_url":"/spree/products/18/product/ror_baseball_jersey_back_green.png?1467025842","large_url":"/spree/products/18/large/ror_baseball_jersey_back_green.png?1467025842"}]},{"id":26,"name":"Ruby on Rails Baseball Jersey","sku":"ROR-00010","price":"19.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":false,"slug":"ruby-on-rails-baseball-jersey","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"17.0","display_price":"$19.99","options_text":"Size: XL, Color: Green","in_stock":true,"is_backorderable":true,"total_on_hand":10,"is_destroyed":false,"option_values":[{"id":4,"name":"Extra Large","presentation":"XL","option_type_name":"tshirt-size","option_type_id":1,"option_type_presentation":"Size"},{"id":6,"name":"Green","presentation":"Green","option_type_name":"tshirt-color","option_type_id":2,"option_type_presentation":"Color"}],"images":[{"id":19,"position":1,"attachment_content_type":"image/png","attachment_file_name":"ror_baseball_jersey_green.png","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:42.000Z","attachment_width":240,"attachment_height":240,"alt":null,"viewable_type":"Spree::Variant","viewable_id":26,"mini_url":"/spree/products/19/mini/ror_baseball_jersey_green.png?1467025842","small_url":"/spree/products/19/small/ror_baseball_jersey_green.png?1467025842","product_url":"/spree/products/19/product/ror_baseball_jersey_green.png?1467025842","large_url":"/spree/products/19/large/ror_baseball_jersey_green.png?1467025842"},{"id":20,"position":2,"attachment_content_type":"image/png","attachment_file_name":"ror_baseball_jersey_back_green.png","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:43.000Z","attachment_width":240,"attachment_height":240,"alt":null,"viewable_type":"Spree::Variant","viewable_id":26,"mini_url":"/spree/products/20/mini/ror_baseball_jersey_back_green.png?1467025843","small_url":"/spree/products/20/small/ror_baseball_jersey_back_green.png?1467025843","product_url":"/spree/products/20/product/ror_baseball_jersey_back_green.png?1467025843","large_url":"/spree/products/20/large/ror_baseball_jersey_back_green.png?1467025843"}]}],"option_types":[{"id":1,"name":"tshirt-size","presentation":"Size","position":1},{"id":2,"name":"tshirt-color","presentation":"Color","position":2}],"product_properties":[{"id":8,"product_id":3,"property_id":8,"value":"Men's","property_name":"Gender"},{"id":7,"product_id":3,"property_id":7,"value":"Loose","property_name":"Fit"},{"id":6,"product_id":3,"property_id":6,"value":"100% cotton","property_name":"Made from"},{"id":5,"product_id":3,"property_id":5,"value":"Long","property_name":"Sleeve Type"},{"id":4,"product_id":3,"property_id":4,"value":"Baseball Jersey","property_name":"Shirt Type"},{"id":3,"product_id":3,"property_id":3,"value":"JK1002","property_name":"Model"},{"id":2,"product_id":3,"property_id":2,"value":"Wannabe Sports","property_name":"Brand"},{"id":1,"product_id":3,"property_id":1,"value":"Wilson","property_name":"Manufacturer"}],"classifications":[{"taxon_id":7,"position":1,"taxon":{"id":7,"name":"T-Shirts","pretty_name":"Categories -\u003e Clothing -\u003e T-Shirts","permalink":"categories/clothing/t-shirts","parent_id":5,"taxonomy_id":1,"taxons":[]}},{"taxon_id":11,"position":5,"taxon":{"id":11,"name":"Rails","pretty_name":"Brand -\u003e Rails","permalink":"brand/rails","parent_id":2,"taxonomy_id":2,"taxons":[]}}]},{"id":4,"name":"Ruby on Rails Jr. Spaghetti","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","price":"19.99","display_price":"$19.99","available_on":"2016-06-27T11:10:17.000Z","slug":"ruby-on-rails-jr-spaghetti","meta_description":null,"meta_keywords":null,"shipping_category_id":1,"taxon_ids":[6,11],"total_on_hand":10,"has_variants":false,"master":{"id":4,"name":"Ruby on Rails Jr. Spaghetti","sku":"ROR-00013","price":"19.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"ruby-on-rails-jr-spaghetti","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"17.0","display_price":"$19.99","options_text":"","in_stock":true,"is_backorderable":true,"total_on_hand":10,"is_destroyed":false,"option_values":[],"images":[{"id":26,"position":1,"attachment_content_type":"image/jpeg","attachment_file_name":"ror_jr_spaghetti.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:46.000Z","attachment_width":360,"attachment_height":360,"alt":null,"viewable_type":"Spree::Variant","viewable_id":4,"mini_url":"/spree/products/26/mini/ror_jr_spaghetti.jpeg?1467025846","small_url":"/spree/products/26/small/ror_jr_spaghetti.jpeg?1467025846","product_url":"/spree/products/26/product/ror_jr_spaghetti.jpeg?1467025846","large_url":"/spree/products/26/large/ror_jr_spaghetti.jpeg?1467025846"}]},"variants":[],"option_types":[],"product_properties":[{"id":15,"product_id":4,"property_id":7,"value":"Form","property_name":"Fit"},{"id":14,"product_id":4,"property_id":6,"value":"90% Cotton, 10% Nylon","property_name":"Made from"},{"id":13,"product_id":4,"property_id":5,"value":"None","property_name":"Sleeve Type"},{"id":12,"product_id":4,"property_id":4,"value":"Jr. Spaghetti T","property_name":"Shirt Type"},{"id":11,"product_id":4,"property_id":3,"value":"TL174","property_name":"Model"},{"id":10,"product_id":4,"property_id":2,"value":"Resiliance","property_name":"Brand"},{"id":9,"product_id":4,"property_id":1,"value":"Jerseys","property_name":"Manufacturer"},{"id":16,"product_id":4,"property_id":8,"value":"Women's","property_name":"Gender"}],"classifications":[{"taxon_id":6,"position":1,"taxon":{"id":6,"name":"Shirts","pretty_name":"Categories -\u003e Clothing -\u003e Shirts","permalink":"categories/clothing/shirts","parent_id":5,"taxonomy_id":1,"taxons":[]}},{"taxon_id":11,"position":6,"taxon":{"id":11,"name":"Rails","pretty_name":"Brand -\u003e Rails","permalink":"brand/rails","parent_id":2,"taxonomy_id":2,"taxons":[]}}]},{"id":5,"name":"Ruby on Rails Ringer T-Shirt","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","price":"19.99","display_price":"$19.99","available_on":"2016-06-27T11:10:17.000Z","slug":"ruby-on-rails-ringer-t-shirt","meta_description":null,"meta_keywords":null,"shipping_category_id":1,"taxon_ids":[7,11],"total_on_hand":10,"has_variants":false,"master":{"id":5,"name":"Ruby on Rails Ringer T-Shirt","sku":"ROR-00015","price":"19.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"ruby-on-rails-ringer-t-shirt","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"17.0","display_price":"$19.99","options_text":"","in_stock":true,"is_backorderable":true,"total_on_hand":10,"is_destroyed":false,"option_values":[],"images":[{"id":29,"position":1,"attachment_content_type":"image/jpeg","attachment_file_name":"ror_ringer.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:47.000Z","attachment_width":360,"attachment_height":360,"alt":null,"viewable_type":"Spree::Variant","viewable_id":5,"mini_url":"/spree/products/29/mini/ror_ringer.jpeg?1467025847","small_url":"/spree/products/29/small/ror_ringer.jpeg?1467025847","product_url":"/spree/products/29/product/ror_ringer.jpeg?1467025847","large_url":"/spree/products/29/large/ror_ringer.jpeg?1467025847"},{"id":30,"position":2,"attachment_content_type":"image/jpeg","attachment_file_name":"ror_ringer_back.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:47.000Z","attachment_width":360,"attachment_height":360,"alt":null,"viewable_type":"Spree::Variant","viewable_id":5,"mini_url":"/spree/products/30/mini/ror_ringer_back.jpeg?1467025847","small_url":"/spree/products/30/small/ror_ringer_back.jpeg?1467025847","product_url":"/spree/products/30/product/ror_ringer_back.jpeg?1467025847","large_url":"/spree/products/30/large/ror_ringer_back.jpeg?1467025847"}]},"variants":[],"option_types":[],"product_properties":[{"id":17,"product_id":5,"property_id":1,"value":"Jerseys","property_name":"Manufacturer"},{"id":18,"product_id":5,"property_id":2,"value":"Conditioned","property_name":"Brand"},{"id":24,"product_id":5,"property_id":8,"value":"Men's","property_name":"Gender"},{"id":23,"product_id":5,"property_id":7,"value":"Loose","property_name":"Fit"},{"id":22,"product_id":5,"property_id":6,"value":"100% Vellum","property_name":"Made from"},{"id":21,"product_id":5,"property_id":5,"value":"Short","property_name":"Sleeve Type"},{"id":20,"product_id":5,"property_id":4,"value":"Ringer T","property_name":"Shirt Type"},{"id":19,"product_id":5,"property_id":3,"value":"TL9002","property_name":"Model"}],"classifications":[{"taxon_id":7,"position":2,"taxon":{"id":7,"name":"T-Shirts","pretty_name":"Categories -\u003e Clothing -\u003e T-Shirts","permalink":"categories/clothing/t-shirts","parent_id":5,"taxonomy_id":1,"taxons":[]}},{"taxon_id":11,"position":7,"taxon":{"id":11,"name":"Rails","pretty_name":"Brand -\u003e Rails","permalink":"brand/rails","parent_id":2,"taxonomy_id":2,"taxons":[]}}]},{"id":6,"name":"Ruby Baseball Jersey","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","price":"19.99","display_price":"$19.99","available_on":"2016-06-27T11:10:17.000Z","slug":"ruby-baseball-jersey","meta_description":null,"meta_keywords":null,"shipping_category_id":1,"taxon_ids":[7,8],"total_on_hand":10,"has_variants":false,"master":{"id":6,"name":"Ruby Baseball Jersey","sku":"RUB-00001","price":"19.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"ruby-baseball-jersey","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"17.0","display_price":"$19.99","options_text":"","in_stock":true,"is_backorderable":true,"total_on_hand":10,"is_destroyed":false,"option_values":[],"images":[{"id":34,"position":1,"attachment_content_type":"image/png","attachment_file_name":"ruby_baseball.png","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:50.000Z","attachment_width":495,"attachment_height":477,"alt":null,"viewable_type":"Spree::Variant","viewable_id":6,"mini_url":"/spree/products/34/mini/ruby_baseball.png?1467025850","small_url":"/spree/products/34/small/ruby_baseball.png?1467025850","product_url":"/spree/products/34/product/ruby_baseball.png?1467025850","large_url":"/spree/products/34/large/ruby_baseball.png?1467025850"}]},"variants":[],"option_types":[],"product_properties":[],"classifications":[{"taxon_id":7,"position":4,"taxon":{"id":7,"name":"T-Shirts","pretty_name":"Categories -\u003e Clothing -\u003e T-Shirts","permalink":"categories/clothing/t-shirts","parent_id":5,"taxonomy_id":1,"taxons":[]}},{"taxon_id":8,"position":1,"taxon":{"id":8,"name":"Ruby","pretty_name":"Brand -\u003e Ruby","permalink":"brand/ruby","parent_id":2,"taxonomy_id":2,"taxons":[]}}]},{"id":7,"name":"Apache Baseball Jersey","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","price":"19.99","display_price":"$19.99","available_on":"2016-06-27T11:10:17.000Z","slug":"apache-baseball-jersey","meta_description":null,"meta_keywords":null,"shipping_category_id":1,"taxon_ids":[7,9],"total_on_hand":10,"has_variants":false,"master":{"id":7,"name":"Apache Baseball Jersey","sku":"APC-00001","price":"19.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"apache-baseball-jersey","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"17.0","display_price":"$19.99","options_text":"","in_stock":true,"is_backorderable":true,"total_on_hand":10,"is_destroyed":false,"option_values":[],"images":[{"id":33,"position":1,"attachment_content_type":"image/png","attachment_file_name":"apache_baseball.png","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:49.000Z","attachment_width":504,"attachment_height":484,"alt":null,"viewable_type":"Spree::Variant","viewable_id":7,"mini_url":"/spree/products/33/mini/apache_baseball.png?1467025849","small_url":"/spree/products/33/small/apache_baseball.png?1467025849","product_url":"/spree/products/33/product/apache_baseball.png?1467025849","large_url":"/spree/products/33/large/apache_baseball.png?1467025849"}]},"variants":[],"option_types":[],"product_properties":[],"classifications":[{"taxon_id":7,"position":3,"taxon":{"id":7,"name":"T-Shirts","pretty_name":"Categories -\u003e Clothing -\u003e T-Shirts","permalink":"categories/clothing/t-shirts","parent_id":5,"taxonomy_id":1,"taxons":[]}},{"taxon_id":9,"position":1,"taxon":{"id":9,"name":"Apache","pretty_name":"Brand -\u003e Apache","permalink":"brand/apache","parent_id":2,"taxonomy_id":2,"taxons":[]}}]},{"id":8,"name":"Spree Baseball Jersey","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","price":"19.99","display_price":"$19.99","available_on":"2016-06-27T11:10:17.000Z","slug":"spree-baseball-jersey","meta_description":null,"meta_keywords":null,"shipping_category_id":1,"taxon_ids":[7,10],"total_on_hand":10,"has_variants":false,"master":{"id":8,"name":"Spree Baseball Jersey","sku":"SPR-00001","price":"19.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"spree-baseball-jersey","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"17.0","display_price":"$19.99","options_text":"","in_stock":true,"is_backorderable":true,"total_on_hand":10,"is_destroyed":false,"option_values":[],"images":[{"id":41,"position":1,"attachment_content_type":"image/jpeg","attachment_file_name":"spree_jersey.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:54.000Z","attachment_width":480,"attachment_height":480,"alt":null,"viewable_type":"Spree::Variant","viewable_id":8,"mini_url":"/spree/products/41/mini/spree_jersey.jpeg?1467025854","small_url":"/spree/products/41/small/spree_jersey.jpeg?1467025854","product_url":"/spree/products/41/product/spree_jersey.jpeg?1467025854","large_url":"/spree/products/41/large/spree_jersey.jpeg?1467025854"},{"id":42,"position":2,"attachment_content_type":"image/jpeg","attachment_file_name":"spree_jersey_back.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:54.000Z","attachment_width":480,"attachment_height":480,"alt":null,"viewable_type":"Spree::Variant","viewable_id":8,"mini_url":"/spree/products/42/mini/spree_jersey_back.jpeg?1467025854","small_url":"/spree/products/42/small/spree_jersey_back.jpeg?1467025854","product_url":"/spree/products/42/product/spree_jersey_back.jpeg?1467025854","large_url":"/spree/products/42/large/spree_jersey_back.jpeg?1467025854"}]},"variants":[],"option_types":[{"id":1,"name":"tshirt-size","presentation":"Size","position":1},{"id":2,"name":"tshirt-color","presentation":"Color","position":2}],"product_properties":[{"id":48,"product_id":8,"property_id":6,"value":"100% cotton","property_name":"Made from"},{"id":47,"product_id":8,"property_id":5,"value":"Long","property_name":"Sleeve Type"},{"id":46,"product_id":8,"property_id":4,"value":"Baseball Jersey","property_name":"Shirt Type"},{"id":45,"product_id":8,"property_id":3,"value":"JK1002","property_name":"Model"},{"id":44,"product_id":8,"property_id":2,"value":"Wannabe Sports","property_name":"Brand"},{"id":43,"product_id":8,"property_id":1,"value":"Wilson","property_name":"Manufacturer"},{"id":49,"product_id":8,"property_id":7,"value":"Loose","property_name":"Fit"},{"id":50,"product_id":8,"property_id":8,"value":"Men's","property_name":"Gender"}],"classifications":[{"taxon_id":7,"position":5,"taxon":{"id":7,"name":"T-Shirts","pretty_name":"Categories -\u003e Clothing -\u003e T-Shirts","permalink":"categories/clothing/t-shirts","parent_id":5,"taxonomy_id":1,"taxons":[]}},{"taxon_id":10,"position":4,"taxon":{"id":10,"name":"Spree","pretty_name":"Brand -\u003e Spree","permalink":"brand/spree","parent_id":2,"taxonomy_id":2,"taxons":[]}}]},{"id":9,"name":"Spree Jr. Spaghetti","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","price":"19.99","display_price":"$19.99","available_on":"2016-06-27T11:10:17.000Z","slug":"spree-jr-spaghetti","meta_description":null,"meta_keywords":null,"shipping_category_id":1,"taxon_ids":[6,10],"total_on_hand":10,"has_variants":false,"master":{"id":9,"name":"Spree Jr. Spaghetti","sku":"SPR-00013","price":"19.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"spree-jr-spaghetti","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"17.0","display_price":"$19.99","options_text":"","in_stock":true,"is_backorderable":true,"total_on_hand":10,"is_destroyed":false,"option_values":[],"images":[{"id":40,"position":1,"attachment_content_type":"image/jpeg","attachment_file_name":"spree_spaghetti.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:53.000Z","attachment_width":480,"attachment_height":480,"alt":null,"viewable_type":"Spree::Variant","viewable_id":9,"mini_url":"/spree/products/40/mini/spree_spaghetti.jpeg?1467025853","small_url":"/spree/products/40/small/spree_spaghetti.jpeg?1467025853","product_url":"/spree/products/40/product/spree_spaghetti.jpeg?1467025853","large_url":"/spree/products/40/large/spree_spaghetti.jpeg?1467025853"}]},"variants":[],"option_types":[],"product_properties":[{"id":51,"product_id":9,"property_id":1,"value":"Jerseys","property_name":"Manufacturer"},{"id":58,"product_id":9,"property_id":8,"value":"Women's","property_name":"Gender"},{"id":57,"product_id":9,"property_id":7,"value":"Form","property_name":"Fit"},{"id":56,"product_id":9,"property_id":6,"value":"90% Cotton, 10% Nylon","property_name":"Made from"},{"id":55,"product_id":9,"property_id":5,"value":"None","property_name":"Sleeve Type"},{"id":54,"product_id":9,"property_id":4,"value":"Jr. Spaghetti T","property_name":"Shirt Type"},{"id":53,"product_id":9,"property_id":3,"value":"TL174","property_name":"Model"},{"id":52,"product_id":9,"property_id":2,"value":"Resiliance","property_name":"Brand"}],"classifications":[{"taxon_id":6,"position":2,"taxon":{"id":6,"name":"Shirts","pretty_name":"Categories -\u003e Clothing -\u003e Shirts","permalink":"categories/clothing/shirts","parent_id":5,"taxonomy_id":1,"taxons":[]}},{"taxon_id":10,"position":7,"taxon":{"id":10,"name":"Spree","pretty_name":"Brand -\u003e Spree","permalink":"brand/spree","parent_id":2,"taxonomy_id":2,"taxons":[]}}]},{"id":10,"name":"Spree Ringer T-Shirt","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","price":"19.99","display_price":"$19.99","available_on":"2016-06-27T11:10:17.000Z","slug":"spree-ringer-t-shirt","meta_description":null,"meta_keywords":null,"shipping_category_id":1,"taxon_ids":[7,10],"total_on_hand":10,"has_variants":false,"master":{"id":10,"name":"Spree Ringer T-Shirt","sku":"SPR-00015","price":"19.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"spree-ringer-t-shirt","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"17.0","display_price":"$19.99","options_text":"","in_stock":true,"is_backorderable":true,"total_on_hand":10,"is_destroyed":false,"option_values":[],"images":[{"id":38,"position":1,"attachment_content_type":"image/jpeg","attachment_file_name":"spree_ringer_t.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:52.000Z","attachment_width":480,"attachment_height":480,"alt":null,"viewable_type":"Spree::Variant","viewable_id":10,"mini_url":"/spree/products/38/mini/spree_ringer_t.jpeg?1467025852","small_url":"/spree/products/38/small/spree_ringer_t.jpeg?1467025852","product_url":"/spree/products/38/product/spree_ringer_t.jpeg?1467025852","large_url":"/spree/products/38/large/spree_ringer_t.jpeg?1467025852"},{"id":39,"position":2,"attachment_content_type":"image/jpeg","attachment_file_name":"spree_ringer_t_back.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:53.000Z","attachment_width":480,"attachment_height":480,"alt":null,"viewable_type":"Spree::Variant","viewable_id":10,"mini_url":"/spree/products/39/mini/spree_ringer_t_back.jpeg?1467025853","small_url":"/spree/products/39/small/spree_ringer_t_back.jpeg?1467025853","product_url":"/spree/products/39/product/spree_ringer_t_back.jpeg?1467025853","large_url":"/spree/products/39/large/spree_ringer_t_back.jpeg?1467025853"}]},"variants":[],"option_types":[],"product_properties":[{"id":66,"product_id":10,"property_id":8,"value":"Men's","property_name":"Gender"},{"id":65,"product_id":10,"property_id":7,"value":"Loose","property_name":"Fit"},{"id":64,"product_id":10,"property_id":6,"value":"100% Vellum","property_name":"Made from"},{"id":63,"product_id":10,"property_id":5,"value":"Short","property_name":"Sleeve Type"},{"id":62,"product_id":10,"property_id":4,"value":"Ringer T","property_name":"Shirt Type"},{"id":61,"product_id":10,"property_id":3,"value":"TL9002","property_name":"Model"},{"id":60,"product_id":10,"property_id":2,"value":"Conditioned","property_name":"Brand"},{"id":59,"product_id":10,"property_id":1,"value":"Jerseys","property_name":"Manufacturer"}],"classifications":[{"taxon_id":7,"position":6,"taxon":{"id":7,"name":"T-Shirts","pretty_name":"Categories -\u003e Clothing -\u003e T-Shirts","permalink":"categories/clothing/t-shirts","parent_id":5,"taxonomy_id":1,"taxons":[]}},{"taxon_id":10,"position":3,"taxon":{"id":10,"name":"Spree","pretty_name":"Brand -\u003e Spree","permalink":"brand/spree","parent_id":2,"taxonomy_id":2,"taxons":[]}}]},{"id":11,"name":"Spree Tote","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","price":"15.99","display_price":"$15.99","available_on":"2016-06-27T11:10:17.000Z","slug":"spree-tote","meta_description":null,"meta_keywords":null,"shipping_category_id":1,"taxon_ids":[3,10],"total_on_hand":10,"has_variants":false,"master":{"id":11,"name":"Spree Tote","sku":"SPR-00011","price":"15.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"spree-tote","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"13.0","display_price":"$15.99","options_text":"","in_stock":true,"is_backorderable":true,"total_on_hand":10,"is_destroyed":false,"option_values":[],"images":[{"id":36,"position":1,"attachment_content_type":"image/jpeg","attachment_file_name":"spree_tote_front.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:51.000Z","attachment_width":480,"attachment_height":480,"alt":null,"viewable_type":"Spree::Variant","viewable_id":11,"mini_url":"/spree/products/36/mini/spree_tote_front.jpeg?1467025851","small_url":"/spree/products/36/small/spree_tote_front.jpeg?1467025851","product_url":"/spree/products/36/product/spree_tote_front.jpeg?1467025851","large_url":"/spree/products/36/large/spree_tote_front.jpeg?1467025851"},{"id":37,"position":2,"attachment_content_type":"image/jpeg","attachment_file_name":"spree_tote_back.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:52.000Z","attachment_width":480,"attachment_height":480,"alt":null,"viewable_type":"Spree::Variant","viewable_id":11,"mini_url":"/spree/products/37/mini/spree_tote_back.jpeg?1467025852","small_url":"/spree/products/37/small/spree_tote_back.jpeg?1467025852","product_url":"/spree/products/37/product/spree_tote_back.jpeg?1467025852","large_url":"/spree/products/37/large/spree_tote_back.jpeg?1467025852"}]},"variants":[],"option_types":[],"product_properties":[{"id":40,"product_id":11,"property_id":10,"value":"15\" x 18\" x 6\"","property_name":"Size"},{"id":39,"product_id":11,"property_id":9,"value":"Tote","property_name":"Type"}],"classifications":[{"taxon_id":3,"position":3,"taxon":{"id":3,"name":"Bags","pretty_name":"Categories -\u003e Bags","permalink":"categories/bags","parent_id":1,"taxonomy_id":1,"taxons":[]}},{"taxon_id":10,"position":5,"taxon":{"id":10,"name":"Spree","pretty_name":"Brand -\u003e Spree","permalink":"brand/spree","parent_id":2,"taxonomy_id":2,"taxons":[]}}]},{"id":12,"name":"Spree Bag","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","price":"22.99","display_price":"$22.99","available_on":"2016-06-27T11:10:17.000Z","slug":"spree-bag","meta_description":null,"meta_keywords":null,"shipping_category_id":1,"taxon_ids":[3,10],"total_on_hand":10,"has_variants":false,"master":{"id":12,"name":"Spree Bag","sku":"SPR-00012","price":"22.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"spree-bag","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"21.0","display_price":"$22.99","options_text":"","in_stock":true,"is_backorderable":true,"total_on_hand":10,"is_destroyed":false,"option_values":[],"images":[{"id":35,"position":1,"attachment_content_type":"image/jpeg","attachment_file_name":"spree_bag.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:50.000Z","attachment_width":480,"attachment_height":480,"alt":null,"viewable_type":"Spree::Variant","viewable_id":12,"mini_url":"/spree/products/35/mini/spree_bag.jpeg?1467025850","small_url":"/spree/products/35/small/spree_bag.jpeg?1467025850","product_url":"/spree/products/35/product/spree_bag.jpeg?1467025850","large_url":"/spree/products/35/large/spree_bag.jpeg?1467025850"}]},"variants":[],"option_types":[],"product_properties":[{"id":42,"product_id":12,"property_id":10,"value":"14 1/2\" x 12\" x 5\"","property_name":"Size"},{"id":41,"product_id":12,"property_id":9,"value":"Messenger","property_name":"Type"}],"classifications":[{"taxon_id":3,"position":4,"taxon":{"id":3,"name":"Bags","pretty_name":"Categories -\u003e Bags","permalink":"categories/bags","parent_id":1,"taxonomy_id":1,"taxons":[]}},{"taxon_id":10,"position":6,"taxon":{"id":10,"name":"Spree","pretty_name":"Brand -\u003e Spree","permalink":"brand/spree","parent_id":2,"taxonomy_id":2,"taxons":[]}}]},{"id":13,"name":"Ruby on Rails Mug","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","price":"13.99","display_price":"$13.99","available_on":"2016-06-27T11:10:17.000Z","slug":"ruby-on-rails-mug","meta_description":null,"meta_keywords":null,"shipping_category_id":1,"taxon_ids":[4,11],"total_on_hand":10,"has_variants":false,"master":{"id":13,"name":"Ruby on Rails Mug","sku":"ROR-00014","price":"13.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"ruby-on-rails-mug","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"11.0","display_price":"$13.99","options_text":"","in_stock":true,"is_backorderable":true,"total_on_hand":10,"is_destroyed":false,"option_values":[],"images":[{"id":27,"position":1,"attachment_content_type":"image/jpeg","attachment_file_name":"ror_mug.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:46.000Z","attachment_width":360,"attachment_height":360,"alt":null,"viewable_type":"Spree::Variant","viewable_id":13,"mini_url":"/spree/products/27/mini/ror_mug.jpeg?1467025846","small_url":"/spree/products/27/small/ror_mug.jpeg?1467025846","product_url":"/spree/products/27/product/ror_mug.jpeg?1467025846","large_url":"/spree/products/27/large/ror_mug.jpeg?1467025846"},{"id":28,"position":2,"attachment_content_type":"image/jpeg","attachment_file_name":"ror_mug_back.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:47.000Z","attachment_width":360,"attachment_height":360,"alt":null,"viewable_type":"Spree::Variant","viewable_id":13,"mini_url":"/spree/products/28/mini/ror_mug_back.jpeg?1467025847","small_url":"/spree/products/28/small/ror_mug_back.jpeg?1467025847","product_url":"/spree/products/28/product/ror_mug_back.jpeg?1467025847","large_url":"/spree/products/28/large/ror_mug_back.jpeg?1467025847"}]},"variants":[],"option_types":[],"product_properties":[{"id":32,"product_id":13,"property_id":10,"value":"4.5\" tall, 3.25\" dia.","property_name":"Size"},{"id":31,"product_id":13,"property_id":9,"value":"Mug","property_name":"Type"}],"classifications":[{"taxon_id":4,"position":1,"taxon":{"id":4,"name":"Mugs","pretty_name":"Categories -\u003e Mugs","permalink":"categories/mugs","parent_id":1,"taxonomy_id":1,"taxons":[]}},{"taxon_id":11,"position":3,"taxon":{"id":11,"name":"Rails","pretty_name":"Brand -\u003e Rails","permalink":"brand/rails","parent_id":2,"taxonomy_id":2,"taxons":[]}}]},{"id":14,"name":"Ruby on Rails Stein","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","price":"16.99","display_price":"$16.99","available_on":"2016-06-27T11:10:17.000Z","slug":"ruby-on-rails-stein","meta_description":null,"meta_keywords":null,"shipping_category_id":1,"taxon_ids":[4,11],"total_on_hand":10,"has_variants":false,"master":{"id":14,"name":"Ruby on Rails Stein","sku":"ROR-00016","price":"16.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"ruby-on-rails-stein","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"15.0","display_price":"$16.99","options_text":"","in_stock":true,"is_backorderable":true,"total_on_hand":10,"is_destroyed":false,"option_values":[],"images":[{"id":31,"position":1,"attachment_content_type":"image/jpeg","attachment_file_name":"ror_stein.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:48.000Z","attachment_width":360,"attachment_height":360,"alt":null,"viewable_type":"Spree::Variant","viewable_id":14,"mini_url":"/spree/products/31/mini/ror_stein.jpeg?1467025848","small_url":"/spree/products/31/small/ror_stein.jpeg?1467025848","product_url":"/spree/products/31/product/ror_stein.jpeg?1467025848","large_url":"/spree/products/31/large/ror_stein.jpeg?1467025848"},{"id":32,"position":2,"attachment_content_type":"image/jpeg","attachment_file_name":"ror_stein_back.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:48.000Z","attachment_width":360,"attachment_height":360,"alt":null,"viewable_type":"Spree::Variant","viewable_id":14,"mini_url":"/spree/products/32/mini/ror_stein_back.jpeg?1467025848","small_url":"/spree/products/32/small/ror_stein_back.jpeg?1467025848","product_url":"/spree/products/32/product/ror_stein_back.jpeg?1467025848","large_url":"/spree/products/32/large/ror_stein_back.jpeg?1467025848"}]},"variants":[],"option_types":[],"product_properties":[{"id":34,"product_id":14,"property_id":10,"value":"6.75\" tall, 3.75\" dia. base, 3\" dia. rim","property_name":"Size"},{"id":33,"product_id":14,"property_id":9,"value":"Stein","property_name":"Type"}],"classifications":[{"taxon_id":4,"position":2,"taxon":{"id":4,"name":"Mugs","pretty_name":"Categories -\u003e Mugs","permalink":"categories/mugs","parent_id":1,"taxonomy_id":1,"taxons":[]}},{"taxon_id":11,"position":4,"taxon":{"id":11,"name":"Rails","pretty_name":"Brand -\u003e Rails","permalink":"brand/rails","parent_id":2,"taxonomy_id":2,"taxons":[]}}]},{"id":15,"name":"Spree Stein","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","price":"16.99","display_price":"$16.99","available_on":"2016-06-27T11:10:17.000Z","slug":"spree-stein","meta_description":null,"meta_keywords":null,"shipping_category_id":1,"taxon_ids":[4,10],"total_on_hand":10,"has_variants":false,"master":{"id":15,"name":"Spree Stein","sku":"SPR-00016","price":"16.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"spree-stein","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"15.0","display_price":"$16.99","options_text":"","in_stock":true,"is_backorderable":true,"total_on_hand":10,"is_destroyed":false,"option_values":[],"images":[{"id":43,"position":1,"attachment_content_type":"image/jpeg","attachment_file_name":"spree_stein.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:55.000Z","attachment_width":480,"attachment_height":480,"alt":null,"viewable_type":"Spree::Variant","viewable_id":15,"mini_url":"/spree/products/43/mini/spree_stein.jpeg?1467025855","small_url":"/spree/products/43/small/spree_stein.jpeg?1467025855","product_url":"/spree/products/43/product/spree_stein.jpeg?1467025855","large_url":"/spree/products/43/large/spree_stein.jpeg?1467025855"},{"id":44,"position":2,"attachment_content_type":"image/jpeg","attachment_file_name":"spree_stein_back.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:55.000Z","attachment_width":480,"attachment_height":480,"alt":null,"viewable_type":"Spree::Variant","viewable_id":15,"mini_url":"/spree/products/44/mini/spree_stein_back.jpeg?1467025855","small_url":"/spree/products/44/small/spree_stein_back.jpeg?1467025855","product_url":"/spree/products/44/product/spree_stein_back.jpeg?1467025855","large_url":"/spree/products/44/large/spree_stein_back.jpeg?1467025855"}]},"variants":[],"option_types":[],"product_properties":[{"id":36,"product_id":15,"property_id":10,"value":"6.75\" tall, 3.75\" dia. base, 3\" dia. rim","property_name":"Size"},{"id":35,"product_id":15,"property_id":9,"value":"Stein","property_name":"Type"}],"classifications":[{"taxon_id":4,"position":3,"taxon":{"id":4,"name":"Mugs","pretty_name":"Categories -\u003e Mugs","permalink":"categories/mugs","parent_id":1,"taxonomy_id":1,"taxons":[]}},{"taxon_id":10,"position":1,"taxon":{"id":10,"name":"Spree","pretty_name":"Brand -\u003e Spree","permalink":"brand/spree","parent_id":2,"taxonomy_id":2,"taxons":[]}}]},{"id":16,"name":"Spree Mug","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","price":"13.99","display_price":"$13.99","available_on":"2016-06-27T11:10:17.000Z","slug":"spree-mug","meta_description":null,"meta_keywords":null,"shipping_category_id":1,"taxon_ids":[4,10],"total_on_hand":10,"has_variants":false,"master":{"id":16,"name":"Spree Mug","sku":"SPR-00014","price":"13.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"spree-mug","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"11.0","display_price":"$13.99","options_text":"","in_stock":true,"is_backorderable":true,"total_on_hand":10,"is_destroyed":false,"option_values":[],"images":[{"id":45,"position":1,"attachment_content_type":"image/jpeg","attachment_file_name":"spree_mug.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:55.000Z","attachment_width":240,"attachment_height":240,"alt":null,"viewable_type":"Spree::Variant","viewable_id":16,"mini_url":"/spree/products/45/mini/spree_mug.jpeg?1467025855","small_url":"/spree/products/45/small/spree_mug.jpeg?1467025855","product_url":"/spree/products/45/product/spree_mug.jpeg?1467025855","large_url":"/spree/products/45/large/spree_mug.jpeg?1467025855"},{"id":46,"position":2,"attachment_content_type":"image/jpeg","attachment_file_name":"spree_mug_back.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:56.000Z","attachment_width":240,"attachment_height":240,"alt":null,"viewable_type":"Spree::Variant","viewable_id":16,"mini_url":"/spree/products/46/mini/spree_mug_back.jpeg?1467025856","small_url":"/spree/products/46/small/spree_mug_back.jpeg?1467025856","product_url":"/spree/products/46/product/spree_mug_back.jpeg?1467025856","large_url":"/spree/products/46/large/spree_mug_back.jpeg?1467025856"}]},"variants":[],"option_types":[],"product_properties":[{"id":38,"product_id":16,"property_id":10,"value":"4.5\" tall, 3.25\" dia.","property_name":"Size"},{"id":37,"product_id":16,"property_id":9,"value":"Mug","property_name":"Type"}],"classifications":[{"taxon_id":4,"position":4,"taxon":{"id":4,"name":"Mugs","pretty_name":"Categories -\u003e Mugs","permalink":"categories/mugs","parent_id":1,"taxonomy_id":1,"taxons":[]}},{"taxon_id":10,"position":2,"taxon":{"id":10,"name":"Spree","pretty_name":"Brand -\u003e Spree","permalink":"brand/spree","parent_id":2,"taxonomy_id":2,"taxons":[]}}]}]} \ No newline at end of file diff --git a/tests/test_pagination.py b/tests/test_pagination.py new file mode 100644 index 0000000..23df009 --- /dev/null +++ b/tests/test_pagination.py @@ -0,0 +1,7 @@ +import pytest +from spree.spree import Pagination + + +@pytest.fixture +def page(): + return Pagination() diff --git a/tests/test_spree.py b/tests/test_spree.py index 008bb0e..b547f18 100644 --- a/tests/test_spree.py +++ b/tests/test_spree.py @@ -11,19 +11,58 @@ import pytest # noqa -from spree import spree +def test_products_all(resp, spree): + "test fetching all products" + products = spree.product.all() + assert products.count == 16 + test_product = products[0]['products'][1] + assert test_product['name'] == 'Ruby on Rails Bag' + assert test_product['master']['sku'] == 'ROR-00012' + assert test_product['description'] == 'Et illo et' \ + ' voluptatum corporis. Fugiat atque optio voluptates' \ + ' placeat ut odio. Iusto totam molestiae tenetur eaque' \ + ' molestias. Occaecati sunt sit magni voluptatibus qui ipsum.' + assert test_product['price'] == '22.99' + assert test_product['display_price'] == '$22.99' + assert test_product['available_on'] == '2016-06-27T11:10:17.000Z' + assert test_product['slug'] == 'ruby-on-rails-bag' + assert test_product['shipping_category_id'] == 1 -class TestSpree(object): +def test_finding_one_product(resp, spree): + "test fetching product with respect to id" + test_product = spree.product.find(2) + assert test_product['name'] == 'Ruby on Rails Bag' + assert test_product['master']['sku'] == 'ROR-00012' + assert test_product['description'] == 'Et illo et' \ + ' voluptatum corporis. Fugiat atque optio voluptates' \ + ' placeat ut odio. Iusto totam molestiae tenetur eaque' \ + ' molestias. Occaecati sunt sit magni voluptatibus qui ipsum.' + assert test_product['price'] == '22.99' + assert test_product['display_price'] == '$22.99' + assert test_product['available_on'] == '2016-06-27T11:10:17.000Z' + assert test_product['slug'] == 'ruby-on-rails-bag' + assert test_product['shipping_category_id'] == 1 - @classmethod - def setup_class(cls): - spree - pass - def test_something(self): - pass +def test_orders_all(resp, spree): + "test fetching all orders" + test_orders = spree.orders.all() + test_order = test_orders[0]['orders'][0] + assert test_order['number'] == 'R123456789' + assert test_order['item_total'] == '15.99' + assert test_order['state'] == 'complete' + assert test_order['shipment_state'] == 'pending' + assert test_order['payment_total'] == '0.0' + assert test_order['token'] == 'aAoojFjB1_PCBeLR1VPnIg' - @classmethod - def teardown_class(cls): - pass + +def test_finding_one_order(resp, spree): + "test fetching order with respect to order_id" + test_order = spree.orders.find('R123456789') + assert test_order['number'] == 'R123456789' + assert test_order['item_total'] == '15.99' + assert test_order['state'] == 'complete' + assert test_order['shipment_state'] == 'pending' + assert test_order['payment_total'] == '0.0' + assert test_order['token'] == 'aAoojFjB1_PCBeLR1VPnIg' From af07e85a9b2ef9bc4fd828be4925743dc83763d0 Mon Sep 17 00:00:00 2001 From: Joe Paul Date: Thu, 30 Jun 2016 16:52:38 +0530 Subject: [PATCH 3/6] Provision for updating stock items --- setup.py | 1 - spree/spree.py | 60 ++++++++++++++++++++++++++----- tests/conftest.py | 12 +++++++ tests/responses/stock_item-4.json | 1 + tests/responses/stock_items.json | 1 + tests/test_spree.py | 21 +++++++++-- 6 files changed, 84 insertions(+), 12 deletions(-) create mode 100644 tests/responses/stock_item-4.json create mode 100644 tests/responses/stock_items.json diff --git a/setup.py b/setup.py index 5d22907..4705330 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,6 @@ history = history_file.read() requirements = [ - 'pyactiveresource', ] test_requirements = [ diff --git a/spree/spree.py b/spree/spree.py index fb46833..2f05764 100644 --- a/spree/spree.py +++ b/spree/spree.py @@ -15,12 +15,12 @@ def product(self): return Product(connection=self) @property - def orders(self): - return Orders(connection=self) + def order(self): + return Order(connection=self) @property - def stock_items(self): - return StockItems(connection=self) + def stock_item(self): + return StockItem(connection=self) class Pagination(object): @@ -62,7 +62,7 @@ def load_payload(self, data): def all(self): return Pagination( self.connection.session.get(self.url).json(), - self.path[1:] + self.item_attribute ) def find(self, id): @@ -89,7 +89,12 @@ def delete(self, id): class Product(Resource): + """ + A product Resource class + """ + path = '/products' + item_attribute = 'products' def load_payload(self, data): payload = { @@ -126,10 +131,47 @@ def load_payload(self, data): return super(Product, self).load_payload(payload) -class Orders(Resource): +class Order(Resource): + """ + An order Resource class + """ + path = '/orders' + item_attribute = 'orders' -class StockItems(Resource): - # TODO - path = '/stock_locations' +class StockItem(Resource): + """ + A stock item Resource class + """ + + path = '/stock_locations' + '/%d' + item_attribute = 'stock_items' + + def append_path(self, stk_loc_id): + return self.path % stk_loc_id + '/stock_items' + + def load_payload(self, data): + payload = {} + if 'count_on_hand' in data: + payload['stock_item[count_on_hand]'] = \ + data['count_on_hand'] + if 'force' in data: + payload['stock_item[force]'] = data['force'] + return super(StockItem, self).load_payload(payload) + + def all(self, stk_loc_id): + self.path = self.append_path(stk_loc_id) + return super(StockItem, self).all() + + def find(self, stk_loc_id, stk_id): + self.path = self.append_path(stk_loc_id) + return super(StockItem, self).find(stk_id) + + def update(self, stk_loc_id, stk_id, data): + self.path = self.append_path(stk_loc_id) + return super(StockItem, self).update(stk_id, data) + + def delete(self, stk_loc_id, stk_id): + self.path = self.append_path(stk_loc_id) + return super(StockItem, self).delete(stk_id) diff --git a/tests/conftest.py b/tests/conftest.py index ae86a0a..334c612 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -51,6 +51,18 @@ def resp(fp): body=open(fp('responses/order-R123456789.json'), 'r').read() ) + "StockItems" + rsps.add( + responses.GET, + 'http://mystore/api/stock_locations/1/stock_items', + body=open(fp('responses/stock_items.json'), 'r').read() + ) + rsps.add( + responses.GET, + 'http://mystore/api/stock_locations/1/stock_items/4', + body=open(fp('responses/stock_item-4.json'), 'r').read() + ) + yield rsps rsps.stop() diff --git a/tests/responses/stock_item-4.json b/tests/responses/stock_item-4.json new file mode 100644 index 0000000..72844f5 --- /dev/null +++ b/tests/responses/stock_item-4.json @@ -0,0 +1 @@ +{"id":4,"count_on_hand":10,"backorderable":true,"stock_location_id":1,"variant_id":4,"variant":{"id":4,"name":"Ruby on Rails Jr. Spaghetti","sku":"ROR-00013","price":"19.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"ruby-on-rails-jr-spaghetti","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"17.0","display_price":"$19.99","options_text":"","in_stock":true,"is_backorderable":true,"total_on_hand":10,"is_destroyed":false,"option_values":[],"images":[{"id":26,"position":1,"attachment_content_type":"image/jpeg","attachment_file_name":"ror_jr_spaghetti.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:46.000Z","attachment_width":360,"attachment_height":360,"alt":null,"viewable_type":"Spree::Variant","viewable_id":4,"mini_url":"/spree/products/26/mini/ror_jr_spaghetti.jpeg?1467025846","small_url":"/spree/products/26/small/ror_jr_spaghetti.jpeg?1467025846","product_url":"/spree/products/26/product/ror_jr_spaghetti.jpeg?1467025846","large_url":"/spree/products/26/large/ror_jr_spaghetti.jpeg?1467025846"}]}} \ No newline at end of file diff --git a/tests/responses/stock_items.json b/tests/responses/stock_items.json new file mode 100644 index 0000000..bb0b277 --- /dev/null +++ b/tests/responses/stock_items.json @@ -0,0 +1 @@ +{"count":25,"current_page":1,"pages":2,"stock_items":[{"id":4,"count_on_hand":10,"backorderable":true,"stock_location_id":1,"variant_id":4,"variant":{"id":4,"name":"Ruby on Rails Jr. Spaghetti","sku":"ROR-00013","price":"19.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"ruby-on-rails-jr-spaghetti","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"17.0","display_price":"$19.99","options_text":"","in_stock":true,"is_backorderable":true,"total_on_hand":10,"is_destroyed":false,"option_values":[],"images":[{"id":26,"position":1,"attachment_content_type":"image/jpeg","attachment_file_name":"ror_jr_spaghetti.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:46.000Z","attachment_width":360,"attachment_height":360,"alt":null,"viewable_type":"Spree::Variant","viewable_id":4,"mini_url":"/spree/products/26/mini/ror_jr_spaghetti.jpeg?1467025846","small_url":"/spree/products/26/small/ror_jr_spaghetti.jpeg?1467025846","product_url":"/spree/products/26/product/ror_jr_spaghetti.jpeg?1467025846","large_url":"/spree/products/26/large/ror_jr_spaghetti.jpeg?1467025846"}]}},{"id":5,"count_on_hand":10,"backorderable":true,"stock_location_id":1,"variant_id":5,"variant":{"id":5,"name":"Ruby on Rails Ringer T-Shirt","sku":"ROR-00015","price":"19.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"ruby-on-rails-ringer-t-shirt","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"17.0","display_price":"$19.99","options_text":"","in_stock":true,"is_backorderable":true,"total_on_hand":10,"is_destroyed":false,"option_values":[],"images":[{"id":29,"position":1,"attachment_content_type":"image/jpeg","attachment_file_name":"ror_ringer.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:47.000Z","attachment_width":360,"attachment_height":360,"alt":null,"viewable_type":"Spree::Variant","viewable_id":5,"mini_url":"/spree/products/29/mini/ror_ringer.jpeg?1467025847","small_url":"/spree/products/29/small/ror_ringer.jpeg?1467025847","product_url":"/spree/products/29/product/ror_ringer.jpeg?1467025847","large_url":"/spree/products/29/large/ror_ringer.jpeg?1467025847"},{"id":30,"position":2,"attachment_content_type":"image/jpeg","attachment_file_name":"ror_ringer_back.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:47.000Z","attachment_width":360,"attachment_height":360,"alt":null,"viewable_type":"Spree::Variant","viewable_id":5,"mini_url":"/spree/products/30/mini/ror_ringer_back.jpeg?1467025847","small_url":"/spree/products/30/small/ror_ringer_back.jpeg?1467025847","product_url":"/spree/products/30/product/ror_ringer_back.jpeg?1467025847","large_url":"/spree/products/30/large/ror_ringer_back.jpeg?1467025847"}]}},{"id":6,"count_on_hand":10,"backorderable":true,"stock_location_id":1,"variant_id":6,"variant":{"id":6,"name":"Ruby Baseball Jersey","sku":"RUB-00001","price":"19.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"ruby-baseball-jersey","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"17.0","display_price":"$19.99","options_text":"","in_stock":true,"is_backorderable":true,"total_on_hand":10,"is_destroyed":false,"option_values":[],"images":[{"id":34,"position":1,"attachment_content_type":"image/png","attachment_file_name":"ruby_baseball.png","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:50.000Z","attachment_width":495,"attachment_height":477,"alt":null,"viewable_type":"Spree::Variant","viewable_id":6,"mini_url":"/spree/products/34/mini/ruby_baseball.png?1467025850","small_url":"/spree/products/34/small/ruby_baseball.png?1467025850","product_url":"/spree/products/34/product/ruby_baseball.png?1467025850","large_url":"/spree/products/34/large/ruby_baseball.png?1467025850"}]}},{"id":7,"count_on_hand":10,"backorderable":true,"stock_location_id":1,"variant_id":7,"variant":{"id":7,"name":"Apache Baseball Jersey","sku":"APC-00001","price":"19.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"apache-baseball-jersey","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"17.0","display_price":"$19.99","options_text":"","in_stock":true,"is_backorderable":true,"total_on_hand":10,"is_destroyed":false,"option_values":[],"images":[{"id":33,"position":1,"attachment_content_type":"image/png","attachment_file_name":"apache_baseball.png","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:49.000Z","attachment_width":504,"attachment_height":484,"alt":null,"viewable_type":"Spree::Variant","viewable_id":7,"mini_url":"/spree/products/33/mini/apache_baseball.png?1467025849","small_url":"/spree/products/33/small/apache_baseball.png?1467025849","product_url":"/spree/products/33/product/apache_baseball.png?1467025849","large_url":"/spree/products/33/large/apache_baseball.png?1467025849"}]}},{"id":8,"count_on_hand":10,"backorderable":true,"stock_location_id":1,"variant_id":8,"variant":{"id":8,"name":"Spree Baseball Jersey","sku":"SPR-00001","price":"19.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"spree-baseball-jersey","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"17.0","display_price":"$19.99","options_text":"","in_stock":true,"is_backorderable":true,"total_on_hand":10,"is_destroyed":false,"option_values":[],"images":[{"id":41,"position":1,"attachment_content_type":"image/jpeg","attachment_file_name":"spree_jersey.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:54.000Z","attachment_width":480,"attachment_height":480,"alt":null,"viewable_type":"Spree::Variant","viewable_id":8,"mini_url":"/spree/products/41/mini/spree_jersey.jpeg?1467025854","small_url":"/spree/products/41/small/spree_jersey.jpeg?1467025854","product_url":"/spree/products/41/product/spree_jersey.jpeg?1467025854","large_url":"/spree/products/41/large/spree_jersey.jpeg?1467025854"},{"id":42,"position":2,"attachment_content_type":"image/jpeg","attachment_file_name":"spree_jersey_back.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:54.000Z","attachment_width":480,"attachment_height":480,"alt":null,"viewable_type":"Spree::Variant","viewable_id":8,"mini_url":"/spree/products/42/mini/spree_jersey_back.jpeg?1467025854","small_url":"/spree/products/42/small/spree_jersey_back.jpeg?1467025854","product_url":"/spree/products/42/product/spree_jersey_back.jpeg?1467025854","large_url":"/spree/products/42/large/spree_jersey_back.jpeg?1467025854"}]}},{"id":9,"count_on_hand":10,"backorderable":true,"stock_location_id":1,"variant_id":9,"variant":{"id":9,"name":"Spree Jr. Spaghetti","sku":"SPR-00013","price":"19.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"spree-jr-spaghetti","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"17.0","display_price":"$19.99","options_text":"","in_stock":true,"is_backorderable":true,"total_on_hand":10,"is_destroyed":false,"option_values":[],"images":[{"id":40,"position":1,"attachment_content_type":"image/jpeg","attachment_file_name":"spree_spaghetti.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:53.000Z","attachment_width":480,"attachment_height":480,"alt":null,"viewable_type":"Spree::Variant","viewable_id":9,"mini_url":"/spree/products/40/mini/spree_spaghetti.jpeg?1467025853","small_url":"/spree/products/40/small/spree_spaghetti.jpeg?1467025853","product_url":"/spree/products/40/product/spree_spaghetti.jpeg?1467025853","large_url":"/spree/products/40/large/spree_spaghetti.jpeg?1467025853"}]}},{"id":10,"count_on_hand":10,"backorderable":true,"stock_location_id":1,"variant_id":10,"variant":{"id":10,"name":"Spree Ringer T-Shirt","sku":"SPR-00015","price":"19.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"spree-ringer-t-shirt","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"17.0","display_price":"$19.99","options_text":"","in_stock":true,"is_backorderable":true,"total_on_hand":10,"is_destroyed":false,"option_values":[],"images":[{"id":38,"position":1,"attachment_content_type":"image/jpeg","attachment_file_name":"spree_ringer_t.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:52.000Z","attachment_width":480,"attachment_height":480,"alt":null,"viewable_type":"Spree::Variant","viewable_id":10,"mini_url":"/spree/products/38/mini/spree_ringer_t.jpeg?1467025852","small_url":"/spree/products/38/small/spree_ringer_t.jpeg?1467025852","product_url":"/spree/products/38/product/spree_ringer_t.jpeg?1467025852","large_url":"/spree/products/38/large/spree_ringer_t.jpeg?1467025852"},{"id":39,"position":2,"attachment_content_type":"image/jpeg","attachment_file_name":"spree_ringer_t_back.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:53.000Z","attachment_width":480,"attachment_height":480,"alt":null,"viewable_type":"Spree::Variant","viewable_id":10,"mini_url":"/spree/products/39/mini/spree_ringer_t_back.jpeg?1467025853","small_url":"/spree/products/39/small/spree_ringer_t_back.jpeg?1467025853","product_url":"/spree/products/39/product/spree_ringer_t_back.jpeg?1467025853","large_url":"/spree/products/39/large/spree_ringer_t_back.jpeg?1467025853"}]}},{"id":11,"count_on_hand":10,"backorderable":true,"stock_location_id":1,"variant_id":11,"variant":{"id":11,"name":"Spree Tote","sku":"SPR-00011","price":"15.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"spree-tote","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"13.0","display_price":"$15.99","options_text":"","in_stock":true,"is_backorderable":true,"total_on_hand":10,"is_destroyed":false,"option_values":[],"images":[{"id":36,"position":1,"attachment_content_type":"image/jpeg","attachment_file_name":"spree_tote_front.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:51.000Z","attachment_width":480,"attachment_height":480,"alt":null,"viewable_type":"Spree::Variant","viewable_id":11,"mini_url":"/spree/products/36/mini/spree_tote_front.jpeg?1467025851","small_url":"/spree/products/36/small/spree_tote_front.jpeg?1467025851","product_url":"/spree/products/36/product/spree_tote_front.jpeg?1467025851","large_url":"/spree/products/36/large/spree_tote_front.jpeg?1467025851"},{"id":37,"position":2,"attachment_content_type":"image/jpeg","attachment_file_name":"spree_tote_back.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:52.000Z","attachment_width":480,"attachment_height":480,"alt":null,"viewable_type":"Spree::Variant","viewable_id":11,"mini_url":"/spree/products/37/mini/spree_tote_back.jpeg?1467025852","small_url":"/spree/products/37/small/spree_tote_back.jpeg?1467025852","product_url":"/spree/products/37/product/spree_tote_back.jpeg?1467025852","large_url":"/spree/products/37/large/spree_tote_back.jpeg?1467025852"}]}},{"id":13,"count_on_hand":10,"backorderable":true,"stock_location_id":1,"variant_id":13,"variant":{"id":13,"name":"Ruby on Rails Mug","sku":"ROR-00014","price":"13.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"ruby-on-rails-mug","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"11.0","display_price":"$13.99","options_text":"","in_stock":true,"is_backorderable":true,"total_on_hand":10,"is_destroyed":false,"option_values":[],"images":[{"id":27,"position":1,"attachment_content_type":"image/jpeg","attachment_file_name":"ror_mug.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:46.000Z","attachment_width":360,"attachment_height":360,"alt":null,"viewable_type":"Spree::Variant","viewable_id":13,"mini_url":"/spree/products/27/mini/ror_mug.jpeg?1467025846","small_url":"/spree/products/27/small/ror_mug.jpeg?1467025846","product_url":"/spree/products/27/product/ror_mug.jpeg?1467025846","large_url":"/spree/products/27/large/ror_mug.jpeg?1467025846"},{"id":28,"position":2,"attachment_content_type":"image/jpeg","attachment_file_name":"ror_mug_back.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:47.000Z","attachment_width":360,"attachment_height":360,"alt":null,"viewable_type":"Spree::Variant","viewable_id":13,"mini_url":"/spree/products/28/mini/ror_mug_back.jpeg?1467025847","small_url":"/spree/products/28/small/ror_mug_back.jpeg?1467025847","product_url":"/spree/products/28/product/ror_mug_back.jpeg?1467025847","large_url":"/spree/products/28/large/ror_mug_back.jpeg?1467025847"}]}},{"id":27,"count_on_hand":0,"backorderable":true,"stock_location_id":1,"variant_id":27,"variant":{"id":27,"name":"iphone","sku":"","price":"100.0","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"iphone","description":null,"track_inventory":true,"cost_price":null,"display_price":"$100.00","options_text":"","in_stock":false,"is_backorderable":true,"total_on_hand":0,"is_destroyed":false,"option_values":[],"images":[]}},{"id":28,"count_on_hand":0,"backorderable":true,"stock_location_id":1,"variant_id":28,"variant":{"id":28,"name":"iphone","sku":"","price":"100.0","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"iphone-3934b5d1-d23e-4063-ad95-b76b7f72af4e","description":null,"track_inventory":true,"cost_price":null,"display_price":"$100.00","options_text":"","in_stock":false,"is_backorderable":true,"total_on_hand":0,"is_destroyed":false,"option_values":[],"images":[]}},{"id":29,"count_on_hand":0,"backorderable":true,"stock_location_id":1,"variant_id":29,"variant":{"id":29,"name":"iphone","sku":"","price":"100.0","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"iphone-1b16be9c-df2e-4dfe-b894-3f02dff58367","description":null,"track_inventory":true,"cost_price":null,"display_price":"$100.00","options_text":"","in_stock":false,"is_backorderable":true,"total_on_hand":0,"is_destroyed":false,"option_values":[],"images":[]}},{"id":30,"count_on_hand":0,"backorderable":true,"stock_location_id":1,"variant_id":30,"variant":{"id":30,"name":"iphone","sku":"","price":"100.0","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"iphone-f6ae6303-cf1e-4667-9b53-a1d1fd8ae418","description":null,"track_inventory":true,"cost_price":null,"display_price":"$100.00","options_text":"","in_stock":false,"is_backorderable":true,"total_on_hand":0,"is_destroyed":false,"option_values":[],"images":[]}},{"id":31,"count_on_hand":0,"backorderable":true,"stock_location_id":1,"variant_id":31,"variant":{"id":31,"name":"iphone","sku":"","price":"100.0","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"iphone-0e15566a-19fe-4882-ab0f-82d599fbb4de","description":null,"track_inventory":true,"cost_price":null,"display_price":"$100.00","options_text":"","in_stock":false,"is_backorderable":true,"total_on_hand":0,"is_destroyed":false,"option_values":[],"images":[]}},{"id":32,"count_on_hand":0,"backorderable":true,"stock_location_id":1,"variant_id":32,"variant":{"id":32,"name":"iphone","sku":"","price":"100.0","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"iphone-527101e2-ee43-4d02-9894-19d29d5a542a","description":null,"track_inventory":true,"cost_price":null,"display_price":"$100.00","options_text":"","in_stock":false,"is_backorderable":true,"total_on_hand":0,"is_destroyed":false,"option_values":[],"images":[]}},{"id":33,"count_on_hand":0,"backorderable":true,"stock_location_id":1,"variant_id":33,"variant":{"id":33,"name":"iphone","sku":"","price":"100.0","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"iphone-520d5c78-4ffe-4a8b-a91e-ee4bb0af9b33","description":null,"track_inventory":true,"cost_price":null,"display_price":"$100.00","options_text":"","in_stock":false,"is_backorderable":true,"total_on_hand":0,"is_destroyed":false,"option_values":[],"images":[]}},{"id":34,"count_on_hand":0,"backorderable":true,"stock_location_id":1,"variant_id":34,"variant":{"id":34,"name":"iphone","sku":"","price":"100.0","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"iphone-695288d4-1a2a-40a3-b164-b154d768e641","description":null,"track_inventory":true,"cost_price":null,"display_price":"$100.00","options_text":"","in_stock":false,"is_backorderable":true,"total_on_hand":0,"is_destroyed":false,"option_values":[],"images":[]}},{"id":35,"count_on_hand":0,"backorderable":true,"stock_location_id":1,"variant_id":35,"variant":{"id":35,"name":"iphone","sku":"","price":"10.0","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"iphone-aefe3a20-7471-4010-9117-c34f2d03cd8d","description":null,"track_inventory":true,"cost_price":null,"display_price":"$10.00","options_text":"","in_stock":false,"is_backorderable":true,"total_on_hand":0,"is_destroyed":false,"option_values":[],"images":[]}},{"id":36,"count_on_hand":0,"backorderable":true,"stock_location_id":1,"variant_id":36,"variant":{"id":36,"name":"iphone","sku":"","price":"10.0","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"iphone-f511f3e0-3e46-4705-8043-d3cab0c6e25b","description":null,"track_inventory":true,"cost_price":null,"display_price":"$10.00","options_text":"","in_stock":false,"is_backorderable":true,"total_on_hand":0,"is_destroyed":false,"option_values":[],"images":[]}},{"id":37,"count_on_hand":0,"backorderable":true,"stock_location_id":1,"variant_id":37,"variant":{"id":37,"name":"iphone","sku":"","price":"100.0","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"iphone-f559d233-ac22-4da0-bb16-3ba7c7a26fd5","description":null,"track_inventory":true,"cost_price":null,"display_price":"$100.00","options_text":"","in_stock":false,"is_backorderable":true,"total_on_hand":0,"is_destroyed":false,"option_values":[],"images":[]}},{"id":38,"count_on_hand":0,"backorderable":true,"stock_location_id":1,"variant_id":38,"variant":{"id":38,"name":"iphone","sku":"","price":"100.0","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"iphone-af8ade0d-b335-45ad-92fe-dd75c12943c7","description":null,"track_inventory":true,"cost_price":null,"display_price":"$100.00","options_text":"","in_stock":false,"is_backorderable":true,"total_on_hand":0,"is_destroyed":false,"option_values":[],"images":[]}},{"id":39,"count_on_hand":0,"backorderable":true,"stock_location_id":1,"variant_id":39,"variant":{"id":39,"name":"iphone","sku":"","price":"100.0","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"iphone-2e7bd331-8d69-43b5-aa99-5cb7b7cfb9e0","description":null,"track_inventory":true,"cost_price":null,"display_price":"$100.00","options_text":"","in_stock":false,"is_backorderable":true,"total_on_hand":0,"is_destroyed":false,"option_values":[],"images":[]}},{"id":40,"count_on_hand":0,"backorderable":true,"stock_location_id":1,"variant_id":40,"variant":{"id":40,"name":"iphone","sku":"","price":"100.0","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"iphone-cf60b57a-c24e-48a4-9719-4ba6d338c5c3","description":null,"track_inventory":true,"cost_price":null,"display_price":"$100.00","options_text":"","in_stock":false,"is_backorderable":true,"total_on_hand":0,"is_destroyed":false,"option_values":[],"images":[]}},{"id":41,"count_on_hand":0,"backorderable":true,"stock_location_id":1,"variant_id":41,"variant":{"id":41,"name":"iphone","sku":"","price":"100.0","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"iphone-6f77a7d7-bfb8-4c5e-975d-319c95aebdd3","description":null,"track_inventory":true,"cost_price":null,"display_price":"$100.00","options_text":"","in_stock":false,"is_backorderable":true,"total_on_hand":0,"is_destroyed":false,"option_values":[],"images":[]}},{"id":42,"count_on_hand":0,"backorderable":true,"stock_location_id":1,"variant_id":42,"variant":{"id":42,"name":"iphone","sku":"","price":"0.0","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"iphone-807cedf0-a4b7-4390-8c71-8eebfb1f657e","description":null,"track_inventory":true,"cost_price":null,"display_price":"$0.00","options_text":"","in_stock":false,"is_backorderable":true,"total_on_hand":0,"is_destroyed":false,"option_values":[],"images":[]}}]} \ No newline at end of file diff --git a/tests/test_spree.py b/tests/test_spree.py index b547f18..9df8abb 100644 --- a/tests/test_spree.py +++ b/tests/test_spree.py @@ -47,7 +47,7 @@ def test_finding_one_product(resp, spree): def test_orders_all(resp, spree): "test fetching all orders" - test_orders = spree.orders.all() + test_orders = spree.order.all() test_order = test_orders[0]['orders'][0] assert test_order['number'] == 'R123456789' assert test_order['item_total'] == '15.99' @@ -59,10 +59,27 @@ def test_orders_all(resp, spree): def test_finding_one_order(resp, spree): "test fetching order with respect to order_id" - test_order = spree.orders.find('R123456789') + test_order = spree.order.find('R123456789') assert test_order['number'] == 'R123456789' assert test_order['item_total'] == '15.99' assert test_order['state'] == 'complete' assert test_order['shipment_state'] == 'pending' assert test_order['payment_total'] == '0.0' assert test_order['token'] == 'aAoojFjB1_PCBeLR1VPnIg' + + +def test_stock_items_all(resp, spree): + "test fetching all stock items" + test_stock_items = spree.stock_item.all(1) + test_stock_item = test_stock_items[0]['stock_items'][0] + assert test_stock_item['count_on_hand'] == 10 + assert test_stock_item['stock_location_id'] == 1 + assert test_stock_item['variant_id'] == 4 + + +def test_finding_one_stock_item(resp, spree): + "test fetching all stock items" + test_stock_item = spree.stock_item.find(1, 4) + assert test_stock_item['count_on_hand'] == 10 + assert test_stock_item['stock_location_id'] == 1 + assert test_stock_item['variant_id'] == 4 From f42603a549f83982d519245858313af3c0a4e71c Mon Sep 17 00:00:00 2001 From: Joe Paul Date: Thu, 30 Jun 2016 16:52:38 +0530 Subject: [PATCH 4/6] Fix pagination and iteration bug --- spree/spree.py | 14 ++++++++++---- tests/test_spree.py | 6 +++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/spree/spree.py b/spree/spree.py index 2f05764..caf4cbf 100644 --- a/spree/spree.py +++ b/spree/spree.py @@ -36,12 +36,18 @@ def count(self): def __iter__(self): return self - def __getitem__(self, key): - return self.data + def __getitem__(self, index): + return self.items[index] + + def __setitem__(self, index, value): + self.items[index] = value def next(self): - self.current_index += 1 - return self.items[self.current_index] + if self.current_index < self.count-1: + self.current_index += 1 + return self.items[self.current_index] + else: + raise StopIteration class Resource(object): diff --git a/tests/test_spree.py b/tests/test_spree.py index 9df8abb..7b5309a 100644 --- a/tests/test_spree.py +++ b/tests/test_spree.py @@ -15,7 +15,7 @@ def test_products_all(resp, spree): "test fetching all products" products = spree.product.all() assert products.count == 16 - test_product = products[0]['products'][1] + test_product = products[1] assert test_product['name'] == 'Ruby on Rails Bag' assert test_product['master']['sku'] == 'ROR-00012' assert test_product['description'] == 'Et illo et' \ @@ -48,7 +48,7 @@ def test_finding_one_product(resp, spree): def test_orders_all(resp, spree): "test fetching all orders" test_orders = spree.order.all() - test_order = test_orders[0]['orders'][0] + test_order = test_orders[0] assert test_order['number'] == 'R123456789' assert test_order['item_total'] == '15.99' assert test_order['state'] == 'complete' @@ -71,7 +71,7 @@ def test_finding_one_order(resp, spree): def test_stock_items_all(resp, spree): "test fetching all stock items" test_stock_items = spree.stock_item.all(1) - test_stock_item = test_stock_items[0]['stock_items'][0] + test_stock_item = test_stock_items[0] assert test_stock_item['count_on_hand'] == 10 assert test_stock_item['stock_location_id'] == 1 assert test_stock_item['variant_id'] == 4 From 662f3b44d7bfef3991dae670dfa20e07b77513bc Mon Sep 17 00:00:00 2001 From: Joe Paul Date: Sat, 2 Jul 2016 00:34:34 +0530 Subject: [PATCH 5/6] Provision for importing variants --- spree/spree.py | 17 +++++++++++++++++ tests/conftest.py | 7 +++++++ tests/responses/variant-ROR-00013.json | 1 + tests/test_spree.py | 9 +++++++++ 4 files changed, 34 insertions(+) create mode 100644 tests/responses/variant-ROR-00013.json diff --git a/spree/spree.py b/spree/spree.py index caf4cbf..305aeaf 100644 --- a/spree/spree.py +++ b/spree/spree.py @@ -22,6 +22,10 @@ def order(self): def stock_item(self): return StockItem(connection=self) + @property + def variant(self): + return Variant(connection=self) + class Pagination(object): def __init__(self, data, items_attribute): @@ -181,3 +185,16 @@ def update(self, stk_loc_id, stk_id, data): def delete(self, stk_loc_id, stk_id): self.path = self.append_path(stk_loc_id) return super(StockItem, self).delete(stk_id) + + +class Variant(Resource): + """ + A variant item Resource class + """ + + path = '/variants' + item_attribute = 'variants' + + def all(self, permalink): + self.path = '/products' + '/' + permalink + self.path + return super(Variant, self).all() diff --git a/tests/conftest.py b/tests/conftest.py index 334c612..509d989 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -63,6 +63,13 @@ def resp(fp): body=open(fp('responses/stock_item-4.json'), 'r').read() ) + "Variants" + rsps.add( + responses.GET, + 'http://mystore/api/products/ruby-on-rails-jr-spaghetti/variants', + body=open(fp('responses/variant-ROR-00013.json'), 'r').read() + ) + yield rsps rsps.stop() diff --git a/tests/responses/variant-ROR-00013.json b/tests/responses/variant-ROR-00013.json new file mode 100644 index 0000000..d0503d0 --- /dev/null +++ b/tests/responses/variant-ROR-00013.json @@ -0,0 +1 @@ +{"count":1,"total_count":1,"current_page":1,"pages":1,"variants":[{"id":4,"name":"Ruby on Rails Jr. Spaghetti","sku":"ROR-00013","price":"19.99","weight":"0.0","height":null,"width":null,"depth":null,"is_master":true,"slug":"ruby-on-rails-jr-spaghetti","description":"Et illo et voluptatum corporis. Fugiat atque optio voluptates placeat ut odio. Iusto totam molestiae tenetur eaque molestias. Occaecati sunt sit magni voluptatibus qui ipsum.","track_inventory":true,"cost_price":"17.0","display_price":"$19.99","options_text":"","in_stock":true,"is_backorderable":true,"total_on_hand":10,"is_destroyed":false,"option_values":[],"images":[{"id":26,"position":1,"attachment_content_type":"image/jpeg","attachment_file_name":"ror_jr_spaghetti.jpeg","type":"Spree::Image","attachment_updated_at":"2016-06-27T11:10:46.000Z","attachment_width":360,"attachment_height":360,"alt":null,"viewable_type":"Spree::Variant","viewable_id":4,"mini_url":"/spree/products/26/mini/ror_jr_spaghetti.jpeg?1467025846","small_url":"/spree/products/26/small/ror_jr_spaghetti.jpeg?1467025846","product_url":"/spree/products/26/product/ror_jr_spaghetti.jpeg?1467025846","large_url":"/spree/products/26/large/ror_jr_spaghetti.jpeg?1467025846"}],"stock_items":[{"id":4,"count_on_hand":10,"stock_location_id":1,"backorderable":true,"available":true,"stock_location_name":"default"}]}]} \ No newline at end of file diff --git a/tests/test_spree.py b/tests/test_spree.py index 7b5309a..9ab22d6 100644 --- a/tests/test_spree.py +++ b/tests/test_spree.py @@ -83,3 +83,12 @@ def test_finding_one_stock_item(resp, spree): assert test_stock_item['count_on_hand'] == 10 assert test_stock_item['stock_location_id'] == 1 assert test_stock_item['variant_id'] == 4 + + +def test_variant_via_permalink(resp, spree): + "test fetching variant by product permalink" + test_variants = spree.variant.all('ruby-on-rails-jr-spaghetti') + test_variant = test_variants[0] + assert test_variant['sku'] == 'ROR-00013' + assert test_variant['price'] == '19.99' + assert test_variant['cost_price'] == '17.0' From 331372d41a52c84fbb0c318c98131a6ef177d828 Mon Sep 17 00:00:00 2001 From: Tarun Bhardwaj Date: Mon, 4 Jul 2016 13:23:51 +0530 Subject: [PATCH 6/6] Released version 0.1.0