"""Create persistent changes for the test environment. The goal of those changes is to be able to test mechanisms without touching specific parts of our architecture. For instance: tests should be running against a database – but this database does not have to be our live database, it should be a 'in memory' db. """ from unittest.mock import MagicMock, patch import pytest from owsrequest import request from grass import api, config def pytest_runtest_setup(): """Setup before each test.""" config.environment = config.TEST_ENVIRONMENT request.create_authorization = MagicMock() @pytest.fixture(autouse=True) def mock_datadog_globals(): """Mock Datadog API for all tests.""" with patch('grass.connectors.datadog.api') as mock_api, patch( 'grass.connectors.datadog.initialize' ) as mock_init: yield @pytest.fixture def app(): """Get the application. Returns: TornadoWeb: Grass's application. """ return api.app