def test_unknown_classname(): db = DataAccessHelper.createdb( 'postgresql://*****:*****@localhost:5432/det_unk_class') sudata = { 'tablename': 'amz_states', 'shpname': 'amz_states_epsg_4326', 'as_attribute_name': 'NM_ESTADO' } DataAccessHelper.add_spatial_unit(db, sudata['tablename'], sudata['shpname'], sudata['as_attribute_name']) group_dg = DeterClassGroup('DG') group_dg.add_class('CICATRIZ_DE_QUEIMADA') group_dg.add_class('DEGRADACAO') group_ds = DeterClassGroup('DS') group_ds.add_class('MINERACAO') group_ds.add_class('DESMATAMENTO_CR') group_ds.add_class('DESMATAMENTO_VEG') group_repo = DeterClassGroupRepository(db) group_repo.add(group_dg) group_repo.add(group_ds) surepo = SpatialUnitDynamicMapperFactory.instance()\ .create_spatial_unit(sudata['tablename'], sudata['as_attribute_name']) su = surepo.get() startdate = datetime.date(2021, 2, 1) enddate = datetime.date(2021, 1, 1) deter_repo = DeterRepository() deter_hist = [] class_groups = group_repo.list() uc = DetermineRiskIndicators(su, deter_repo, deter_hist, class_groups, startdate, enddate) indicators = uc.execute() assert len(indicators) == 61 for ind in indicators: assert ind.classname == 'DG' or 'DS' db.drop()
def set_class_groups(db): group_ds = DeterClassGroup('DS') group_ds.add_class('DESMATAMENTO_CR') group_ds.add_class('DESMATAMENTO_VEG') group_dg = DeterClassGroup('DG') group_dg.add_class('CICATRIZ_DE_QUEIMADA') group_dg.add_class('DEGRADACAO') group_cs = DeterClassGroup('CS') group_cs.add_class('CS_DESORDENADO') group_cs.add_class('CS_GEOMETRICO') group_mn = DeterClassGroup('MN') group_mn.add_class('MINERACAO') group_repo = DeterClassGroupRepository(db) group_repo.add(group_ds) group_repo.add(group_dg) group_repo.add(group_cs) group_repo.add(group_mn)
def set_only_one_group(db): group = DeterClassGroup('C1') group.add_class('CICATRIZ_DE_QUEIMADA') group.add_class('DEGRADACAO') group.add_class('MINERACAO') group.add_class('DESMATAMENTO_CR') group.add_class('DESMATAMENTO_VEG') group.add_class('CS_DESORDENADO') group.add_class('CS_GEOMETRICO') group_repo = DeterClassGroupRepository(db) group_repo.add(group)