Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PonteIneptique committed Jan 27, 2017
1 parent 0bb48d1 commit 6bea1bb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions MyCapytain/resources/prototypes/cts/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ def __export__(self, output=None, domain="", namespaces=True, lines="\n"):
"""
if output == Mimetypes.XML.CTS:
attrs = {"urn": self.id, "xml:lang": self.lang}
if self.parent is not None and self.parent.id:
attrs["workUrn"] = self.parent.id
if namespaces is True:
attrs.update(self.__namespaces_header__())

Expand Down
9 changes: 9 additions & 0 deletions tests/resources/collections/test_cts.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ def sortbytext(elem):
else:
return ''

@staticmethod
def sortbyattr(elem):
attrkeys = sorted(elem.keys())
if len(attrkeys):
return elem.get(attrkeys[0])
else:
return ""

@staticmethod
def sortAttrs(item, sorteditem):
attrkeys = sorted(item.keys())
Expand All @@ -57,6 +65,7 @@ def sortElements(items, newroot):
# We do this by performing three sorts in the reverse order
items = sorted(items, key=XML_Compare.sortbyid)
items = sorted(items, key=XML_Compare.sortbytext)
items = sorted(items, key=XML_Compare.sortbyattr)
items = sorted(items, key=attrgetter('tag'))

# Once sorted, we sort each of the items
Expand Down

0 comments on commit 6bea1bb

Please sign in to comment.