Skip to content
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ install:
script:
- ./itests/install-chronos.sh
- ./itests/start-chronos.sh
- make itests
- make test && make itests
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.PHONY: test
test:
tox

.PHONY: itests
itests:
tox -e itests
23 changes: 23 additions & 0 deletions tests/test_chronos_init.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import json

import mock

import chronos


def test_check_accepts_json():
client = chronos.ChronosClient(hostname="localhost")
fake_response = mock.Mock()
fake_response.status = 200
fake_content = '{ "foo": "bar" }'
actual = client._check(fake_response, fake_content)
assert actual == json.loads(fake_content)


def test_check_returns_raw_response_when_not_json():
client = chronos.ChronosClient(hostname="localhost")
fake_response = mock.Mock()
fake_response.status = 401
fake_content = 'UNAUTHORIZED'
actual = client._check(fake_response, fake_content)
assert actual == fake_content
18 changes: 18 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@ usedevelop=True
basepython = python2.7
envlist = py


[flake8]
max-line-length = 120


[testenv:py]
basepython = python2.7
deps =
-rrequirements.txt
pep8==1.5.7
flake8
pytest
mock
commands =
flake8 chronos tests
py.test -s {posargs:tests}


[testenv:itests]
passenv = TRAVIS
basepython = python2.7
Expand Down