Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added support for alias-list to work entities

Signed-off-by: Sam Doshi <sam@metal-fish.co.uk>
  • Loading branch information...
commit dbc789abc74f2ca99d3e3279fd06450016c8ef8b 1 parent 6707a31
@samdoshi samdoshi authored
View
2  musicbrainzngs/mbxml.py
@@ -349,7 +349,7 @@ def parse_work(work):
inner_els = {"tag-list": parse_tag_list,
"user-tag-list": parse_tag_list,
"rating": parse_rating,
- "alias-list": parse_element_list,
+ "alias-list": parse_alias_list,
"iswc-list": parse_element_list,
"relation-list": parse_relation_list,
"annotation": parse_response_message}
View
1  test/data/work/3d7c7cd2-da79-37f4-98b8-ccfb1a4ac6c4-aliases.xml
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><metadata xmlns="http://musicbrainz.org/ns/mmd-2.0#"><work id="3d7c7cd2-da79-37f4-98b8-ccfb1a4ac6c4"><title>Symphony No. 2 in E minor, Op. 27: III. Adagio</title><alias-list count="10"><alias sort-name="Adagio from Symphony No. 2 in E minor, Op. 27">Adagio from Symphony No. 2 in E minor, Op. 27</alias><alias sort-name="Adagio from Symphony No. 2 in E minor, Op. 27">Adagio from Symphony No. 2 in E minor, Op. 27</alias><alias sort-name="III. Adagio from Symphony No. 2 in E minor, Op. 27">III. Adagio from Symphony No. 2 in E minor, Op. 27</alias><alias sort-name="Sinfonie Nr. 2 e-moll, Op. 27: III. Adagio">Sinfonie Nr. 2 e-moll, Op. 27: III. Adagio</alias><alias sort-name="Symphonie No. 2 in E minor, Op. 27: III. Adagio">Symphonie No. 2 in E minor, Op. 27: III. Adagio</alias><alias sort-name="Symphony No. 2 in E minor, Op. 27: III. Adagio">Symphony No. 2 in E minor, Op. 27: III. Adagio</alias><alias sort-name="Symphony No. 2 in E minor, Op. 27: III. Adagio">Symphony No. 2 in E minor, Op. 27: III. Adagio</alias><alias sort-name="Symphony No. 2 in E minor, Op. 27: III. Adagio">Symphony No. 2 in E minor, Op. 27: III. Adagio</alias><alias sort-name="Symphony No. 3 in A minor, Op. 44: II. Adagio ma non troppo">Symphony No. 3 in A minor, Op. 44: II. Adagio ma non troppo</alias><alias sort-name="교향곡 2번 3악장 &quot;아다지오&quot; [Symphony No. 2 in E minor, Op. 27: III. Adagio]">교향곡 2번 3악장 &quot;아다지오&quot; [Symphony No. 2 in E minor, Op. 27: III. Adagio]</alias></alias-list></work></metadata>
View
1  test/data/work/80737426-8ef3-3a9c-a3a6-9507afb93e93-aliases.xml
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><metadata xmlns="http://musicbrainz.org/ns/mmd-2.0#"><work type="Symphony" id="80737426-8ef3-3a9c-a3a6-9507afb93e93"><title>Symphony No. 3 in E-flat major, Op. 55 &quot;Eroica&quot;</title><alias-list count="2"><alias sort-name="Symphonie Nr. 3 Es-Dur, Op. 55 &quot;Eroica&quot;">Symphonie Nr. 3 Es-Dur, Op. 55 &quot;Eroica&quot;</alias><alias sort-name="Symphony No. 3, Op. 55 &quot;Eroica&quot;">Symphony No. 3, Op. 55 &quot;Eroica&quot;</alias></alias-list></work></metadata>
View
39 test/test_mbxml_work.py
@@ -0,0 +1,39 @@
+# coding=utf-8
+# Tests for parsing of work queries
+
+import unittest
+import os
+import sys
+# Insert .. at the beginning of path so we use this version instead
+# of something that's already been installed
+sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
+import musicbrainzngs
+from musicbrainzngs import mbxml
+
+class GetWorkTest(unittest.TestCase):
+ def setUp(self):
+ self.datadir = os.path.join(os.path.dirname(__file__), "data", "work")
+
+ def testWorkAliases(self):
+ fn = os.path.join(self.datadir, "80737426-8ef3-3a9c-a3a6-9507afb93e93-aliases.xml")
+ res = mbxml.parse_message(open(fn))
+ aliases = res["work"]["alias-list"]
+ self.assertEqual(len(aliases), 2)
+
+ a0 = aliases[0]
+ self.assertEqual(a0["alias"], 'Symphonie Nr. 3 Es-Dur, Op. 55 "Eroica"')
+ self.assertEqual(a0["sort-name"], 'Symphonie Nr. 3 Es-Dur, Op. 55 "Eroica"')
+
+ a1 = aliases[1]
+ self.assertEqual(a1["alias"], 'Symphony No. 3, Op. 55 "Eroica"')
+ self.assertEqual(a1["sort-name"], 'Symphony No. 3, Op. 55 "Eroica"')
+
+ fn = os.path.join(self.datadir, "3d7c7cd2-da79-37f4-98b8-ccfb1a4ac6c4-aliases.xml")
+ res = mbxml.parse_message(open(fn))
+ aliases = res["work"]["alias-list"]
+ self.assertEqual(len(aliases), 10)
+
+ a0 = aliases[0]
+ self.assertEqual(a0["alias"], "Adagio from Symphony No. 2 in E minor, Op. 27")
+ self.assertEqual(a0["sort-name"], "Adagio from Symphony No. 2 in E minor, Op. 27")
+
Please sign in to comment.
Something went wrong with that request. Please try again.