Skip to content

Commit

Permalink
Merge a0ed2f3 into 2941ab8
Browse files Browse the repository at this point in the history
  • Loading branch information
sevein committed Dec 21, 2018
2 parents 2941ab8 + a0ed2f3 commit bdedcd3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion metsrw/plugins/premisrw/premis.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,10 @@ def _data_to_lxml_el(data, ns, nsmap, element_maker=None, snake=True):
elif isinstance(element, (tuple, list)):
args.append(_data_to_lxml_el(
element, ns, nsmap, element_maker=element_maker, snake=snake))
elif isinstance(element, six.text_type):
args.append(element)
else:
args.append(str(element))
args.append(six.binary_type(element))
ret = func(*args)
for attr, val in attributes.items():
try:
Expand Down
16 changes: 16 additions & 0 deletions tests/plugins/premisrw/test_premis.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from unittest import TestCase

import pytest
Expand All @@ -19,6 +20,21 @@ def test_roundtrip(self):
data = premisrw.premis_to_data(lxml_el)
assert data == c.EX_COMPR_EVT

def test_roundtrip_unicode(self):
"""Test the roundtripping with unicode values."""
lxml_el = premisrw.data_to_premis((
'agent',
premisrw.PREMIS_META,
(
'agent_identifier',
('agent_identifier_type', u'𝕡𝕣𝕖𝕤𝕖𝕣𝕧𝕒𝕥𝕚𝕠𝕟 𝕤𝕪𝕤𝕥𝕖𝕞'),
('agent_identifier_value', u'𝓊𝓃𝒾𝒸𝑜𝒹𝑒'),
)
))
data = premisrw.premis_to_data(lxml_el)
assert data[2][1][1] == u'𝕡𝕣𝕖𝕤𝕖𝕣𝕧𝕒𝕥𝕚𝕠𝕟 𝕤𝕪𝕤𝕥𝕖𝕞'
assert data[2][2][1] == u'𝓊𝓃𝒾𝒸𝑜𝒹𝑒'

def test_premis_event_cls_data(self):
"""Tests that you can pass a Python tuple as the ``data`` argument to
``PREMISEvent`` to construct an instance.
Expand Down

0 comments on commit bdedcd3

Please sign in to comment.