예제 #1
0
 def test_create_user_key_return(self):
     '''
     Test create_user_key method - return
     '''
     mock_hana_inst = MagicMock()
     mock_hana = MagicMock(return_value=mock_hana_inst)
     with patch.object(hanamod, '_init', mock_hana):
         hanamod.create_user_key('key', 'env', 'user', 'pass', 'db', 'prd',
                                 '00', 'pass')
         mock_hana.assert_called_once_with('prd', '00', 'pass')
         mock_hana_inst.create_user_key.assert_called_once_with(
             'key', 'env', 'user', 'pass', 'db')
예제 #2
0
 def test_create_user_key_raise(self):
     '''
     Test create_user_key method - raise
     '''
     mock_hana_inst = MagicMock()
     mock_hana_inst.create_user_key.side_effect = hanamod.hana.HanaError(
         'hana error')
     mock_hana = MagicMock(return_value=mock_hana_inst)
     with patch.object(hanamod, '_init', mock_hana):
         with pytest.raises(exceptions.CommandExecutionError) as err:
             hanamod.create_user_key('key', 'env', 'user', 'pass', 'db',
                                     'prd', '00', 'pass')
         mock_hana.assert_called_once_with('prd', '00', 'pass')
         mock_hana_inst.create_user_key.assert_called_once_with(
             'key', 'env', 'user', 'pass', 'db')
         assert 'hana error' in str(err)