Beispiel #1
0
 def test_create_actions_db_mocked_inputs(self):
     """test run create_actions_db with mocked inputs."""
     from melissa.actions_db import create_actions_db
     mock_con = mock.Mock()
     mock_cur = mock.Mock()
     create_actions_db(mock_con, mock_cur)
     mock_con.commit.assert_called_once_with()
     mock_cur.executescript.assert_called_once_with(self.exec_script_arg)
 def test_create_actions_db_mocked_inputs(self, m_load_profile):
     """test run create_actions_db with mocked inputs."""
     from melissa.actions_db import create_actions_db
     mock_con = mock.Mock()
     mock_cur = mock.Mock()
     create_actions_db(mock_con, mock_cur)
     mock_con.commit.assert_called_once_with()
     mock_cur.executescript.assert_called_once_with(self.exec_script_arg)
Beispiel #3
0
 def test_create_actions_db_raise_sqlite3_error(self):
     """test run create_actions_db and raise sqlite3 error."""
     from melissa.actions_db import create_actions_db
     mock_con = mock.Mock()
     mock_cur = mock.Mock()
     mock_err_msg = 'Error'
     mock_con.commit.side_effect = sqlite3.Error(mock_err_msg)
     with mock.patch('sys.stdout', new_callable=StringIO) as mock_stdout:
         with pytest.raises(SystemExit):
             create_actions_db(mock_con, mock_cur)
         assert 'Error {}:\n'.format(mock_err_msg) in mock_stdout.getvalue()
 def test_create_actions_db_raise_sqlite3_error(self, m_load_profile):
     """test run create_actions_db and raise sqlite3 error."""
     from melissa.actions_db import create_actions_db
     mock_con = mock.Mock()
     mock_cur = mock.Mock()
     mock_err_msg = 'Error'
     mock_con.commit.side_effect = sqlite3.Error(mock_err_msg)
     with mock.patch('sys.stdout', new_callable=StringIO) as mock_stdout:
         with pytest.raises(SystemExit):
             create_actions_db(mock_con, mock_cur)
         assert 'Error {}:\n'.format(mock_err_msg) in mock_stdout.getvalue()