"""Model Tests for Supply Chain Defaults.""" from unittest.mock import MagicMock from unittest.mock import patch from sqlalchemy.exc import SQLAlchemyError from tests.testutils import db from product_configuration.models import supply_chain_defaults @db.test_schema def test_get_all_defaults(supply_chain_default_value): """Test successful retrieval and mapping of supply_chain_defaults.""" db.insert_supply_chain_defaults_data() result = supply_chain_defaults.get_all_defaults() assert result == supply_chain_default_value @patch('product_configuration.connectors.mysql._db_session') def test_get_all_defaults_db_failure( db_session, sentry_sdk_capture_exception_mock): """Test fatal db error when retrieving mapping of supply_chain_defaults.""" session = MagicMock() session.query = MagicMock(side_effect=SQLAlchemyError()) db_session.return_value = session response = supply_chain_defaults.get_all_defaults() assert response.status == 500 sentry_sdk_capture_exception_mock.assert_called_once()