-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Alastair Porter <[email protected]>
- Loading branch information
Showing
13 changed files
with
160 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
test/data/instrument/01ba56a2-4306-493d-8088-c7e9b671c74e-instrument-rels.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?xml version="1.0" encoding="UTF-8"?><metadata xmlns="http://musicbrainz.org/ns/mmd-2.0#"><instrument id="01ba56a2-4306-493d-8088-c7e9b671c74e" type="String instrument"><name>kemenche</name><description>Various types of stringed bowed musical instruments having their origin in the Eastern Mediterranean</description><relation-list target-type="instrument"><relation type-id="12678b88-1adb-3536-890e-9b39b9a14b2d" type="children"><target>04a21d03-535a-4ace-9098-12013867b8e5</target><direction>backward</direction><instrument id="04a21d03-535a-4ace-9098-12013867b8e5"><name>fiddle</name></instrument></relation><relation type="children" type-id="12678b88-1adb-3536-890e-9b39b9a14b2d"><target>ad09a4ed-d1b6-47c3-ac85-acb531244a4d</target><instrument id="ad09a4ed-d1b6-47c3-ac85-acb531244a4d"><name>kemençe of the Black Sea</name><description>Turkish box-shaped kemenche, mainly used for folk music.</description></instrument></relation><relation type="children" type-id="12678b88-1adb-3536-890e-9b39b9a14b2d"><target>b9692581-c117-47f3-9524-3deeb69c6d3f</target><instrument id="b9692581-c117-47f3-9524-3deeb69c6d3f"><name>classical kemençe</name><description>Turkish bowl-shaped kemenche, mainly used in classical Ottoman music</description></instrument></relation></relation-list></instrument></metadata> |
1 change: 1 addition & 0 deletions
1
test/data/instrument/6505f98c-f698-4406-8bf4-8ca43d05c36f-aliases.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?xml version="1.0" encoding="UTF-8"?><metadata xmlns="http://musicbrainz.org/ns/mmd-2.0#"><instrument type="Other instrument" id="6505f98c-f698-4406-8bf4-8ca43d05c36f"><name>bass</name><description>Bass is a common but generic credit which refers to more than one instrument, the most common being the bass guitar and the double bass (a.k.a. contrabass, acoustic upright bass, wood bass). Please use the correct instrument if you know which one is intended.</description><alias-list count="14"><alias locale="de" primary="primary" sort-name="Bass" type="Instrument name">Bass</alias><alias locale="it" sort-name="Basso" primary="primary" type="Instrument name">Basso</alias><alias sort-name="baixo" primary="primary" locale="pt_BR" type="Instrument name">baixo</alias><alias type="Instrument name" sort-name="bajo (genérico, no usar)" primary="primary" locale="es">bajo (genérico, no usar)</alias><alias locale="da" primary="primary" sort-name="bas" type="Instrument name">bas</alias><alias type="Instrument name" primary="primary" sort-name="bas" locale="hr">bas</alias><alias type="Instrument name" primary="primary" sort-name="bas" locale="nl">bas</alias><alias type="Instrument name" primary="primary" sort-name="bas" locale="tr">bas</alias><alias type="Instrument name" locale="en" primary="primary" sort-name="bass">bass</alias><alias type="Instrument name" sort-name="bass" primary="primary" locale="et">bass</alias><alias locale="fr" primary="primary" sort-name="basses" type="Instrument name">basses</alias><alias type="Instrument name" locale="fi" sort-name="basso" primary="primary">basso</alias><alias type="Instrument name" sort-name="μπάσο" primary="primary" locale="el">μπάσο</alias><alias type="Instrument name" locale="ja" primary="primary" sort-name="ベース">ベース</alias></alias-list></instrument></metadata> |
1 change: 1 addition & 0 deletions
1
test/data/instrument/6505f98c-f698-4406-8bf4-8ca43d05c36f-tags.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?xml version="1.0" encoding="UTF-8"?><metadata xmlns="http://musicbrainz.org/ns/mmd-2.0#"><instrument id="6505f98c-f698-4406-8bf4-8ca43d05c36f" type="Other instrument"><name>bass</name><description>Bass is a common but generic credit which refers to more than one instrument, the most common being the bass guitar and the double bass (a.k.a. contrabass, acoustic upright bass, wood bass). Please use the correct instrument if you know which one is intended.</description><tag-list><tag count="1"><name>fixme</name></tag><tag count="0"><name>never use this</name></tag><tag count="0"><name>please don't use this</name></tag></tag-list></instrument></metadata> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?xml version="1.0" encoding="UTF-8"?><metadata xmlns="http://musicbrainz.org/ns/mmd-2.0#"><instrument id="9447c0af-5569-48f2-b4c5-241105d58c91" type="Wind instrument"><name>bass saxophone</name><description>The bass saxophone is the second largest existing member of the saxophone family (not counting the subcontrabass tubax). It is similar in design to a baritone saxophone, but it is larger, with a longer loop near the mouthpiece.</description></instrument></metadata> |
1 change: 1 addition & 0 deletions
1
test/data/instrument/d00cec5f-f9bc-4235-a54f-6639a02d4e4c-annotation.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?xml version="1.0" encoding="UTF-8"?><metadata xmlns="http://musicbrainz.org/ns/mmd-2.0#"><instrument type="Other instrument" id="d00cec5f-f9bc-4235-a54f-6639a02d4e4c"><name>bullroarer</name><description>A bullroarer consists of a piece of wood attached to a long cord which is then swung in a circle.</description><annotation><text>Hornbostel-Sachs: 412.22</text></annotation></instrument></metadata> |
1 change: 1 addition & 0 deletions
1
test/data/instrument/d00cec5f-f9bc-4235-a54f-6639a02d4e4c-url-rels.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?xml version="1.0" encoding="UTF-8"?><metadata xmlns="http://musicbrainz.org/ns/mmd-2.0#"><instrument id="d00cec5f-f9bc-4235-a54f-6639a02d4e4c" type="Other instrument"><name>bullroarer</name><description>A bullroarer consists of a piece of wood attached to a long cord which is then swung in a circle.</description><relation-list target-type="url"><relation type-id="0e62afec-12f3-3d0f-b122-956207839854" type="information page"><target id="e0132182-3ab0-405f-adde-f2504c97900e">http://en.wikisource.org/wiki/1911_Encyclop%C3%A6dia_Britannica/Bullroarer</target></relation><relation type-id="1486fccd-cf59-35e4-9399-b50e2b255877" type="wikidata"><target id="5c0633b0-12fd-4e54-8383-9cc0e049aa3a">http://www.wikidata.org/wiki/Q666971</target></relation><relation type-id="f64eacbd-1ea1-381e-9886-2cfb552b7d90" type="image"><target id="8513926d-184f-4ef7-920c-ec3b69e9a00a">https://commons.wikimedia.org/wiki/File:Bull_roarers.jpg</target></relation></relation-list></instrument></metadata> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?xml version="1.0" encoding="UTF-8"?><metadata xmlns="http://musicbrainz.org/ns/mmd-2.0#"><instrument type="String instrument" id="dabdeb41-560f-4d84-aa6a-cf22349326fe"><name>tar</name><disambiguation>lute</disambiguation><description>The tar is a long-necked, waisted lute found in Azerbaijan, Iran, Armenia, Georgia, and other areas near the Caucasus region. Not to be confused with the drum of the same name.</description></instrument></metadata> |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# -*- coding: UTF-8 -*- | ||
# Tests for parsing instrument 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__), ".."))) | ||
from test import _common | ||
import musicbrainzngs | ||
|
||
class GetInstrumentTest(unittest.TestCase): | ||
def setUp(self): | ||
self.datadir = os.path.join(os.path.dirname(__file__), "data", "instrument") | ||
|
||
def testData(self): | ||
res = _common.open_and_parse_test_data(self.datadir, "9447c0af-5569-48f2-b4c5-241105d58c91.xml") | ||
inst = res["instrument"] | ||
|
||
self.assertEqual(inst["id"], "9447c0af-5569-48f2-b4c5-241105d58c91") | ||
self.assertEqual(inst["name"], "bass saxophone") | ||
self.assertEqual(inst["type"], "Wind instrument") | ||
self.assertTrue(inst["description"].startswith("The bass saxophone")) | ||
|
||
def testAliases(self): | ||
res = _common.open_and_parse_test_data(self.datadir, "6505f98c-f698-4406-8bf4-8ca43d05c36f-aliases.xml") | ||
inst = res["instrument"] | ||
|
||
aliases = inst["alias-list"] | ||
self.assertEqual(len(aliases), 14) | ||
self.assertEqual(aliases[1]["locale"], "it") | ||
self.assertEqual(aliases[1]["type"], "Instrument name") | ||
self.assertEqual(aliases[1]["primary"], "primary") | ||
self.assertEqual(aliases[1]["sort-name"], "Basso") | ||
self.assertEqual(aliases[1]["alias"], "Basso") | ||
|
||
|
||
def testTags(self): | ||
res = _common.open_and_parse_test_data(self.datadir, "6505f98c-f698-4406-8bf4-8ca43d05c36f-tags.xml") | ||
inst = res["instrument"] | ||
|
||
tags = inst["tag-list"] | ||
self.assertEqual(len(tags), 3) | ||
self.assertEqual(tags[0]["name"], "fixme") | ||
self.assertEqual(tags[0]["count"], "1") | ||
|
||
def testUrlRels(self): | ||
res = _common.open_and_parse_test_data(self.datadir, "d00cec5f-f9bc-4235-a54f-6639a02d4e4c-url-rels.xml") | ||
inst = res["instrument"] | ||
|
||
rels = inst["url-relation-list"] | ||
self.assertEqual(len(rels), 3) | ||
self.assertEqual(rels[0]["type"], "information page") | ||
self.assertEqual(rels[0]["type-id"], "0e62afec-12f3-3d0f-b122-956207839854") | ||
self.assertTrue(rels[0]["target"].startswith("http://en.wikisource")) | ||
|
||
def testAnnotations(self): | ||
res = _common.open_and_parse_test_data(self.datadir, "d00cec5f-f9bc-4235-a54f-6639a02d4e4c-annotation.xml") | ||
inst = res["instrument"] | ||
self.assertEqual(inst["annotation"]["text"], "Hornbostel-Sachs: 412.22") | ||
|
||
def testInstrumentRels(self): | ||
res = _common.open_and_parse_test_data(self.datadir, "01ba56a2-4306-493d-8088-c7e9b671c74e-instrument-rels.xml") | ||
inst = res["instrument"] | ||
|
||
rels = inst["instrument-relation-list"] | ||
self.assertEqual(len(rels), 3) | ||
self.assertEqual(rels[1]["type"], "children") | ||
self.assertEqual(rels[1]["type-id"], "12678b88-1adb-3536-890e-9b39b9a14b2d") | ||
self.assertEqual(rels[1]["target"], "ad09a4ed-d1b6-47c3-ac85-acb531244a4d") | ||
self.assertEqual(rels[1]["instrument"]["id"], "ad09a4ed-d1b6-47c3-ac85-acb531244a4d") | ||
self.assertTrue(rels[1]["instrument"]["name"].startswith(b"kemen\xc3\xa7e".decode("utf-8"))) | ||
|
||
def testDisambiguation(self): | ||
res = _common.open_and_parse_test_data(self.datadir, "dabdeb41-560f-4d84-aa6a-cf22349326fe.xml") | ||
inst = res["instrument"] | ||
self.assertEqual(inst["disambiguation"], "lute") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters