Skip to content

Commit

Permalink
add set and get methods for placenames. #47
Browse files Browse the repository at this point in the history
  • Loading branch information
davemfish committed Nov 6, 2024
1 parent a02862a commit 00b3c8c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/geometamaker/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ''
Expand Down Expand Up @@ -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):
Expand All @@ -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.
Expand Down
12 changes: 12 additions & 0 deletions tests/test_geometamaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 00b3c8c

Please sign in to comment.