Skip to content

Commit

Permalink
Only do coverage for unit test.
Browse files Browse the repository at this point in the history
Also install python-coveralls and a minor fix for the forwarder test.
  • Loading branch information
alexkiro committed Jul 1, 2014
1 parent d784b29 commit b9b0faa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
7 changes: 3 additions & 4 deletions scripts/run_tests
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -evx

pip install pytest pytest-cov
pip install pytest pytest-cov python-coveralls

if [ `python -c 'import sys; print(sys.version_info[0])'` = '3' ]
then
Expand All @@ -16,8 +16,7 @@ else
mysql -e 'create database pyzor_test'
fi

#XXX There is little point in running coverage on functional tests
py.test tests/ --cov coveralls --cov-report term-missing

py.test tests/unit/ --cov coveralls --cov-report term-missing
py.test tests/functional/


19 changes: 9 additions & 10 deletions tests/functional/test_forwarder.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,23 @@ def setUp(self):
self.remote_pyzord_proc = subprocess.Popen(args)
time.sleep(0.3)

def tearDown(self):
redis.StrictRedis(db=9).flushdb()
redis.StrictRedis(db=10).flushdb()

def test_forward_report(self):
# submit hash to local server
self.check_pyzor("report", self.localserver.homedir)

# make sure the local submission worked
self.check_pyzor("check", self.localserver.homedir, counts=(1, 0), msg='local insert failed')
self.check_pyzor("check", self.localserver.homedir, counts=(1, 0))

# now use the forwarding client's config to check forwarded submission
time.sleep(1)
self.check_pyzor("check", self.fwdclient.homedir, counts=(1, 0), msg='forwarding failed')
self.check_pyzor("check", self.fwdclient.homedir, counts=(1, 0))

# submit the hash to the remote system, the count should go up
self.check_pyzor("report", self.fwdclient.homedir)
self.check_pyzor("check", self.fwdclient.homedir, counts=(2, 0), msg='submit to remote failed')
self.check_pyzor("check", self.fwdclient.homedir, counts=(2, 0))

# switch back to our local server, the count should still be the old value
self.check_pyzor("check", self.localserver.homedir, counts=(1, 0), msg='local count is wrong')
self.check_pyzor("check", self.localserver.homedir, counts=(1, 0))

def tearDown(self):
if self.remote_pyzord_proc != None:
Expand All @@ -71,9 +67,12 @@ def tearDown(self):
shutil.rmtree(self.fwdclient.homedir, True)
shutil.rmtree(self.remoteserver.homedir, True)

redis.StrictRedis(db=9).flushdb()
redis.StrictRedis(db=10).flushdb()

def check_pyzor(self, cmd, homedir, counts=None, msg=None):
"""simplified check_pyzor version from PyzorTestBase"""
msg = "forwarding makes the world go round!"
msg = "This is a test message for the forwading feature"
args = ["pyzor", '--homedir', homedir, cmd]
pyzor = subprocess.Popen(args,
stdin=subprocess.PIPE,
Expand All @@ -95,7 +94,7 @@ def check_pyzor(self, cmd, homedir, counts=None, msg=None):
self.assertEqual(status[0], 200, status)

if counts:
self.assertEqual(counts, (int(results[2]), int(results[3])), msg)
self.assertEqual(counts, (int(results[2]), int(results[3])))
return stdout

def suite():
Expand Down

0 comments on commit b9b0faa

Please sign in to comment.