def check_is_region_launched_in_env(region: Region) -> None: """Checks if direct ingest has been launched for the provided |region| in the current GAE env and throws if it has not.""" if not region.is_ingest_launched_in_env(): gae_env = environment.get_gae_environment() error_msg = f'Bad environment [{gae_env}] for region [{region.region_code}].' logging.error(error_msg) raise DirectIngestError( msg=error_msg, error_type=DirectIngestErrorType.ENVIRONMENT_ERROR)
def fake_region(*, region_code: str = 'us_ca', agency_type: str = 'prison', environment: str = 'local', jurisdiction_id: str = 'unknown', ingestor: Optional[Union[BaseScraper, BaseDirectIngestController]] = None): region = create_autospec(Region) region.region_code = region_code region.agency_type = agency_type region.environment = environment region.jurisdiction_id = jurisdiction_id region.get_ingestor.return_value = \ ingestor if ingestor else create_autospec(BaseDirectIngestController) region.is_ingest_launched_in_env.return_value = \ Region.is_ingest_launched_in_env(region) return region
def fake_region(*, region_code: str = 'us_xx', agency_type: str = 'prison', environment: str = 'local', jurisdiction_id: str = 'unknown', ingestor: Optional[Union[BaseScraper, BaseDirectIngestController]] = None, is_raw_vs_ingest_file_name_detection_enabled: bool = False, are_raw_data_bq_imports_enabled_in_env: bool = False, are_ingest_view_exports_enabled_in_env: bool = False): region = create_autospec(Region) region.region_code = region_code region.agency_type = agency_type region.environment = environment region.jurisdiction_id = jurisdiction_id region.get_ingestor.return_value = \ ingestor if ingestor else create_autospec(BaseDirectIngestController) region.is_ingest_launched_in_env.return_value = \ Region.is_ingest_launched_in_env(region) region.is_raw_vs_ingest_file_name_detection_enabled.return_value = is_raw_vs_ingest_file_name_detection_enabled region.are_raw_data_bq_imports_enabled_in_env.return_value = are_raw_data_bq_imports_enabled_in_env region.are_ingest_view_exports_enabled_in_env.return_value = are_ingest_view_exports_enabled_in_env return region
def fake_is_launched_in_env(): return Region.is_ingest_launched_in_env(region)