Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop support for EOL Python #90

Merged
merged 7 commits into from
Oct 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/PULL_REQUEST_TEMPLATE
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ We appreciate the effort for this pull request but before that please make sure


Please enter each Issue number you are resolving in your PR after one of the following words [Fixes, Closes, Resolves]. This will auto-link these issues and close them when this PR is merged!
e.g.
e.g.
Fixes #1
Closes #2
-->
# Fixes #
# Fixes #

### Checklist
- [ ] I have made a material change to the repo (functionality, testing, spelling, grammar)
Expand All @@ -18,7 +18,7 @@ Closes #2
- [ ] I have added in line documentation to the code I modified

### Short description of what this PR does:
-
-
-
-

If you have questions, please send an email to [Sendgrid](mailto:[email protected]), or file a Github Issue in this repository.
If you have questions, please send an email to [SendGrid](mailto:[email protected]), or file a GitHub Issue in this repository.
10 changes: 3 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ language: python
sudo: false
cache: pip
python:
- '2.6'
- '2.7'
- '3.4'
- '3.5'
Expand All @@ -18,19 +17,16 @@ before_install:
- pip install pycodestyle
install:
- pip install codecov
- if [[ "$TRAVIS_PYTHON_VERSION" == 2.6* ]]; then travis_retry pip install unittest2; fi
- if [[ "$TRAVIS_PYTHON_VERSION" == 2.6* ]]; then travis_retry pip uninstall -y pbr; fi
- if [[ "$TRAVIS_PYTHON_VERSION" == "3.2" ]]; then travis_retry pip install coverage==3.7.1; fi
- if [[ "$TRAVIS_PYTHON_VERSION" != "3.2" ]]; then travis_retry pip install coverage; fi
- travis_retry pip install coverage
- python setup.py install
- pip install codecov
script:
- if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then coverage run -m unittest2 discover; else coverage run -m unittest discover; fi
- coverage run -m unittest discover
after_script:
- codecov
# Run pycodestyle
- pycodestyle
- if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then unit2 discover; else python -m unittest discover; fi
- python -m unittest discover
- coverage run tests/test_unit.py
notifications:
hipchat:
Expand Down
17 changes: 4 additions & 13 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ A software bug is a demonstrable issue in the code base. In order for us to diag

Before you decide to create a new issue, please try the following:

1. Check the Github issues tab if the identified issue has already been reported, if so, please add a +1 to the existing post.
1. Check the GitHub issues tab if the identified issue has already been reported, if so, please add a +1 to the existing post.
2. Update to the latest version of this code and check if issue has already been fixed
3. Copy and fill in the Bug Report Template we have provided below

Expand All @@ -66,7 +66,7 @@ We welcome direct contributions to the python-http-client code base. Thank you!

##### Prerequisites #####

- Python 2.6, 2.7 or 3.3+
- Python 2.7 and 3.4+
- There are no external dependencies

##### Initial setup: #####
Expand Down Expand Up @@ -112,14 +112,6 @@ All test files are in the [`tests`](https://github.com/sendgrid/python-http-clie

For the purposes of contributing to this repo, please update the [`test_unit.py`](https://github.com/sendgrid/python-http-client/blob/master/test/test_unit.py) file with unit tests as you modify the code.

For Python 2.6.*:

```bash
unit2 discover -v
```

For Python 2.7.* and up:

```bash
python -m unittest discover -v
```
Expand All @@ -141,13 +133,12 @@ The above local "Initial setup" is complete
Add `eval "$(pyenv init -)"` to your shell environment (.profile, .bashrc, etc) after installing tox, you only need to do this once.

```bash
pyenv install 2.6.9
pyenv install 2.7.11
pyenv install 3.4.3
pyenv install 3.5.2
pyenv install 3.6.0
python setup.py install
pyenv local 3.6.0 3.5.2 3.4.3 2.7.8 2.6.9
pyenv local 3.6.0 3.5.2 3.4.3 2.7.8
pyenv rehash
```

Expand Down Expand Up @@ -229,4 +220,4 @@ If you have any additional questions, please feel free to [email](mailto:dx@send

<a name="code-reviews"></a>
## Code Reviews
If you can, please look at open PRs and review them. Give feedback and help us merge these PRs much faster! If you don't know how, Github has some great [information on how to review a Pull Request](https://help.github.com/articles/about-pull-request-reviews/).
If you can, please look at open PRs and review them. Give feedback and help us merge these PRs much faster! If you don't know how, GitHub has some great [information on how to review a Pull Request](https://help.github.com/articles/about-pull-request-reviews/).
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM ubuntu:xenial
ENV PYTHON_VERSIONS='python2.6 python2.7 python3.4 python3.5 python3.6 python3.7' \
ENV PYTHON_VERSIONS='python2.7 python3.4 python3.5 python3.6 python3.7' \
OAI_SPEC_URL="https://raw.githubusercontent.com/sendgrid/sendgrid-oai/master/oai_stoplight.json"

# install testing versions of python, including old versions, from deadsnakes
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ If you are looking for the SendGrid API client library, please see [this repo](h

## Prerequisites

- Python version 2.6, 2.7, 3.4, 3.5 or 3.6
- Python version 2.7 or 3.4+

## Install Package

Expand Down
2 changes: 1 addition & 1 deletion examples/live_sendgrid_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
host = "https://api.sendgrid.com"
api_key = os.environ.get('SENDGRID_API_KEY')
request_headers = {
"Authorization": 'Bearer {0}'.format(api_key)
"Authorization": 'Bearer {}'.format(api_key)
}
version = 3 # we could also use client.version(3)
client = python_http_client.Client(host=host,
Expand Down
6 changes: 3 additions & 3 deletions python_http_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def _build_versioned_url(self, url):
:type url: string
:return: string
"""
return '{0}/v{1}{2}'.format(self.host, str(self._version), url)
return '{}/v{}{}'.format(self.host, str(self._version), url)

def _build_url(self, query_params):
"""Build the final URL to be passed to urllib
Expand All @@ -114,7 +114,7 @@ def _build_url(self, query_params):
url = ''
count = 0
while count < len(self._url_path):
url += '/{0}'.format(self._url_path[count])
url += '/{}'.format(self._url_path[count])
count += 1

# add slash
Expand All @@ -123,7 +123,7 @@ def _build_url(self, query_params):

if query_params:
url_values = urlencode(sorted(query_params.items()), True)
url = '{0}?{1}'.format(url, url_values)
url = '{}?{}'.format(url, url_values)

if self._version:
url = self._build_versioned_url(url)
Expand Down
18 changes: 4 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import sys
import os
from setuptools import setup

Expand All @@ -8,36 +7,27 @@
long_description = open('README.txt').read()


def get_requires():
deps = []
if (2, 6) <= sys.version_info < (2, 7):
deps.append('unittest2')
return deps


base_url = 'https://github.com/sendgrid/'
version = '3.1.0'
setup(
name='python_http_client',
version=version,
author='Elmer Thomas',
author_email='[email protected]',
url='{0}python-http-client'.format(base_url),
download_url='{0}python-http-client/tarball/{1}'.format(base_url, version),
url='{}python-http-client'.format(base_url),
download_url='{}python-http-client/tarball/{}'.format(base_url, version),
packages=['python_http_client'],
license='MIT',
description='HTTP REST client, simplified for Python',
long_description=long_description,
install_requires=get_requires(),
keywords=[
'REST',
'HTTP',
'API'],
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
classifiers=[
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6'
Expand Down
8 changes: 4 additions & 4 deletions tests/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,13 @@ def run_tested_code(client, num_loops):

@timefunc
def dynamic_version():
local_path = '{0}/..'.format(os.path.abspath(os.path.dirname(__file__)))
local_path = '{}/..'.format(os.path.abspath(os.path.dirname(__file__)))
Config(local_path)
api_key = os.environ.get('SENDGRID_API_KEY')
request_headers = {
'X-Mock': 200,
'Content-Type': 'application/json',
'Authorization': 'Bearer {0}'.format(api_key)
'Authorization': 'Bearer {}'.format(api_key)
}
client = Client(host=os.environ.get('LOCAL_HOST'),
request_headers=request_headers,
Expand All @@ -147,13 +147,13 @@ def dynamic_version():

@timefunc
def static_version():
local_path = '{0}/..'.format(os.path.abspath(os.path.dirname(__file__)))
local_path = '{}/..'.format(os.path.abspath(os.path.dirname(__file__)))
Config(local_path)
api_key = os.environ.get('SENDGRID_API_KEY')
request_headers = {
'X-Mock': 200,
'Content-Type': 'application/json',
'Authorization': 'Bearer {0}'.format(api_key)
'Authorization': 'Bearer {}'.format(api_key)
}
client = StaticClient(host=os.environ.get('LOCAL_HOST'),
request_headers=request_headers,
Expand Down
9 changes: 2 additions & 7 deletions tests/test_daterange.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import os
import time

try:
import unittest2 as unittest
except ImportError:
import unittest
import unittest


class DateRangeTest(unittest.TestCase):
Expand All @@ -19,5 +15,4 @@ def setUp(self):
fh.close()

def test__daterange(self):
self.assertTrue(self.pattern in self.licensefile)

self.assertIn(self.pattern, self.licensefile)
9 changes: 3 additions & 6 deletions tests/test_repofiles.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import unittest
from os import path
try:
import unittest2 as unittest
except ImportError:
import unittest


class RepoFiles(unittest.TestCase):
Expand Down Expand Up @@ -34,5 +31,5 @@ def _all_file(self, files):

def test_file_existence(self):
missing = list(filter(self._all_file, self.FILES))
self.assertTrue(len(missing) == 0,
"Files %s aren't found" % str(missing))
self.assertEqual(len(missing), 0,
"Files %s aren't found" % str(missing))
13 changes: 5 additions & 8 deletions tests/test_unit.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import pickle
import unittest

try:
import unittest2 as unittest
except ImportError:
import unittest
from python_http_client.client import Client
from python_http_client.exceptions import (
handle_error,
Expand Down Expand Up @@ -86,7 +83,7 @@ def test__init__(self):
self.assertIs(default_client.timeout, None)
methods = ['delete', 'get', 'patch', 'post', 'put']
self.assertEqual(default_client.methods, methods)
self.assertEqual(default_client._version, None)
self.assertIsNone(default_client._version)
self.assertEqual(default_client._url_path, [])

request_headers = {'X-Test': 'test', 'X-Test2': 1}
Expand All @@ -106,15 +103,15 @@ def test__init__(self):
def test__build_versioned_url(self):
url = '/api_keys?hello=1&world=2'
versioned_url = self.client._build_versioned_url(url)
url = '{0}/v{1}{2}'.format(self.host, str(self.client._version), url)
url = '{}/v{}{}'.format(self.host, str(self.client._version), url)
self.assertEqual(versioned_url, url)

def test__build_url(self):
self.client._url_path = self.client._url_path + ['here']
self.client._url_path = self.client._url_path + ['there']
self.client._url_path = self.client._url_path + [1]
self.client._version = 3
url = '{0}/v{1}{2}'.format(
url = '{}/v{}{}'.format(
self.host,
str(self.client._version),
'/here/there/1?hello=0&world=1&ztest=0&ztest=1'
Expand All @@ -126,7 +123,7 @@ def test__build_url(self):
def test__update_headers(self):
request_headers = {'X-Test': 'Test'}
self.client._update_headers(request_headers)
self.assertTrue('X-Test' in self.client.request_headers)
self.assertIn('X-Test', self.client.request_headers)
self.client.request_headers.pop('X-Test', None)

def test__build_client(self):
Expand Down
17 changes: 1 addition & 16 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,17 @@
# and then run "tox" from this directory.

[tox]
envlist = py26, py27, py32, py33, py34, py35, py36, py37
envlist = py27, py34, py35, py36, py37

[testenv]
commands = {envbindir}/python -m unittest discover -v []
deps =

[testenv:py26]
commands = {envbindir}/unit2 discover -v []
deps =
basepython = python2.6

[testenv:py27]
commands = {envbindir}/python -m unittest discover -v []
deps =
basepython = python2.7

[testenv:py32]
commands = {envbindir}/python -m unittest discover -v []
deps =
basepython = python3.2

[testenv:py33]
commands = {envbindir}/python -m unittest discover -v []
deps =
basepython = python3.3

[testenv:py34]
commands = {envbindir}/python -m unittest discover -v []
deps =
Expand Down