def test_update_object_raises_on_pgerror(self, mock_get_conn): # type: (MagicMock) -> None # Arrange exception = TestPGErrors.TestException() mock_get_conn.return_value.cursor.return_value = cursor = MagicMock() cursor.execute.side_effect = exception # Act with self.assertRaises(DBException): db.update_object('', '', '', '')
def test_update_object_returns_uuid(self, mock_jinja_env, mock_get_conn): # type: (MagicMock, MagicMock) -> None # Arrange uuid = "uuid" # Act actual_result = db.update_object("classname", {}, "note", uuid) # Assert self.assertEqual(uuid, actual_result)
def test_update_object_returns_uuid_on_noop_pgerror(self, mock_get_conn): # type: (MagicMock) -> None # Arrange class_name = 'classname' uuid = '8abdb359-ce8a-47d9-a5d0-c9a1c6d36c44' exception = TestPGErrors.TestException( message='Aborted updating {} with id [{}] as the given data, ' 'does not give raise to a new registration.'.format( class_name.lower(), uuid ) ) mock_get_conn.return_value.cursor.return_value = cursor = MagicMock() cursor.execute.side_effect = exception # Act actual_result = db.update_object(class_name, '', '', uuid) # Assert self.assertEqual(uuid, actual_result)