diff --git a/magma/upload.py b/magma/upload.py
index 450af1b..93d2413 100644
--- a/magma/upload.py
+++ b/magma/upload.py
@@ -154,6 +154,16 @@ def set_restricted_access(self):
accconst.text = "Restricted Access Online: Access granted to Licensee only. Available only to MIT affiliates."
return self
+ def add_keywords(self):
+ keywords = self._get_path('idinfo/keywords')
+ theme = etree.SubElement(keywords, 'theme')
+ etree.SubElement(theme, 'themekt')
+ etree.SubElement(theme, 'themekey')
+ place = etree.SubElement(keywords, 'place')
+ etree.SubElement(place, 'placekt')
+ etree.SubElement(place, 'placekey')
+ return self
+
def _get_path(self, path):
return get_path(path, self.root)
@@ -167,6 +177,7 @@ def process(fgdc, ds=None):
set_name(ds.name)
metadata.set_distribution().\
set_metadata_contact().\
+ add_keywords().\
ensure_elements()
return metadata
diff --git a/tests/test_upload.py b/tests/test_upload.py
index 31294b6..5cdfcc1 100644
--- a/tests/test_upload.py
+++ b/tests/test_upload.py
@@ -201,6 +201,25 @@ def test_sets_restricted_access():
assert r.doc.find('idinfo/accconst').text == "Restricted Access Online: Access granted to Licensee only. Available only to MIT affiliates."
+def test_adds_empty_keyword():
+ r = FGDC(StringIO("""
+
+
+
+
+ Foo
+
+
+ Bar
+
+
+
+ """))
+ r.add_keywords()
+ assert len(r.doc.findall('idinfo/keywords/theme')) == 2
+ assert len(r.doc.findall('idinfo/keywords/place')) == 2
+
+
def test_process_ensures_elements_exist(shp):
r = process(StringIO(""), shp)
- assert r.doc.find('idinfo/keywords/theme/themekey') is not None
+ assert r.doc.find('idinfo/descript/purpose') is not None