From 3411d5f8066bf722e4de962dd212ca4be43184f9 Mon Sep 17 00:00:00 2001 From: Alvie Zhang Date: Wed, 26 Feb 2020 14:24:59 +0800 Subject: [PATCH 1/2] Prepare release --- .travis.yml | 2 +- MANIFEST.in | 2 +- Makefile | 10 +++++++--- requirements-dev.txt | 11 +++++++++++ requirements.txt | 9 --------- setup.py | 6 +++++- tox.ini | 6 ------ 7 files changed, 25 insertions(+), 21 deletions(-) create mode 100644 requirements-dev.txt delete mode 100644 tox.ini diff --git a/.travis.yml b/.travis.yml index 06f056d..e305195 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ python: - "pypy3" install: - - pip install -r requirements.txt + - pip install -r requirements-dev.txt - pip install . script: diff --git a/MANIFEST.in b/MANIFEST.in index 229c32d..917f1f6 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1,2 @@ include README.rst LICENSE VERSION requirements.txt -recursive-include tests *.py +recursive-include aftership diff --git a/Makefile b/Makefile index 69e2960..00a2c29 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,9 @@ install: test: py.test +record: + py.test --vcr-record=new_episodes + flake8: flake8 @@ -13,8 +16,9 @@ docs: cd docs && make html @echo "\033[95m\n\nBuild successful! View the docs homepage at docs/_build/html/index.html.\n\033[0m" +build: + python setup.py sdist --formats=gztar,zip + clean: -rm -r docs/_build - -record: - py.test --vcr-record=new_episodes + -rm -r build dist aftership.egg-info diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..aa8dec5 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,11 @@ +-r requirements.txt + +# For packaging +wheel +setuptools + +# For testing +flake8 +pytest +pytest-cov +pytest-vcr diff --git a/requirements.txt b/requirements.txt index 6b217c1..f229360 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,10 +1 @@ -wheel -setuptools - requests - -# For testing -flake8 -pytest -pytest-cov -pytest-vcr diff --git a/setup.py b/setup.py index cc1ea55..2caeea3 100644 --- a/setup.py +++ b/setup.py @@ -12,6 +12,10 @@ with open(path.join(here, 'VERSION'), encoding='utf-8') as f: version = f.read() +with open(path.join(here, 'requirements.txt'), encoding='utf-8') as f: + install_requires = f.read().split('\n') + + setup( name='aftership', @@ -68,5 +72,5 @@ # You can just specify the packages manually here if your project is # simple. Or you can use find_packages(). packages=['aftership'], - install_requires=[], + install_requires=install_requires, ) diff --git a/tox.ini b/tox.ini deleted file mode 100644 index b499add..0000000 --- a/tox.ini +++ /dev/null @@ -1,6 +0,0 @@ -[tox] -envlist = py35,py36,py37,py38 - -[testenv] -deps = -rrequirements.txt -commands = py.test -v --capture=sys From 7893c77d03ced853bd2fa1dc7f07ec1ac9448f19 Mon Sep 17 00:00:00 2001 From: Alvie Zhang Date: Wed, 26 Feb 2020 14:51:44 +0800 Subject: [PATCH 2/2] Update test script --- .travis.yml | 7 +- Makefile | 8 +- aftership/__init__.py | 2 +- requirements-dev.txt | 2 - setup.cfg | 4 +- setup.py | 19 ++--- tests/conftest.py | 2 +- .../TrackingTestCase.test_list_trackings.yaml | 73 +++++++++++++++++++ 8 files changed, 96 insertions(+), 21 deletions(-) diff --git a/.travis.yml b/.travis.yml index e305195..ff56f0f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,6 @@ language: python +install: "make" + python: - "3.5" - "3.6" @@ -7,8 +9,7 @@ python: - "pypy3" install: - - pip install -r requirements-dev.txt - - pip install . + - make install script: - - py.test -v --capture=sys + - make test diff --git a/Makefile b/Makefile index 00a2c29..3fd432f 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,14 @@ .PHONY: docs clean install: - pip install -r requirements.txt + pip install --upgrade . + pip install -r requirements-dev.txt test: - py.test + cd tests && py.test record: - py.test --vcr-record=new_episodes + cd tests && py.test --vcr-record=new_episodes flake8: flake8 @@ -18,6 +19,7 @@ docs: build: python setup.py sdist --formats=gztar,zip + python setup.py sdist bdist_wheel clean: -rm -r docs/_build diff --git a/aftership/__init__.py b/aftership/__init__.py index 2c9807c..8aaac57 100644 --- a/aftership/__init__.py +++ b/aftership/__init__.py @@ -4,7 +4,7 @@ with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), '../VERSION')) as f: - __version__ = f.read() + __version__ = f.read().strip() api_key = None diff --git a/requirements-dev.txt b/requirements-dev.txt index aa8dec5..d9d554c 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,5 +1,3 @@ --r requirements.txt - # For packaging wheel setuptools diff --git a/setup.cfg b/setup.cfg index 60bd34d..60162cd 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bdist_wheel] -universal = 1 +universal = 0 [metadata] -license_file = LICENSE \ No newline at end of file +license_file = LICENSE diff --git a/setup.py b/setup.py index 2caeea3..a515def 100644 --- a/setup.py +++ b/setup.py @@ -1,28 +1,29 @@ +import os from codecs import open # To use a consistent encoding -from os import path from setuptools import setup -here = path.abspath(path.dirname(__file__)) +here = os.path.abspath(os.path.dirname(__file__)) # Get the long description from the relevant file -with open(path.join(here, 'README.rst'), encoding='utf-8') as f: +with open(os.path.join(here, 'README.rst'), encoding='utf-8') as f: long_description = f.read() -with open(path.join(here, 'VERSION'), encoding='utf-8') as f: - version = f.read() - -with open(path.join(here, 'requirements.txt'), encoding='utf-8') as f: +with open(os.path.join(here, 'requirements.txt'), encoding='utf-8') as f: install_requires = f.read().split('\n') +with open(os.path.join(here, 'VERSION'), encoding='utf-8') as f: + __version__ = f.read().strip() setup( name='aftership', + python_requires='>3.5.0', + # Versions should comply with PEP440. For a discussion on single-sourcing # the version across setup.py and the project code, see # http://packaging.python.org/en/latest/tutorial.html#version - version=version, + version=__version__, description='Python SDK of AfterShip API', long_description=long_description, @@ -31,7 +32,7 @@ url='https://github.com/AfterShip/aftership-python', # Download path - download_url='https://github.com/AfterShip/aftership-python/tarball/{}'.format(version), + download_url='https://github.com/AfterShip/aftership-python/tarball/{}'.format(__version__), # Author details author='AfterShip', diff --git a/tests/conftest.py b/tests/conftest.py index 2410ff6..64bc1aa 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -4,7 +4,7 @@ @pytest.fixture(scope='session') def vcr_config(): return { - 'cassette_library_dir': 'tests/fixtures/cassettes', + 'cassette_library_dir': 'fixtures/cassettes', 'serializer': 'yaml', 'filter_headers': [('aftership-api-key', 'YOUR_API_KEY_IS_HERE')], 'record_mode': 'none', diff --git a/tests/fixtures/cassettes/TrackingTestCase.test_list_trackings.yaml b/tests/fixtures/cassettes/TrackingTestCase.test_list_trackings.yaml index e56e8f5..f61ade4 100644 --- a/tests/fixtures/cassettes/TrackingTestCase.test_list_trackings.yaml +++ b/tests/fixtures/cassettes/TrackingTestCase.test_list_trackings.yaml @@ -72,4 +72,77 @@ interactions: status: code: 200 message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - python-requests/2.23.0 + aftership-api-key: + - YOUR_API_KEY_IS_HERE + method: GET + uri: https://api.aftership.com/v4/trackings?slug=4px&limit=1 + response: + body: + string: !!binary | + H4sIAAAAAAAAA4VUy27bMBD8F15rA5RcO7G+IMceegsCgqbWMiu+ykdjw/C/d/W0ZLkpoAM1uyRn + Z2d5JRoiJ8WVCFsCKXJKbytS8g5zvEIsWxEltYztSthkcJXvt3S/W5EaLp/Wl6QgZEWCShWuvrsz + /lgvK2lI8f6B50GI0vAobQ9EXnVbjhJUGbq18MAjlIxHppudJKfZfp1l6/z1J90U2x1+3ygtKH1I + 5uc2Oadrmq/z3TJZ8RBZcmW/gxQmKbUiHmLyhkXLApgSfMcNK/QSPJuQZm3V/sJksJu+As9FLU2F + 3N+vRDYKOE1hczydf202oqxf8gDRXWi+nbF9yjQbmU5Jfpm4KOnL7IEtM0kfmkLJ21u2z3f0NXt5 + bBwXUf7BtkefAP9M6W1TXitNCtFqNjStU7EDUTDDNQxgCQoPQcWinIL/UrQ/6b/Kd3mguVShowRn + B6LRYLhxSJK2zzA2jgzQqnh+U878nzkeT3ewce7Tm8NJOg0mYr6ocThYPw6PUSnq5FjTnEVsVOZp + NF7cEvwEWZ2Wt3QwS0beY7IyqMVhVCHoAL0OAdUVeDjhTpJhBH+g8dEXjQfSYQYxSrMRZhpCaB+D + yY4oo4JHK7VOQwq9MLR3qpYK2OjCkJyzHrs20FTcVKk9v/vHmn4n3GBraB6CEpwH0Vi9maUTiNpZ + aeJQWDoE4eUBb52We0enflnO/JGrAIMVnLdahomdZm26u3rSpr7Zyor+gZvBU/eN9XPRyjNO40N4 + bsBF+Ml4LHLwXV5gzobIFese+odYY6pZqfdIHNHbx+32FyJiU6ExBgAA + headers: + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Allow-Headers: + - Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,aftership-api-key + Access-Control-Allow-Methods: + - GET,OPTIONS + Access-Control-Allow-Origin: + - '*' + Cache-Control: + - no-store, no-cache, must-revalidate, proxy-revalidate + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 26 Feb 2020 03:56:56 GMT + Expires: + - '0' + Pragma: + - no-cache + Server: + - nginx + Surrogate-Control: + - no-store + Vary: + - Accept-Encoding + X-RateLimit-Limit: + - '10000' + X-RateLimit-Remaining: + - '9992' + X-RateLimit-Reset: + - '1582689439' + X-Response-Time: + - 244.104ms + p3p: + - 'CP="AfterShip does not have a P3P policy. Learn why here: https://www.aftership.com/p3p"' + transfer-encoding: + - chunked + status: + code: 200 + message: OK version: 1