From 75d6790aa77e3c6617064ee1554bedfda913ea21 Mon Sep 17 00:00:00 2001 From: Allen Luce Date: Sat, 14 May 2016 18:03:24 -0700 Subject: [PATCH 1/3] Don't bother with the quoting Params are already urlencoded by this point. Quoting here can mess up unicode URLs. The included test relies on two environment variables to be set: AWS_ACCESS_ID and AWS_SECRET_ACCESS_KEY. The associated credentials should be authorized to do Alexa API queries. --- awis/__init__.py | 2 +- test/conftest.py | 3 +++ test/test_awis.py | 10 ++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 test/conftest.py create mode 100755 test/test_awis.py diff --git a/awis/__init__.py b/awis/__init__.py index 687e3ba..bfd34b0 100644 --- a/awis/__init__.py +++ b/awis/__init__.py @@ -121,7 +121,7 @@ def category_listings(self, path, SortBy="Popularity", Recursive=False, Start=1, params = { "Action": "CategoryListings", "ResponseGroup": "Listings", - "Path": quote(path), + "Path": path, "SortBy": SortBy, "Start": str(Start), "Recursive": str(not not Recursive), diff --git a/test/conftest.py b/test/conftest.py new file mode 100644 index 0000000..ee6a555 --- /dev/null +++ b/test/conftest.py @@ -0,0 +1,3 @@ +import sys, os +sys.path.append(os.path.abspath('.')) + diff --git a/test/test_awis.py b/test/test_awis.py new file mode 100755 index 0000000..8c09e2c --- /dev/null +++ b/test/test_awis.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +from awis import AwisApi +import os + +def test_unicode(): + api = AwisApi(os.environ['AWS_ACCESS_ID'], os.environ['AWS_SECRET_ACCESS_KEY']) + tree = api.category_listings("Top/World/Dansk/Børn_og_unge/Kultur") + listings = tree.findall('.//awis:Listing', AwisApi.NS_PREFIXES) + + assert len(listings) > 0 From c2a4e006093eb9de1dc18d9e93e317d91d5ea8fc Mon Sep 17 00:00:00 2001 From: Allen Luce Date: Sat, 14 May 2016 18:03:47 -0700 Subject: [PATCH 2/3] Add travis and coveralls configs. And add test runner to setup.py. The setup.cfg aliases test to pytest. --- .travis.yml | 13 +++++++++++++ requirements.txt | 3 +++ setup.cfg | 2 ++ setup.py | 4 +++- 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 .travis.yml create mode 100644 requirements.txt create mode 100644 setup.cfg diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..e382de7 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,13 @@ +language: python +python: + - "2.7" + - "3.3" + - "3.4" + - "3.5" + - "3.5-dev" # 3.5 development branch + - "nightly" # currently points to 3.6-dev +script: + - "python setup.py test" + - coverage run --source=awis setup.py test +after_success: + - coveralls diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..1012bfe --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +pytest==2.8.5 +coverage==4.0.3 +coveralls==1.1 diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..b7e4789 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,2 @@ +[aliases] +test=pytest diff --git a/setup.py b/setup.py index 059eb0d..d40747d 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -from distutils.core import setup +from setuptools import setup from distutils.command.install import INSTALL_SCHEMES from awis import __version__, __maintainer__, __email__ @@ -14,6 +14,8 @@ setup( + setup_requires=['pytest-runner'], + tests_require=['pytest'], name = 'python-awis', version = __version__, url = 'http://github.com/muhuk/python-awis', From 435e8c0c731f3d3aa2dc5ea9f17e9f4d31e2480f Mon Sep 17 00:00:00 2001 From: Allen Luce Date: Sat, 14 May 2016 19:22:40 -0700 Subject: [PATCH 3/3] Add badges. For TravisCI and coveralls.io --- README.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/README.rst b/README.rst index ee98349..c446712 100644 --- a/README.rst +++ b/README.rst @@ -1,3 +1,4 @@ +[![Build Status](https://travis-ci.org/muhuk/python-awis.svg?branch=master)](https://travis-ci.org/muhuk/python-awis) Wraps `Alexa Web Information Service`_. Usage