def test_update_member_exception(self, mock_gpm_list, mock_db, mock_print): mock_gpm_list.side_effect = Exception gpm = GPM() gpm.update_members() mock_print.assert_called_once() mock_gpm_list.assert_called_once() mock_db().rollback_data.assert_called_once()
def test_update_gpm_back(self, mock_gpm_list, mock_menu, mock_input): mock_gpm_list.return_value = {'name1': 'id1'} mock_menu().draw_menu.side_effect = ['BACK'] gpm = GPM() gpm.update_members() mock_input.assert_called_once() mock_menu().draw_menu.assert_called_once() mock_gpm_list.assert_called_once()
def test_update_member_invalid_age(self, mock_input, mock_gpm_list, mock_validation, mock_print, mock_menu): mock_gpm_list.return_value = {'name1': 'id1', 'name2': 'id2'} mock_menu().draw_menu.side_effect = ['name1', 'AGE'] mock_validation.age.return_value = False mock_input.side_effect = ['', '', 'dummy_data', ''] gpm = GPM() gpm.update_members() self.assertEqual(mock_menu().draw_menu.call_count, 2) self.assertEqual(mock_print.call_count, 2) mock_gpm_list.assert_called_once() self.assertEqual(mock_input.call_count, 4) mock_validation.age.assert_called_once_with('dummy_data')
def test_update_member_user_details(self, mock_db, mock_input, mock_gpm_list, mock_print, mock_menu, mock_encrypt): mock_gpm_list.return_value = {'name1': 'id1', 'name2': 'id2'} mock_menu().draw_menu.side_effect = ['name1', 'PASSWORD'] mock_encrypt.return_value = 'Pass@123' mock_input.side_effect = ['', '', 'Pass@123'] gpm = GPM() gpm.update_members() self.assertEqual(mock_menu().draw_menu.call_count, 2) self.assertEqual(mock_print.call_count, 2) mock_gpm_list.assert_called_once() self.assertEqual(mock_input.call_count, 3) mock_db().update_user.assert_called_once_with('PASSWORD', mock.ANY, 'Pass@123') mock_db().commit_data.assert_called_once()
def test_update_member_personal_detail(self, mock_db, mock_input, mock_gpm_list, mock_validation, mock_print, mock_menu): mock_gpm_list.return_value = {'name1': 'id1', 'name2': 'id2'} mock_menu().draw_menu.side_effect = ['name1', 'AGE'] mock_validation.age.return_value = True mock_input.side_effect = ['', '', '21'] gpm = GPM() gpm.update_members() self.assertEqual(mock_menu().draw_menu.call_count, 2) self.assertEqual(mock_print.call_count, 2) mock_gpm_list.assert_called_once() mock_validation.age.assert_called_once() self.assertEqual(mock_input.call_count, 3) mock_db().update_personal_details.assert_called_once_with( 'AGE', mock.ANY, '21') mock_db().commit_data.assert_called_once()