From 00b3c8c155813eb894fa00fcc9e8d0f80de645c8 Mon Sep 17 00:00:00 2001 From: davemfish Date: Wed, 6 Nov 2024 13:33:45 -0500 Subject: [PATCH] add set and get methods for placenames. #47 --- src/geometamaker/models.py | 25 +++++++++++++++++++++++++ tests/test_geometamaker.py | 12 ++++++++++++ 2 files changed, 37 insertions(+) diff --git a/src/geometamaker/models.py b/src/geometamaker/models.py index 67e62f3..039b57b 100644 --- a/src/geometamaker/models.py +++ b/src/geometamaker/models.py @@ -311,6 +311,7 @@ class Resource(BaseMetadata): keywords: list = dataclasses.field(default_factory=list) license: LicenseSchema = dataclasses.field(default_factory=LicenseSchema) lineage: str = '' + placenames: list = dataclasses.field(default_factory=list) purpose: str = '' title: str = '' url: str = '' @@ -433,6 +434,12 @@ def set_keywords(self, keywords): self.keywords = keywords def get_keywords(self): + """Get the keywords describing the dataset. + + Returns: + list + + """ return self.keywords def set_lineage(self, statement): @@ -454,6 +461,24 @@ def get_lineage(self): """ return self.lineage + def set_placenames(self, placenames): + """Describe the geography of a dataset with a list of placenames. + + Args: + places (list): sequence of strings + + """ + self.placenames = placenames + + def get_placenames(self): + """Get the placenames describing the dataset. + + Returns: + list + + """ + return self.placenames + def set_purpose(self, purpose): """Add a purpose for the dataset. diff --git a/tests/test_geometamaker.py b/tests/test_geometamaker.py index 3853585..3e33b35 100644 --- a/tests/test_geometamaker.py +++ b/tests/test_geometamaker.py @@ -366,6 +366,18 @@ def test_set_keywords(self): resource.get_keywords(), ['foo', 'bar']) + def test_set_and_get_placenames(self): + """Test set and get placenames.""" + + import geometamaker + + resource = geometamaker.models.Resource() + resource.set_placenames(['Alaska', 'North Pacific']) + + self.assertEqual( + resource.get_placenames(), + ['Alaska', 'North Pacific']) + def test_set_and_get_license(self): """Test set and get license for resource.""" import geometamaker