tflink/mock_fedorainfra — Issue #3: runtests.sh fail when run second time
Author: kparal
Created: 2011-11-24 11:08:27+00:00
State: open

When /tmp/boji.db already exists and I have already run tests, another execution of test suite fails. The tests should probably use a separate database file.

[root@aqd mock_fedorainfra]# ./runtests.sh
Virtualenv (env_flask) detected.
================================================================================= test session starts =================================================================================
platform linux2 -- Python 2.7.2 -- pytest-2.2.0
collected 6 items

testing/testfunc_bodhi.py FF
testing/testfunc_koji_xmlrpc.py ....

====================================================================================== FAILURES =======================================================================================
___________________________________________________________________________ TestFuncBodhi.test_get_comment ____________________________________________________________________________

self = , monkeypatch = <_pytest.monkeypatch.monkeypatch instance at 0x2a06518>

def test_get_comment(self, monkeypatch):
self.ref_query = util.make_default_update()

monkeypatch.setattr(mock_fedorainfra.boji, 'get_bodhi_connection', get_mock_bodhi)
monkeypatch.setattr(mock_fedorainfra.database, 'db_url', 'file://%s' % self.db_fd)

test_result = self.app.post('/bodhi/list', data={'package':'foo', 'limit':10})

test_comments = json.loads(test_result.data)['updates'][0]['comments']
> assert len(test_comments) == 0
E assert 4 == 0
E + where 4 = len([{u'anonymous': False, u'author': u'nobody', u'group': None, u'karma': 0, ...}, {u'anonymous': False, u'author': u'nob...ody', u'group': None, u'karma': 0, ...}, {u'anonymous': False, u'author': u'nobody', u'group': None, u'karma': 0, ...}])

testing/testfunc_bodhi.py:66: AssertionError
----------------------------------------------------------------------------------- Captured stdout -----------------------------------------------------------------------------------
tempfiledb: /tmp/tmp5Fs0Zi
___________________________________________________________________________ TestFuncBodhi.test_make_comment ___________________________________________________________________________

self = , monkeypatch = <_pytest.monkeypatch.monkeypatch instance at 0x2b0ba70>

def test_make_comment(self, monkeypatch):
ref_user = 'nobody'
ref_title = 'nothing-1.2.3-4.fc99'
ref_comment = 'this is a random comment'

monkeypatch.setattr(mock_fedorainfra.boji, 'get_bodhi_connection', get_mock_bodhi)
monkeypatch.setattr(mock_fedorainfra.database, 'db_url', 'file://%s' % self.db_fd)

test_result = self.app.post('/bodhi/comment', data={'title':ref_title, 'text': ref_comment, 'user_name': ref_user, 'karma':0, 'email': 'False', 'password': 'password' })

test_comments = json.loads(self.app.post('/bodhi/list', data={'package': ref_title, 'limit':10}).data)['updates']

assert len(test_comments) == 1
> assert len(test_comments[0]['comments']) == 1
E assert 5 == 1
E + where 5 = len([{u'anonymous': False, u'author': u'nobody', u'group': None, u'karma': 0, ...}, {u'anonymous': False, u'author': u'nob...ody', u'group': None, u'karma': 0, ...}, {u'anonymous': False, u'author': u'nobody', u'group': None, u'karma': 0, ...}])

testing/testfunc_bodhi.py:81: AssertionError
----------------------------------------------------------------------------------- Captured stdout -----------------------------------------------------------------------------------
tempfiledb: /tmp/tmpH8Ckca
========================================================================= 2 failed, 4 passed in 0.39 seconds ==========================================================================