def retrieve_watertype_group(self, area): """Return the water type group of the given area. This method returns the default WatertypeGroup when no WaterBody exists for the given area or when no water type is specified for the WaterBody. """ watertype_group = None try: waterbody = WaterBody.objects.get(area=area) if waterbody.krw_watertype is not None: watertype_group = waterbody.krw_watertype.watertype_group except ObjectDoesNotExist: pass if watertype_group is None: watertype_group = WatertypeGroups.get_default() return watertype_group
def test_i(self): """Test the retrieval of the default WatertypeGroup when none exists.""" watertype_group = WatertypeGroups.get_default() self.assertEqual(DEFAULT_WATERTYPE_GROUP_CODE, watertype_group.code)