Skip to content

Commit

Permalink
Fix failing tests, run tests with tox
Browse files Browse the repository at this point in the history
  • Loading branch information
brondsem committed Jul 10, 2019
1 parent 074b483 commit b561488
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ build
example/.switches
*.log
.venv
geckodriver.log
server.pid
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
language: python
python: 2.7

addons:
firefox: "latest"
Expand All @@ -9,11 +10,12 @@ before_install:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- sleep 3 # give xvfb some time to start
- pip install codecov
- npm install -g geckodriver

install: make install

script: make test-coverage functional-test

after_success: codecov
after_success:
- pip install codecov
- codecov
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ install:
pip install -r requirements.txt

test:
nosetests switchboard
tox

functional-test:
python example/server.py > /dev/null 2>&1 & echo $$! > $(SERVER_PID)
nosetests example/tests.py
nosetests --logging-filter=switchboard example/tests.py
if test -f $(SERVER_PID); then \
kill -9 `cat $(SERVER_PID)` || true; \
rm $(SERVER_PID) || true; \
fi

test-coverage:
nosetests --with-coverage --cover-package=switchboard switchboard
tox -e coverage

release:
git tag $(VERSION)
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ bottle
paste
splinter
selenium>=3.0
tox
2 changes: 1 addition & 1 deletion switchboard/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def inner(self, *args, **kwargs):
dic = self.result_cache
cache_key = None
if dic is not None:
cache_key = (args, tuple(kwargs.items()))
cache_key = (args, tuple(sorted(kwargs.items())))
try:
result = dic.get(cache_key)
except TypeError as e: # not hashable
Expand Down
5 changes: 4 additions & 1 deletion switchboard/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,9 @@ def test_get_status_label_selective_no_conditions(self):

def test_to_dict(self):
switch_dict = self.switch.to_dict(self.manager)
for cond in switch_dict['conditions']:
cond['conditions'].sort()
assert_equals.__self__.maxDiff = None
assert_equals(switch_dict, {
'key': 'test',
'status': DISABLED,
Expand All @@ -539,8 +542,8 @@ def test_to_dict(self):
'label': 'IP Address',
'conditions': [
('ip_address', '10.1.1.1', '10.1.1.1', False),
('ip_address', '192.168.1.1', '192.168.1.1', False),
('ip_address', '127.0.0.1', '127.0.0.1', False),
('ip_address', '192.168.1.1', '192.168.1.1', False),
('percent', '0-50', 'Percent: 50% (0-50)', False),
]
}
Expand Down
10 changes: 8 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@
envlist = py27

[testenv]
commands = nosetests
commands = nosetests {posargs}
deps =
nose
mock
bobo

[testenv:coverage]
deps =
{[testenv]deps}
coverage
commands =
nosetests --with-coverage --cover-package=switchboard

0 comments on commit b561488

Please sign in to comment.