Skip to content

Commit

Permalink
0.3a6
Browse files Browse the repository at this point in the history
  • Loading branch information
andreygrechin committed Mar 4, 2018
1 parent 8419893 commit 0e56202
Show file tree
Hide file tree
Showing 45 changed files with 979 additions and 135 deletions.
24 changes: 24 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[run]
source =
umbr_api

# branch = True

[report]
# Regexes for lines to exclude from consideration
exclude_lines =
# Have to re-enable the standard pragma
pragma: no cover

# Don't complain about missing debug-only code:
def __repr__
if self\.debug

# Don't complain if non-runnable code isn't run:
if __name__ == .__main__.:

ignore_errors = True

[paths]
source =
umbr_api
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ venv/
*.egg-info/
dist/
docs/_build/
.coverage
*.py,cover
.pytest_cache/

customer_key.json
30 changes: 28 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,41 @@
language: python
env:
- DEV=true
python:
- '3.4'
- '3.5'
- '3.6'
- 3.6-dev
- 3.7-dev
matrix:
fast_finish: true
# include:
# - python: '3.4'
# - python: '3.5'
# - python: '3.6'
# - python: '3.6-dev'
# - python: '3.7-dev'
allow_failures:
- python: '3.6-dev'
env: DEV=true
- python: '3.7-dev'
env: DEV=true
install:
- pip install .
- pip install -r requirements.txt
- pip install .[dev]
# branches:
# only:
# - master
# except:
# - develop
before_script:
- pip install coveralls
script:
- pytest
- make test-offline
- coverage run -m pytest -k 'not Online' -q --cache-clear tests/
# - if [[ "$TRAVIS_PYTHON_VERSION" = 3.6 ]]; then coverage run -m pytest -k 'not Online' -q --cache-clear tests/; fi
after_success:
- coveralls
notifications:
email:
on_success: change
Expand Down
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
include LICENSE
include README.rst
include Makefile
include requirements.txt
include requirements_dev.txt
include umbr_api/data/customer_key_example.json
63 changes: 63 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
.PHONY: test
test: clear-all install-dev
pytest -q --cache-clear tests/

.PHONY: test-online
test-online: clear-all install-dev
pytest -k 'Online' -q --cache-clear tests/

.PHONY: test-offline
test-offline: clear-all install-dev
pytest -k 'not Online' -q --cache-clear tests/

.PHONY: install-dev
install-dev:
pip install -q -e .[dev]

.PHONY: coverage-offline
coverage-offline: clear-pyc clear-cov
coverage run -m pytest -k 'not Online' -q --cache-clear tests/
coverage report
coverage annotate

.PHONY: coverage
coverage: clear-pyc clear-cov
coverage run -m pytest
coverage report
coverage annotate

.PHONY: cov
cov: coverage

.PHONY: upload
upload: clear-all built
twine upload dist/*

.PHONY: docs
docs: clear-pyc install-dev
$(MAKE) -C docs html

.PHONY: built
built:
python3 setup.py sdist

.PHONY: clear-all
clear-all: clear-pyc clear-cov clear-build

.PHONY: clear-pyc
clear-pyc:
find . -type d -name '__pycache__' -exec rm -rf {} +
find . -type f -name '*.py[co]' -exec rm -f {} +
find . -type f -name '*~' -exec rm -f {} +

.PHONY: clear-cov
clear-cov:
find . -type f -name '*.py,cover' -exec rm -f {} +
rm -fr .pytest_cache
coverage erase

.PHONY: clear-build
clear-build:
rm -fr docs/_build/
rm -fr dist/
rm -fr *.egg-info
25 changes: 0 additions & 25 deletions build.command

This file was deleted.

21 changes: 0 additions & 21 deletions docs.command

This file was deleted.

2 changes: 2 additions & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
autopep8>=1.3.4
coverage>=4.5.1
pep257>=0.7.0
pycodestyle>=2.3.1
pydocstyle>=2.1.1
pylint>=1.8.2
pytest>=3.4.1
setuptools>=38.5.1
Sphinx>=1.7.1
sphinx_rtd_theme>=0.2.4
Expand Down
17 changes: 17 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,23 @@
'logzero >= 1.3.1',
'keyring >= 11.0.0',
],
extras_require={
'dev': [
"coverage>=4.5.1",
"pytest>=3.4.1",
"setuptools>=38.5.1",
"Sphinx>=1.7.1",
"sphinx_rtd_theme>=0.2.4",
"twine>=1.9.1"
],
'dev_recommended': [
"autopep8>=1.3.4",
"pep257>=0.7.0",
"pycodestyle>=2.3.1",
"pydocstyle>=2.1.1",
"pylint>=1.8.2"
],
},
package_data={
'umbr_api': ['data/customer_key_example.json'],
},
Expand Down
3 changes: 3 additions & 0 deletions tests/data/customer_key_incorrect.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"incorrect_key_in_json": "YOUR-CUSTOMER-KEY-IS-HERE-0123456789"
}
1 change: 1 addition & 0 deletions tests/data/templates/add/case1/body.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id":"6ece47ef,7afc,4a50,89e6-b0a10adc2d8a"}
1 change: 1 addition & 0 deletions tests/data/templates/add/case1/code.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
202
1 change: 1 addition & 0 deletions tests/data/templates/add/case1/headers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{'Server': 'nginx/1.10.1', 'Date': 'Sun, 04 Mar 2018 08:37:24 GMT', 'Content-Type': 'application/json', 'Content-Length': '45', 'Connection': 'keep-alive', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'}
1 change: 1 addition & 0 deletions tests/data/templates/add/case2/body.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"message":"There were one or more missing or required fields","errors":{"dstDomain":"is invalid"},"statusCode":400}
1 change: 1 addition & 0 deletions tests/data/templates/add/case2/code.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
400
1 change: 1 addition & 0 deletions tests/data/templates/add/case2/headers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{'Server': 'nginx/1.10.1', 'Date': 'Sun, 04 Mar 2018 08:51:22 GMT', 'Content-Type': 'application/json', 'Content-Length': '116', 'Connection': 'keep-alive', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'}
1 change: 1 addition & 0 deletions tests/data/templates/get/case1/body.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"meta":{"page":1,"limit":10,"prev":false,"next":false},"data":[{"id":2201,"name":"example.com","lastSeenAt":1520190490},{"id":55522,"name":"www.example.com","lastSeenAt":1520188469}]}
1 change: 1 addition & 0 deletions tests/data/templates/get/case1/code.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
200
1 change: 1 addition & 0 deletions tests/data/templates/get/case1/headers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{'Server': 'nginx/1.10.1', 'Date': 'Sun, 04 Mar 2018 19:09:31 GMT', 'Content-Type': 'application/json', 'Content-Length': '184', 'Connection': 'keep-alive', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains', 'X-Frame-Options': 'SAMEORIGIN', 'X-XSS-Protection': '1; mode=block'}
1 change: 1 addition & 0 deletions tests/data/templates/get/case2/body.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"code":"BadRequestError","message":"Limit must be a number less than or equal to 200","statusCode":400}
1 change: 1 addition & 0 deletions tests/data/templates/get/case2/code.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
400
1 change: 1 addition & 0 deletions tests/data/templates/get/case2/headers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{'Server': 'nginx/1.10.1', 'Date': 'Sun, 04 Mar 2018 18:40:50 GMT', 'Content-Type': 'application/json', 'Content-Length': '104', 'Connection': 'keep-alive', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'}
Empty file.
1 change: 1 addition & 0 deletions tests/data/templates/remove/case1/code.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
204
1 change: 1 addition & 0 deletions tests/data/templates/remove/case1/headers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{'Server': 'nginx/1.10.1', 'Date': 'Sun, 04 Mar 2018 11:03:32 GMT', 'Connection': 'keep-alive', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains', 'X-Frame-Options': 'SAMEORIGIN', 'X-XSS-Protection': '1; mode=block'}
1 change: 1 addition & 0 deletions tests/data/templates/remove/case2/body.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"code":"NotFoundError","message":"Domain not in domain list","statusCode":404}
1 change: 1 addition & 0 deletions tests/data/templates/remove/case2/code.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
404
1 change: 1 addition & 0 deletions tests/data/templates/remove/case2/headers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{'Server': 'nginx/1.10.1', 'Date': 'Sun, 04 Mar 2018 11:05:29 GMT', 'Content-Type': 'application/json', 'Content-Length': '79', 'Connection': 'keep-alive', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'}
23 changes: 23 additions & 0 deletions tests/test_add.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env python3
# pylint: disable=R0201
"""Test unit."""

import unittest


class OnlineTestCase(unittest.TestCase):
"""Main class."""

# def test_default(self):
# """Call get_list() with default args."""
# import umbr_api
# umbr_api.add.add(domain='example.com', url='example.com', key=None)

def test_main(self):
"""Call main."""
from umbr_api.add import main
main()


if __name__ == '__main__':
unittest.main()
23 changes: 23 additions & 0 deletions tests/test_get.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env python3
# pylint: disable=R0201
"""Test unit."""

import unittest


class OnlineTestCase(unittest.TestCase):
"""Main class."""

def test_default(self):
"""Call get_list() with default args."""
import umbr_api
umbr_api.get.get_list()

def test_main(self):
"""Call main."""
import umbr_api
umbr_api.get.main()


if __name__ == '__main__':
unittest.main()
34 changes: 34 additions & 0 deletions tests/test_http_requests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env python3
# pylint: disable=R0201
"""Test unit."""

import unittest


class TestCase(unittest.TestCase):
"""Main class."""

def test_send_post(self):
"""Call incorrect send_post, get None.""" # import requests
from umbr_api._http_requests import send_post

response = send_post(' ')
self.assertEqual(response, None)

def test_send_get(self):
"""Call incorrect send_get, get None.""" # import requests
from umbr_api._http_requests import send_get

response = send_get(' ')
self.assertEqual(response, None)

def test_send_delete(self):
"""Call incorrect send_delete, get None.""" # import requests
from umbr_api._http_requests import send_delete

response = send_delete(' ')
self.assertEqual(response, None)


if __name__ == '__main__':
unittest.main()
7 changes: 6 additions & 1 deletion tests/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@
import unittest


class TestKey(unittest.TestCase):
class TestCase(unittest.TestCase):
"""Main class."""

def test_import_package(self):
"""Import of the package."""
import umbr_api

def test_package_has_version_string(self):
"""Have a __version__ string."""
import umbr_api
self.assertTrue(isinstance(umbr_api.__version__, str))

def test_import_modules(self):
"""Import of modules."""
import umbr_api.add
Expand Down

0 comments on commit 0e56202

Please sign in to comment.