Ejemplo n.º 1
0
 def test_single_tag(self):
     loc = u'<mods:identifier type="local" displayLabel="PN_DB_id">'
     locParser = LocationParser(loc)
     base_element = locParser.get_base_element()
     self.assertEqual(base_element[u'element'], u'mods:identifier')
     self.assertEqual(base_element[u'attributes'], {u'type': u'local', u'displayLabel': u'PN_DB_id'})
     self.assertFalse(base_element[u'data'])
     sections = locParser.get_sections()
     self.assertFalse(sections)
Ejemplo n.º 2
0
 def test_single_tag(self):
     loc = u'<mods:identifier type="local" displayLabel="PN_DB_id">'
     locParser = LocationParser(loc)
     base_element = locParser.get_base_element()
     self.assertEqual(base_element[u"element"], u"mods:identifier")
     self.assertEqual(base_element[u"attributes"], {u"type": u"local", u"displayLabel": u"PN_DB_id"})
     self.assertFalse(base_element[u"data"])
     sections = locParser.get_sections()
     self.assertFalse(sections)
Ejemplo n.º 3
0
 def test_multi_tag(self):
     loc = u'<mods:titleInfo><mods:title>'
     locParser = LocationParser(loc)
     base_element = locParser.get_base_element()
     self.assertEqual(base_element[u'element'], u'mods:titleInfo')
     self.assertEqual(base_element[u'attributes'], {})
     self.assertFalse(base_element[u'data'])
     sections = locParser.get_sections()
     self.assertEqual(len(sections), 1)
     first_section = sections[0]
     self.assertEqual(len(first_section), 1)
     self.assertEqual(first_section[0][u'element'], u'mods:title')
     self.assertEqual(first_section[0][u'attributes'], {})
     self.assertFalse(first_section[0][u'data'])
Ejemplo n.º 4
0
 def test_multi_tag(self):
     loc = u"<mods:titleInfo><mods:title>"
     locParser = LocationParser(loc)
     base_element = locParser.get_base_element()
     self.assertEqual(base_element[u"element"], u"mods:titleInfo")
     self.assertEqual(base_element[u"attributes"], {})
     self.assertFalse(base_element[u"data"])
     sections = locParser.get_sections()
     self.assertEqual(len(sections), 1)
     first_section = sections[0]
     self.assertEqual(len(first_section), 1)
     self.assertEqual(first_section[0][u"element"], u"mods:title")
     self.assertEqual(first_section[0][u"attributes"], {})
     self.assertFalse(first_section[0][u"data"])
Ejemplo n.º 5
0
 def test_another_tag(self):
     loc = '<mods:subject><mods:hierarchicalGeographic><mods:country>United States</mods:country><mods:state>'
     locParser = LocationParser(loc)
     base_element = locParser.get_base_element()
     self.assertEqual(base_element[u'element'], u'mods:subject')
     self.assertEqual(base_element[u'attributes'], {})
     self.assertFalse(base_element[u'data'])
     sections = locParser.get_sections()
     self.assertEqual(len(sections), 1)
     first_section = sections[0]
     self.assertEqual(len(first_section), 3)
     self.assertEqual(first_section[0]['element'], 'mods:hierarchicalGeographic')
     self.assertEqual(first_section[1]['element'], 'mods:country')
     self.assertEqual(first_section[1]['data'], 'United States')
     self.assertEqual(first_section[2]['element'], 'mods:state')
Ejemplo n.º 6
0
 def test_another_tag(self):
     loc = "<mods:subject><mods:hierarchicalGeographic><mods:country>United States</mods:country><mods:state>"
     locParser = LocationParser(loc)
     base_element = locParser.get_base_element()
     self.assertEqual(base_element[u"element"], u"mods:subject")
     self.assertEqual(base_element[u"attributes"], {})
     self.assertFalse(base_element[u"data"])
     sections = locParser.get_sections()
     self.assertEqual(len(sections), 1)
     first_section = sections[0]
     self.assertEqual(len(first_section), 3)
     self.assertEqual(first_section[0]["element"], "mods:hierarchicalGeographic")
     self.assertEqual(first_section[1]["element"], "mods:country")
     self.assertEqual(first_section[1]["data"], "United States")
     self.assertEqual(first_section[2]["element"], "mods:state")
Ejemplo n.º 7
0
 def test_name_tag(self):
     loc = u'<mods:name type="personal"><mods:namePart>#<mods:role><mods:roleTerm type="text">winner'
     locParser = LocationParser(loc)
     base_element = locParser.get_base_element()
     self.assertEqual(base_element[u'element'], u'mods:name')
     self.assertEqual(base_element[u'attributes'], {u'type': u'personal'})
     self.assertFalse(base_element[u'data'])
     sections = locParser.get_sections()
     self.assertEqual(len(sections), 2)
     first_section = sections[0]
     self.assertEqual(len(first_section), 1)
     self.assertEqual(first_section[0][u'element'], u'mods:namePart')
     self.assertEqual(first_section[0][u'attributes'], {})
     self.assertFalse(first_section[0][u'data'])
     second_section = sections[1]
     self.assertEqual(len(second_section), 2)
     self.assertEqual(second_section[0][u'element'], u'mods:role')
     self.assertEqual(second_section[0][u'attributes'], {})
     self.assertFalse(second_section[0][u'data'], {})
     self.assertEqual(second_section[1][u'element'], u'mods:roleTerm')
     self.assertEqual(second_section[1][u'attributes'], {u'type': u'text'})
     self.assertEqual(second_section[1][u'data'], u'winner')
Ejemplo n.º 8
0
 def test_name_tag(self):
     loc = u'<mods:name type="personal"><mods:namePart>#<mods:role><mods:roleTerm type="text">winner'
     locParser = LocationParser(loc)
     base_element = locParser.get_base_element()
     self.assertEqual(base_element[u"element"], u"mods:name")
     self.assertEqual(base_element[u"attributes"], {u"type": u"personal"})
     self.assertFalse(base_element[u"data"])
     sections = locParser.get_sections()
     self.assertEqual(len(sections), 2)
     first_section = sections[0]
     self.assertEqual(len(first_section), 1)
     self.assertEqual(first_section[0][u"element"], u"mods:namePart")
     self.assertEqual(first_section[0][u"attributes"], {})
     self.assertFalse(first_section[0][u"data"])
     second_section = sections[1]
     self.assertEqual(len(second_section), 2)
     self.assertEqual(second_section[0][u"element"], u"mods:role")
     self.assertEqual(second_section[0][u"attributes"], {})
     self.assertFalse(second_section[0][u"data"], {})
     self.assertEqual(second_section[1][u"element"], u"mods:roleTerm")
     self.assertEqual(second_section[1][u"attributes"], {u"type": u"text"})
     self.assertEqual(second_section[1][u"data"], u"winner")