def test_dataset_group_mismatch(configuration_data): config = Config() config.config = configuration_data dataset_file = DatasetFile("Mismatch.csv", "some_bucket") with pytest.raises(ValueError) as excinfo: config.dataset_group(dataset_file) assert "must match" in str(excinfo.value)
def mocked_dsg(dataset_file, configuration_data, mocker): with mock_sts(): config = Config() config.config = configuration_data dataset_group = config.dataset_group(dataset_file) dsg = DatasetGroup( dataset_group_name=dataset_group.dataset_group_name, dataset_domain=dataset_group.dataset_group_domain, ) dsg.cli = mocker.MagicMock() dsg.cli.describe_dataset_group.return_value = { "DatasetArns": ["arn::1", "arn::2", "arn::3"] } dsg.cli.describe_dataset.return_value = {"DatasetArn": 'arn::1', "Status": "ACTIVE", 'LastModificationTime': datetime.now()} dsg.cli.get_paginator().paginate.return_value = [{ 'DatasetImportJobs': [ { "DatasetImportJobArn": f"arn::{i}", "Status": "ACTIVE", "LastModificationTime": datetime.now() } for i in range(3) ] }] yield dsg
def test_create(dataset_file, configuration_data): config = Config() config.config = configuration_data dataset_group = config.dataset_group(dataset_file) dsg = DatasetGroup( dataset_group_name=dataset_group.dataset_group_name, dataset_domain=dataset_group.dataset_group_domain, ) assert dsg.arn == "arn:aws:forecast:us-east-1:abcdefghijkl:dataset-group/data"
def test_status(dataset_file, configuration_data, mock_forecast_dsg_exists): config = Config() config.config = configuration_data dataset_group = config.dataset_group(dataset_file) dsg = DatasetGroup( dataset_group_name=dataset_group.dataset_group_name, dataset_domain=dataset_group.dataset_group_domain, ) dsg.cli = mock_forecast_dsg_exists assert dsg.status == Status.ACTIVE
def test_init_forecast(forecast_stub, configuration_data): config = Config() config.config = configuration_data dataset_file = DatasetFile("RetailDemandTNPTS.csv", "some_bucket") forecast = config.forecast(dataset_file, "RetailDemandTNPTS") dataset_group = config.dataset_group(dataset_file) assert ( forecast._dataset_group.dataset_group_name == dataset_group.dataset_group_name ) assert forecast._forecast_config == config.config_item(dataset_file, "Forecast")
def test_dataset_group_default(configuration_data, forecast_stub): config = Config() config.config = configuration_data dataset_file = DatasetFile("some_new_key.csv", "some_bucket") dsg = config.dataset_group(dataset_file=dataset_file) assert ( dsg.arn == "arn:aws:forecast:us-east-1:abcdefghijkl:dataset-group/some_new_key") assert dsg.dataset_group_name == "some_new_key" assert dsg.dataset_group_domain == DatasetDomain.RETAIL dsg.cli = forecast_stub.client forecast_stub.add_client_error("describe_dataset_group", "ResourceNotFoundException") assert dsg.status == Status.DOES_NOT_EXIST