[Python-modules-commits] [python-tunigo] 01/05: import python-tunigo_1.0.0.orig.tar.gz

Stein Magnus Jodal jodal at moszumanska.debian.org
Mon Feb 15 20:11:41 UTC 2016


This is an automated email from the git hooks/post-receive script.

jodal pushed a commit to branch master
in repository python-tunigo.

commit 99b88fbe0f6b52177deaca1c20cd21c2363bbf63
Author: Stein Magnus Jodal <jodal at debian.org>
Date:   Mon Feb 15 20:42:04 2016 +0100

    import python-tunigo_1.0.0.orig.tar.gz
---
 .travis.yml                          |  29 ++
 LICENSE                              | 202 ++++++++++++++
 MANIFEST.in                          |  13 +
 PKG-INFO                             | 137 ++++++++++
 README.rst                           | 114 ++++++++
 dev-requirements.txt                 |  12 +
 examples/genres.py                   |  24 ++
 examples/new_releases.py             |  13 +
 examples/playlists.py                |  15 ++
 examples/set_config.py               |  12 +
 setup.cfg                            |  12 +
 setup.py                             |  45 ++++
 tests/__init__.py                    |   0
 tests/test_api.py                    | 508 +++++++++++++++++++++++++++++++++++
 tests/test_cache.py                  |  44 +++
 tests/test_genre.py                  | 139 ++++++++++
 tests/test_playlist.py               | 102 +++++++
 tests/test_release.py                |  58 ++++
 tests/test_translator.py             |  11 +
 tests/test_utils.py                  |  70 +++++
 tox.ini                              |  22 ++
 tunigo.egg-info/PKG-INFO             | 137 ++++++++++
 tunigo.egg-info/SOURCES.txt          |  34 +++
 tunigo.egg-info/dependency_links.txt |   1 +
 tunigo.egg-info/not-zip-safe         |   1 +
 tunigo.egg-info/requires.txt         |   2 +
 tunigo.egg-info/top_level.txt        |   1 +
 tunigo/__init__.py                   |  19 ++
 tunigo/api.py                        | 112 ++++++++
 tunigo/cache.py                      |  31 +++
 tunigo/genre.py                      | 185 +++++++++++++
 tunigo/playlist.py                   | 146 ++++++++++
 tunigo/release.py                    | 139 ++++++++++
 tunigo/translator.py                 |  14 +
 tunigo/utils.py                      |  25 ++
 35 files changed, 2429 insertions(+)

diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..d281272
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,29 @@
+sudo: false
+
+language: python
+
+env:
+  - TOX_ENV=py27
+  - TOX_ENV=py33
+  - TOX_ENV=py34
+#  - TOX_ENV=py35
+  - TOX_ENV=pypy
+  - TOX_ENV=pypy3
+  - TOX_ENV=flake8
+
+# It is currently necessary to specify python 3.5 when using py35 on Travis,
+# see https://github.com/travis-ci/travis-ci/issues/4794
+matrix:
+  include:
+    - python: 3.5
+      env:
+        - TOX_ENV=py35
+
+install:
+  - "pip install tox"
+
+script:
+  - "tox -e $TOX_ENV"
+
+after_success:
+  - "if [ $TOX_ENV == 'py27' ]; then pip install coveralls; coveralls; fi"
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..b6172d4
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,13 @@
+include *.py
+include *.rst
+include *.txt
+include .travis.yml
+include LICENSE
+include MANIFEST.in
+include tox.ini
+
+recursive-include examples *.py
+
+recursive-include tests *.py
+
+global-exclude __pycache__/*
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..181245f
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,137 @@
+Metadata-Version: 1.1
+Name: tunigo
+Version: 1.0.0
+Summary: Python API for the browse feature of Spotify
+Home-page: https://github.com/trygveaa/python-tunigo
+Author: Trygve Aaberge
+Author-email: trygveaa at gmail.com
+License: Apache License, Version 2.0
+Description: *************
+        Python-Tunigo
+        *************
+        
+        .. image:: https://img.shields.io/pypi/v/tunigo.svg?style=flat
+            :target: https://pypi.python.org/pypi/tunigo/
+            :alt: Latest PyPI version
+        
+        .. image:: https://img.shields.io/pypi/dm/tunigo.svg?style=flat
+            :target: https://pypi.python.org/pypi/tunigo/
+            :alt: Number of PyPI downloads
+        
+        .. image:: https://img.shields.io/travis/trygveaa/python-tunigo/master.png?style=flat
+            :target: https://travis-ci.org/trygveaa/python-tunigo
+            :alt: Travis CI build status
+        
+        .. image:: https://img.shields.io/coveralls/trygveaa/python-tunigo/master.svg?style=flat
+           :target: https://coveralls.io/r/trygveaa/python-tunigo?branch=master
+           :alt: Test coverage
+        
+        Python-Tunigo is a python package that allows for simple access to `Tunigo
+        <http://tunigo.com/>`_'s API. This is an API for fetching featured playlists and
+        new releases for `Spotify <https://www.spotify.com/>`_. It supports featured
+        playlists, top playlists, new album releases and playlists for a range of
+        different genres.
+        
+        Tunigo's API is what the Spotify client uses to provide its Browse-feature.
+        
+        Note that the API is not documented or officially released, so it may change at
+        any time.
+        
+        
+        Installation
+        ============
+        
+        Debian/Ubuntu/Raspbian: Install the ``python-tunigo`` or the ``python3-tunigo``
+        package from `apt.mopidy.com <http://apt.mopidy.com/>`_::
+        
+            sudo apt-get install python-tunigo
+            sudo apt-get install python3-tunigo
+        
+        Arch Linux: Install the ``python2-tunigo`` or the ``python-tunigo`` package
+        from `AUR <https://aur.archlinux.org/packages/mopidy-spotify/>`_, e.g.::
+        
+            yaourt -S python2-tunigo
+            yaourt -S python-tunigo
+        
+        Else: Install the ``tunigo`` package from PyPI::
+        
+            pip install tunigo
+        
+        
+        Examples
+        ========
+        
+        .. code-block:: python
+        
+            import tunigo
+            tunigo = tunigo.Tunigo()
+            for playlist in tunigo.get_featured_playlists():
+                print(playlist.title)
+        
+        See the ``examples/`` directory for further examples.
+        
+        
+        License
+        =======
+        
+        Python-Tunigo is licensed under the `Apache License, Version 2.0
+        <http://www.apache.org/licenses/LICENSE-2.0>`_.
+        
+        
+        Project resources
+        =================
+        
+        - `Source code <https://github.com/trygveaa/python-tunigo>`_
+        - `Issue tracker <https://github.com/trygveaa/python-tunigo/issues>`_
+        - `Download development snapshot <https://github.com/trygveaa/python-tunigo/archive/master.tar.gz#egg=python-tunigo-dev>`_
+        
+        
+        Changelog
+        =========
+        
+        v1.0.0 (2016-02-07)
+        -------------------
+        
+        - Add support for specifying a proxy to use.
+        - Don't specify region in API call if not given. (Fixes: #2)
+        - Add the new field Release.artist_uri.
+        - Fix type of Release.created to be int all places.
+        - Add tests for all classes.
+        
+        v0.1.3 (2014-11-29)
+        -------------------
+        
+        - Fix check for content-type so it doesn't fail after a change in the API.
+        
+        v0.1.2 (2014-08-03)
+        -------------------
+        
+        - Fix that some genres were not listed by using the same query options as
+          play.spotify.com.
+        
+        v0.1.1 (2014-07-21)
+        -------------------
+        
+        - Allow Genre- and SubGenre-objects as arguments to get_genre_playlists.
+        - Allow a SubGenre to be created with main_genre as a string.
+        - Add __repr__ and __str__ methods to classes.
+        
+        v0.1.0 (2014-06-24)
+        -------------------
+        
+        - Initial release.
+        
+Platform: UNKNOWN
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: Apache Software License
+Classifier: Operating System :: OS Independent
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: Implementation :: CPython
+Classifier: Programming Language :: Python :: Implementation :: PyPy
+Classifier: Topic :: Software Development :: Libraries
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..52cfc98
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,114 @@
+*************
+Python-Tunigo
+*************
+
+.. image:: https://img.shields.io/pypi/v/tunigo.svg?style=flat
+    :target: https://pypi.python.org/pypi/tunigo/
+    :alt: Latest PyPI version
+
+.. image:: https://img.shields.io/pypi/dm/tunigo.svg?style=flat
+    :target: https://pypi.python.org/pypi/tunigo/
+    :alt: Number of PyPI downloads
+
+.. image:: https://img.shields.io/travis/trygveaa/python-tunigo/master.png?style=flat
+    :target: https://travis-ci.org/trygveaa/python-tunigo
+    :alt: Travis CI build status
+
+.. image:: https://img.shields.io/coveralls/trygveaa/python-tunigo/master.svg?style=flat
+   :target: https://coveralls.io/r/trygveaa/python-tunigo?branch=master
+   :alt: Test coverage
+
+Python-Tunigo is a python package that allows for simple access to `Tunigo
+<http://tunigo.com/>`_'s API. This is an API for fetching featured playlists and
+new releases for `Spotify <https://www.spotify.com/>`_. It supports featured
+playlists, top playlists, new album releases and playlists for a range of
+different genres.
+
+Tunigo's API is what the Spotify client uses to provide its Browse-feature.
+
+Note that the API is not documented or officially released, so it may change at
+any time.
+
+
+Installation
+============
+
+Debian/Ubuntu/Raspbian: Install the ``python-tunigo`` or the ``python3-tunigo``
+package from `apt.mopidy.com <http://apt.mopidy.com/>`_::
+
+    sudo apt-get install python-tunigo
+    sudo apt-get install python3-tunigo
+
+Arch Linux: Install the ``python2-tunigo`` or the ``python-tunigo`` package
+from `AUR <https://aur.archlinux.org/packages/mopidy-spotify/>`_, e.g.::
+
+    yaourt -S python2-tunigo
+    yaourt -S python-tunigo
+
+Else: Install the ``tunigo`` package from PyPI::
+
+    pip install tunigo
+
+
+Examples
+========
+
+.. code-block:: python
+
+    import tunigo
+    tunigo = tunigo.Tunigo()
+    for playlist in tunigo.get_featured_playlists():
+        print(playlist.title)
+
+See the ``examples/`` directory for further examples.
+
+
+License
+=======
+
+Python-Tunigo is licensed under the `Apache License, Version 2.0
+<http://www.apache.org/licenses/LICENSE-2.0>`_.
+
+
+Project resources
+=================
+
+- `Source code <https://github.com/trygveaa/python-tunigo>`_
+- `Issue tracker <https://github.com/trygveaa/python-tunigo/issues>`_
+- `Download development snapshot <https://github.com/trygveaa/python-tunigo/archive/master.tar.gz#egg=python-tunigo-dev>`_
+
+
+Changelog
+=========
+
+v1.0.0 (2016-02-07)
+-------------------
+
+- Add support for specifying a proxy to use.
+- Don't specify region in API call if not given. (Fixes: #2)
+- Add the new field Release.artist_uri.
+- Fix type of Release.created to be int all places.
+- Add tests for all classes.
+
+v0.1.3 (2014-11-29)
+-------------------
+
+- Fix check for content-type so it doesn't fail after a change in the API.
+
+v0.1.2 (2014-08-03)
+-------------------
+
+- Fix that some genres were not listed by using the same query options as
+  play.spotify.com.
+
+v0.1.1 (2014-07-21)
+-------------------
+
+- Allow Genre- and SubGenre-objects as arguments to get_genre_playlists.
+- Allow a SubGenre to be created with main_genre as a string.
+- Add __repr__ and __str__ methods to classes.
+
+v0.1.0 (2014-06-24)
+-------------------
+
+- Initial release.
diff --git a/dev-requirements.txt b/dev-requirements.txt
new file mode 100644
index 0000000..95fee64
--- /dev/null
+++ b/dev-requirements.txt
@@ -0,0 +1,12 @@
+# Check code style, errors, etc
+flake8
+flake8-import-order
+
+# Mock dependencies in tests
+mock
+responses
+
+# Test runners
+pytest
+pytest-cov
+tox
diff --git a/examples/genres.py b/examples/genres.py
new file mode 100644
index 0000000..b9fae71
--- /dev/null
+++ b/examples/genres.py
@@ -0,0 +1,24 @@
+from tunigo import Tunigo
+
+tunigo = Tunigo()
+
+# Returns the available genres, including sub genres and a playlist containing
+# top tracks for each genre.
+genres = tunigo.get_genres()
+
+# Returns playlists for a genre.
+genre_playlists = tunigo.get_genre_playlists(genres[0])
+
+# Or use a specific genre key.
+genre_playlists = tunigo.get_genre_playlists('rock')
+
+# Returns playlists for a sub genre.
+genre_playlists = tunigo.get_genre_playlists(sub_genre=genres[0].sub_genres[0])
+
+# Or use specific genre and sub genre keys.
+genre_playlists = tunigo.get_genre_playlists('rock', 'metal')
+
+# Print the name and number of playlists for each genre.
+# All the available fields can be seen in tunigo/genre.py
+for genre in genres:
+    print('{}: {} playlists'.format(genre.name, genre.number_playlists))
diff --git a/examples/new_releases.py b/examples/new_releases.py
new file mode 100644
index 0000000..947b6de
--- /dev/null
+++ b/examples/new_releases.py
@@ -0,0 +1,13 @@
+from tunigo import Tunigo
+
+tunigo = Tunigo()
+
+# Returns new album releases.
+releases = tunigo.get_new_releases()
+
+# Print the artist and album name, as well as the URI for each release.
+# All the available fields can be seen in tunigo/release.py.
+for release in releases:
+    print('{} - {} ({})'.format(release.artist_name,
+                                release.album_name,
+                                release.uri))
diff --git a/examples/playlists.py b/examples/playlists.py
new file mode 100644
index 0000000..187f7e5
--- /dev/null
+++ b/examples/playlists.py
@@ -0,0 +1,15 @@
+from tunigo import Tunigo
+
+tunigo = Tunigo()
+
+# Returns the currently featured playlists.
+featured_playlists = tunigo.get_featured_playlists()
+
+# Returns playlists of top tracks in various categories, as well as other
+# popular playlists.
+top_lists = tunigo.get_top_lists()
+
+# Print the title and URI for each playlist.
+# All the available fields can be seen in tunigo/playlist.py
+for playlist in top_lists:
+    print('{} ({})'.format(playlist.title, playlist.uri))
diff --git a/examples/set_config.py b/examples/set_config.py
new file mode 100644
index 0000000..f15e42b
--- /dev/null
+++ b/examples/set_config.py
@@ -0,0 +1,12 @@
+from tunigo import Tunigo
+
+tunigo = Tunigo(
+    # Region to use in API calls. Should be a two letter country code.
+    # Defaults to 'all'.
+    region='no',
+
+    # Max number of results for each API call. Defaults to 1000.
+    max_results=100,
+
+    # Number of seconds to cache results from the API. Defaults to 3600.
+    cache_time=60)
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..609b950
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,12 @@
+[flake8]
+application-import-names = tunigo,tests
+exclude = .git,.tox
+
+[wheel]
+universal = 1
+
+[egg_info]
+tag_build = 
+tag_date = 0
+tag_svn_revision = 0
+
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..592e874
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,45 @@
+from __future__ import unicode_literals
+
+import re
+
+from setuptools import find_packages, setup
+
+
+def get_version(filename):
+    content = open(filename).read()
+    metadata = dict(re.findall("__([a-z]+)__ = '([^']+)'", content))
+    return metadata['version']
+
+
+setup(
+    name='tunigo',
+    version=get_version('tunigo/__init__.py'),
+    url='https://github.com/trygveaa/python-tunigo',
+    license='Apache License, Version 2.0',
+    author='Trygve Aaberge',
+    author_email='trygveaa at gmail.com',
+    description='Python API for the browse feature of Spotify',
+    long_description=open('README.rst').read(),
+    packages=find_packages(exclude=['tests', 'tests.*']),
+    zip_safe=False,
+    include_package_data=True,
+    install_requires=[
+        'requests >= 2.0.0',
+        'setuptools',
+    ],
+    classifiers=[
+        'Development Status :: 5 - Production/Stable',
+        'Intended Audience :: Developers',
+        'License :: OSI Approved :: Apache Software License',
+        'Operating System :: OS Independent',
+        'Programming Language :: Python :: 2',
+        'Programming Language :: Python :: 2.7',
+        'Programming Language :: Python :: 3',
+        'Programming Language :: Python :: 3.3',
+        'Programming Language :: Python :: 3.4',
+        'Programming Language :: Python :: 3.5',
+        'Programming Language :: Python :: Implementation :: CPython',
+        'Programming Language :: Python :: Implementation :: PyPy',
+        'Topic :: Software Development :: Libraries',
+    ],
+)
diff --git a/tests/__init__.py b/tests/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/tests/test_api.py b/tests/test_api.py
new file mode 100644
index 0000000..61f92da
--- /dev/null
+++ b/tests/test_api.py
@@ -0,0 +1,508 @@
+from __future__ import unicode_literals
+
+import time
+
+import responses
+
+from tunigo.api import BASE_QUERY, BASE_URL, Tunigo
+from tunigo.genre import Genre, SubGenre
+from tunigo.playlist import Playlist
+from tunigo.release import Release
+
+
+class TestApi(object):
+
+    @responses.activate
+    def test_repr(self):
+        tunigo = Tunigo(region='no', max_results=100, cache_time=3600)
+
+        assert (
+            tunigo.__repr__() ==
+            "Tunigo(region='no', max_results=100, cache_time=3600)")
+
+    @responses.activate
+    def test_returns_items(self):
+        max_results = 100
+        tunigo = Tunigo(max_results=max_results)
+
+        responses.add(
+            responses.GET,
+            BASE_URL + '/key',
+            content_type='application/json',
+            body='{"items": [{"test": 1}]}')
+
+        result = tunigo._get('key')
+
+        assert len(responses.calls) == 1
+        assert (
+            responses.calls[0].request.url ==
+            '{}/key?{}&per_page={}'.format(
+                BASE_URL, BASE_QUERY, max_results))
+
+        assert len(result) == 1
+        assert result[0]['test'] == 1
+
+    @responses.activate
+    def test_returns_empty_array_if_status_not_200(self):
+        max_results = 100
+        tunigo = Tunigo(max_results=max_results)
+
+        responses.add(
+            responses.GET,
+            BASE_URL + '/key',
+            status=404,
+            content_type='application/json',
+            body='{"items": [{"test": 1}]}')
+
+        result = tunigo._get('key')
+
+        assert len(responses.calls) == 1
+        assert (
+            responses.calls[0].request.url ==
+            '{}/key?{}&per_page={}'.format(
+                BASE_URL, BASE_QUERY, max_results))
+
+        assert result == []
+
+    @responses.activate
+    def test_returns_empty_array_if_content_type_not_application_json(self):
+        max_results = 100
+        tunigo = Tunigo(max_results=max_results)
+
+        responses.add(
+            responses.GET,
+            BASE_URL + '/key',
+            body='{"items": [{"test": 1}]}')
+
+        result = tunigo._get('key')
+
+        assert len(responses.calls) == 1
+        assert (
+            responses.calls[0].request.url ==
+            '{}/key?{}&per_page={}'.format(
+                BASE_URL, BASE_QUERY, max_results))
+
+        assert result == []
+
+    @responses.activate
+    def test_set_given_region_query_option(self):
+        max_results = 100
+        tunigo = Tunigo(region='no', max_results=max_results)
+
+        responses.add(responses.GET, BASE_URL + '/key')
+
+        tunigo._get('key')
+
+        assert len(responses.calls) == 1
+        assert (
+            responses.calls[0].request.url ==
+            '{}/key?{}&per_page={}&region=no'.format(
+                BASE_URL, BASE_QUERY, max_results))
+
+    @responses.activate
+    def test_set_given_query_options(self):
+        max_results = 100
+        tunigo = Tunigo(max_results=max_results)
+
+        responses.add(responses.GET, BASE_URL + '/key')
+
+        tunigo._get('key', 'test=value')
+
+        assert len(responses.calls) == 1
+        assert (
+            responses.calls[0].request.url ==
+            '{}/key?{}&per_page={}&test=value'.format(
+                BASE_URL, BASE_QUERY, max_results))
+
+    @responses.activate
+    def test_returns_playlists(self):
+        max_results = 100
+        tunigo = Tunigo(max_results=max_results)
+
+        responses.add(
+            responses.GET,
+            BASE_URL + '/key',
+            content_type='application/json',
+            body="""
+                {
+                  "items": [
+                    {
+                      "playlist": {
+                        "title": "Title 0",
+                        "description": "Description 0",
+                        "image": "Image 0",
+                        "uri": "uri:0",
+                        "numSubscribers": 0
+                      }
+                    },
+                    {
+                      "playlist": {
+                        "title": "Title 1",
+                        "description": "Description 1",
+                        "image": "Image 1",
+                        "uri": "uri:1",
+                        "numSubscribers": 1
+                      }
+                    }
+                  ]
+                }""")
+
+        playlists = tunigo.get_playlists('key')
+
+        assert len(responses.calls) == 1
+        assert (
+            responses.calls[0].request.url ==
+            '{}/key?{}&per_page={}'.format(
+                BASE_URL, BASE_QUERY, max_results))
+
+        assert len(playlists) == 2
+
+        assert isinstance(playlists[0], Playlist)
+        assert playlists[0].title == 'Title 0'
+        assert playlists[0].description == 'Description 0'
+        assert playlists[0].image == 'Image 0'
+        assert playlists[0].uri == 'uri:0'
+        assert playlists[0].num_subscribers == 0
+
+        assert isinstance(playlists[1], Playlist)
+        assert playlists[1].title == 'Title 1'
+        assert playlists[1].description == 'Description 1'
+        assert playlists[1].image == 'Image 1'
+        assert playlists[1].uri == 'uri:1'
+        assert playlists[1].num_subscribers == 1
+
+    @responses.activate
+    def test_sets_playlists_query_options(self):
+        max_results = 100
+        tunigo = Tunigo(max_results=max_results)
+
+        responses.add(responses.GET, BASE_URL + '/key')
+
+        tunigo.get_playlists('key', 'test=value')
+
+        assert len(responses.calls) == 1
+        assert (
+            responses.calls[0].request.url ==
+            '{}/key?{}&per_page={}&test=value'.format(
+                BASE_URL, BASE_QUERY, max_results))
+
+    @responses.activate
+    def test_caches_playlists_result(self):
+        max_results = 100
+        tunigo = Tunigo(max_results=max_results)
+
+        responses.add(responses.GET, BASE_URL + '/key')
+
+        tunigo.get_playlists('key')
+        tunigo.get_playlists('key')
+
+        assert len(responses.calls) == 1
+        assert (
+            responses.calls[0].request.url ==
+            '{}/key?{}&per_page={}'.format(
+                BASE_URL, BASE_QUERY, max_results))
+
+    @responses.activate
+    def test_featured_playlist_calls_uri(self):
+        max_results = 100
+        tunigo = Tunigo(max_results=max_results)
+
+        responses.add(responses.GET, BASE_URL + '/featured-playlists')
+
+        tunigo.get_featured_playlists()
+
+        assert len(responses.calls) == 1
+        assert (
+            responses.calls[0].request.url ==
+            '{}/featured-playlists?{}&per_page={}&dt={}'.format(
+                BASE_URL,
+                BASE_QUERY,
+                max_results,
+                time.strftime('%FT%H:01:00')))
+
+    @responses.activate
+    def test_top_lists_calls_uri(self):
+        max_results = 100
+        tunigo = Tunigo(max_results=max_results)
+
+        responses.add(responses.GET, BASE_URL + '/toplists')
+
+        tunigo.get_top_lists()
+
+        assert len(responses.calls) == 1
+        assert (
+            responses.calls[0].request.url ==
+            '{}/toplists?{}&per_page={}'.format(
+                BASE_URL, BASE_QUERY, max_results))
+
+    @responses.activate
+    def test_returns_genres(self):
+        max_results = 100
+        tunigo = Tunigo(max_results=max_results)
+
+        responses.add(
+            responses.GET,
+            BASE_URL + '/genres',
+            content_type='application/json',
+            body="""
+                {
... 1680 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-tunigo.git



More information about the Python-modules-commits mailing list