unit test for new_typed_build
This commit is contained in:
parent
c58b7c2ea9
commit
1d215e6355
1 changed files with 39 additions and 0 deletions
39
tests/test_hub/test_new_typed_build.py
Normal file
39
tests/test_hub/test_new_typed_build.py
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
import unittest
|
||||
import mock
|
||||
|
||||
import koji
|
||||
import kojihub
|
||||
|
||||
|
||||
class TestNewTypedBuild(unittest.TestCase):
|
||||
|
||||
@mock.patch('kojihub.lookup_name')
|
||||
@mock.patch('kojihub.QueryProcessor')
|
||||
@mock.patch('kojihub.InsertProcessor')
|
||||
def test_new_typed_build(self, InsertProcessor, QueryProcessor, lookup_name):
|
||||
|
||||
binfo = {'id': 1, 'foo': '137'}
|
||||
btype = 'sometype'
|
||||
btype_id = 99
|
||||
lookup_name.return_value = {'id':99, 'name':btype}
|
||||
|
||||
# no current entry
|
||||
query = QueryProcessor.return_value
|
||||
query.executeOne.return_value = None
|
||||
insert = InsertProcessor.return_value
|
||||
kojihub.new_typed_build(binfo, btype)
|
||||
QueryProcessor.assert_called_once()
|
||||
query.executeOne.assert_called_once()
|
||||
InsertProcessor.assert_called_once()
|
||||
insert.execute.assert_called_once()
|
||||
|
||||
InsertProcessor.reset_mock()
|
||||
QueryProcessor.reset_mock()
|
||||
|
||||
# current entry
|
||||
query = QueryProcessor.return_value
|
||||
query.executeOne.return_value = {'build_id':binfo['id']}
|
||||
kojihub.new_typed_build(binfo, btype)
|
||||
QueryProcessor.assert_called_once()
|
||||
query.executeOne.assert_called_once()
|
||||
InsertProcessor.assert_not_called()
|
||||
Loading…
Add table
Add a link
Reference in a new issue