Skip to content

Commit

Permalink
Fix tests that return None. Fix "A guide to this new...".
Browse files Browse the repository at this point in the history
  • Loading branch information
gregchapman-dev committed May 15, 2022
1 parent 881a587 commit a8b2132
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions music21/metadata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
.. image:: images/moduleMetadata-01.*
:width: 600
A guide to this initial new implementation:
A guide to the 2022 Dublin Core implementation:
- The guts of class Metadata are completely rewritten to support the new
extensions, but all of Metadata's old APIs are still in place and
Expand Down Expand Up @@ -442,10 +442,14 @@ def getItem(self,
Test getItem when the item isn't there.
>>> md = metadata.Metadata()
>>> md.getItem('title') # uniqueName
>>> md.getItem('title', namespace='dcterms') # name, namespace
>>> md.getItem('T', namespace='dcterms') # abbrevCode, namespace
>>> md.getItem('dcterms:title') # 'namespace:name'
>>> md.getItem('title') is None # uniqueName
True
>>> md.getItem('title', namespace='dcterms') is None # name, namespace
True
>>> md.getItem('T', namespace='dcterms') is None # abbrevCode, namespace
True
>>> md.getItem('dcterms:title') is None # 'namespace:name'
True
Test getItem when the item is there:
Expand Down Expand Up @@ -790,8 +794,10 @@ def uniqueNameToNSKey(uniqueName: str) -> t.Optional[str]:
>>> metadata.Metadata.uniqueNameToNSKey('librettist')
'marcrel:LBT'
>>> metadata.Metadata.uniqueNameToNSKey('not a standard property')
>>> metadata.Metadata.uniqueNameToNSKey(None)
>>> metadata.Metadata.uniqueNameToNSKey('not a standard property') is None
True
>>> metadata.Metadata.uniqueNameToNSKey(None) is None
True
>>> metadata.Metadata.uniqueNameToNSKey('alternativeTitle')
'dcterms:alternative'
'''
Expand Down Expand Up @@ -832,8 +838,10 @@ def nsKeyToUniqueName(nsKey: str) -> t.Optional[str]:
>>> metadata.Metadata.nsKeyToUniqueName('marcrel:LBT')
'librettist'
>>> metadata.Metadata.nsKeyToUniqueName('not a standard nskey')
>>> metadata.Metadata.nsKeyToUniqueName(None)
>>> metadata.Metadata.nsKeyToUniqueName('not a standard nskey') is None
True
>>> metadata.Metadata.nsKeyToUniqueName(None) is None
True
>>> metadata.Metadata.nsKeyToUniqueName('dcterms:alternative')
'alternativeTitle'
'''
Expand All @@ -852,9 +860,12 @@ def nsKeyToContributorUniqueName(nsKey: str) -> t.Optional[str]:
>>> metadata.Metadata.nsKeyToContributorUniqueName('marcrel:LBT')
'librettist'
>>> metadata.Metadata.nsKeyToContributorUniqueName('not a standard nskey')
>>> metadata.Metadata.nsKeyToContributorUniqueName(None)
>>> metadata.Metadata.nsKeyToContributorUniqueName('dcterms:alternative')
>>> metadata.Metadata.nsKeyToContributorUniqueName('not a standard nskey') is None
True
>>> metadata.Metadata.nsKeyToContributorUniqueName(None) is None
True
>>> metadata.Metadata.nsKeyToContributorUniqueName('dcterms:alternative') is None
True
'''
if not nsKey:
return None
Expand Down Expand Up @@ -914,7 +925,8 @@ def copyright(self) -> t.Optional[Copyright]:
<music21.metadata.primitives.Copyright Copyright © 1984 All Rights Reserved>
>>> md = metadata.Metadata()
>>> md.copyright
>>> md.copyright is None
True
>>> md.setItem('dcterms:rights', 'Copyright © 1984 All Rights Reserved')
>>> md.addItem('dcterms:rights', 'Lyrics copyright © 1987 All Rights Reserved')
>>> md.copyright = 'Copyright © 1984 from str'
Expand Down

0 comments on commit a8b2132

Please sign in to comment.