Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions magma/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@ def ensure_elements(self):
'idinfo/timeperd/current',
'idinfo/status/progress',
'idinfo/status/update',
'idinfo/keywords/theme/themekey',
'idinfo/keywords/place/placekey',
'idinfo/keywords/temporal/tempkey',
'idinfo/ptcontac',
'eainfo/detailed/attr/attrdef',
Expand All @@ -155,13 +153,10 @@ def set_restricted_access(self):
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')
themekey = self._get_path('idinfo/keywords/theme/themekey')
themekey.addprevious(etree.Element('themekt'))
placekey = self._get_path('idinfo/keywords/place/placekey')
placekey.addprevious(etree.Element('placekt'))
return self

def _get_path(self, path):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ 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():
def test_adds_keyword_thesauri():
r = FGDC(StringIO("""
<metadata>
<idinfo>
Expand All @@ -216,8 +216,8 @@ def test_adds_empty_keyword():
</idinfo>
</metadata>"""))
r.add_keywords()
assert len(r.doc.findall('idinfo/keywords/theme')) == 2
assert len(r.doc.findall('idinfo/keywords/place')) == 2
assert len(r.doc.findall('idinfo/keywords/theme/themekt')) == 1
assert len(r.doc.findall('idinfo/keywords/place/placekt')) == 1


def test_process_ensures_elements_exist(shp):
Expand Down