本文整理汇总了Python中test._common.open_and_parse_test_data函数的典型用法代码示例。如果您正苦于以下问题:Python open_and_parse_test_data函数的具体用法?Python open_and_parse_test_data怎么用?Python open_and_parse_test_data使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了open_and_parse_test_data函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testArtistCredit
def testArtistCredit(self):
"""
If the artist credit is the same in the track and recording, make sure that
the information is replicated in both objects, otherwise have distinct ones.
"""
# If no artist-credit in the track, copy in the recording one
res = _common.open_and_parse_test_data(
self.datadir, "833d4c3a-2635-4b7a-83c4-4e560588f23a-recordings+artist-credits.xml"
)
tracks = res["release"]["medium-list"][0]["track-list"]
t1 = tracks[1]
self.assertEqual(t1["artist-credit"], t1["recording"]["artist-credit"])
self.assertEqual("JT Bruce", t1["artist-credit-phrase"])
self.assertEqual(t1["recording"]["artist-credit-phrase"], t1["artist-credit-phrase"])
# Recording AC is different to track AC
res = _common.open_and_parse_test_data(
self.datadir, "fbe4490e-e366-4da2-a37a-82162d2f41a9-recordings+artist-credits.xml"
)
tracks = res["release"]["medium-list"][0]["track-list"]
t1 = tracks[1]
self.assertNotEqual(t1["artist-credit"], t1["recording"]["artist-credit"])
self.assertEqual("H. Lichner", t1["artist-credit-phrase"])
self.assertNotEqual(t1["recording"]["artist-credit-phrase"], t1["artist-credit-phrase"])
示例2: testWorkAliases
def testWorkAliases(self):
res = _common.open_and_parse_test_data(self.datadir, "80737426-8ef3-3a9c-a3a6-9507afb93e93-aliases.xml")
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"')
work_attrs = res["work"]["attribute-list"]
self.assertEqual(len(work_attrs), 1)
attr = work_attrs[0]
self.assertEqual(attr["type"], "Key")
self.assertEqual(attr["attribute"], "E-flat major")
res = _common.open_and_parse_test_data(self.datadir, "3d7c7cd2-da79-37f4-98b8-ccfb1a4ac6c4-aliases.xml")
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")
示例3: testTrackCount
def testTrackCount(self):
"""
Test that the number of tracks (offset-count) is returned.
"""
# discid without pregap track
res = _common.open_and_parse_test_data(self.datadir, "xp5tz6rE4OHrBafj0bLfDRMGK48-.xml")
self.assertEqual(res["disc"]["offset-count"], 8)
# discid with pregap track
# (the number of tracks does not count the pregap "track")
res = _common.open_and_parse_test_data(self.datadir, "f7agNZK1HMQ2WUWq9bwDymw9aHA-.xml")
self.assertEqual(res["disc"]["offset-count"], 13)
示例4: testReleaseList
def testReleaseList(self):
"""
Test that a release list of correct size is given.
"""
res = _common.open_and_parse_test_data(self.datadir, "xp5tz6rE4OHrBafj0bLfDRMGK48-.xml")
self.assertEqual(res["disc"]["release-count"], 3)
self.assertEqual(res["disc"]["release-count"], len(res["disc"]["release-list"]))
示例5: testTrackLength
def testTrackLength(self):
"""
Test that if there is a track length, then `track_or_recording_length` has
that, but if not then fill the value from the recording length
"""
res = _common.open_and_parse_test_data(self.datadir, "b66ebe6d-a577-4af8-9a2e-a029b2147716-recordings.xml")
tracks = res["release"]["medium-list"][0]["track-list"]
# No track length and recording length
t1 = tracks[0]
self.assertTrue("length" not in t1)
self.assertEqual("180000", t1["recording"]["length"])
self.assertEqual("180000", t1["track_or_recording_length"])
# Track length and recording length same
t2 = tracks[1]
self.assertEqual("279000", t2["length"])
self.assertEqual("279000", t2["recording"]["length"])
self.assertEqual("279000", t2["track_or_recording_length"])
# Track length and recording length different
t3 = tracks[2]
self.assertEqual("60000", t3["length"])
self.assertEqual("80000", t3["recording"]["length"])
self.assertEqual("60000", t3["track_or_recording_length"])
# No track lengths
t4 = tracks[3]
self.assertTrue("length" not in t4["recording"])
self.assertTrue("length" not in t4)
self.assertTrue("track_or_recording_length" not in t4)
示例6: testTypesExist
def testTypesExist(self):
res = _common.open_and_parse_test_data(self.datadir,
"f52bc6a1-c848-49e6-85de-f8f53459a624.xml")
rg = res["release-group"]
self.assertTrue("type" in rg)
self.assertTrue("primary-type" in rg)
self.assertTrue("secondary-type-list" in rg)
示例7: testTrackId
def testTrackId(self):
"""
Test that the id attribute of tracks is read.
"""
res = _common.open_and_parse_test_data(self.datadir, "212895ca-ee36-439a-a824-d2620cd10461-recordings.xml")
tracks = res["release"]["medium-list"][0]["track-list"]
map(lambda t: self.assertTrue("id" in t), tracks)
示例8: testTrackNumber
def testTrackNumber(self):
"""
Test that track number (number or text) and track position (always an increasing number)
are both read properly
"""
res = _common.open_and_parse_test_data(self.datadir, "212895ca-ee36-439a-a824-d2620cd10461-recordings.xml")
tracks = res["release"]["medium-list"][0]["track-list"]
# This release doesn't number intro tracks as numbered tracks,
# so position and number get 'out of sync'
self.assertEqual(['1', '2', '3'], [t["position"] for t in tracks[:3]])
self.assertEqual(['', '1', '2'], [t["number"] for t in tracks[:3]])
res = _common.open_and_parse_test_data(self.datadir, "a81f3c15-2f36-47c7-9b0f-f684a8b0530f-recordings.xml")
tracks = res["release"]["medium-list"][0]["track-list"]
self.assertEqual(['1', '2'], [t["position"] for t in tracks])
self.assertEqual(['A', 'B'], [t["number"] for t in tracks])
示例9: testPlace
def testPlace(self):
event_id = "770fb0b4-0ad8-4774-9275-099b66627355"
res = _common.open_and_parse_test_data(self.datadir, "%s-place-rels.xml" % event_id)
place = res["event"]["place-relation-list"][0]["place"]
self.assertEqual("7643f13a-dcda-4db4-8196-3ffcc1b99ab7", place["id"])
self.assertEqual("50.33556", place["coordinates"]["latitude"])
self.assertEqual("6.9475", place["coordinates"]["longitude"])
示例10: testEventElements
def testEventElements(self):
filename = "e921686d-ba86-4122-bc3b-777aec90d231-tags-artist-rels.xml"
res = _common.open_and_parse_test_data(self.datadir, filename)
e = res["event"]
keys = ["name", "life-span", "time", "setlist", "artist-relation-list", "tag-list"]
for k in keys:
self.assertTrue(k in e, "key %s in dict" % (k, ))
示例11: testTypesResult
def testTypesResult(self):
res = _common.open_and_parse_test_data(self.datadir,
"f52bc6a1-c848-49e6-85de-f8f53459a624.xml")
rg = res["release-group"]
self.assertEqual("Soundtrack", rg["type"])
self.assertEqual("Album", rg["primary-type"])
self.assertEqual(["Soundtrack"], rg["secondary-type-list"])
示例12: testCollectionReleases
def testCollectionReleases(self):
"""
Test that the list of releases is given.
"""
res = _common.open_and_parse_test_data(self.datadir, "0b15c97c-8eb8-4b4f-81c3-0eb24266a2ac-releases.xml")
self.assertEqual(res["collection"]["release-count"], 400)
self.assertTrue("release-list" in res["collection"])
示例13: testTags
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")
示例14: testDataTracklist
def testDataTracklist(self):
"""
Test that data tracklist are parsed.
"""
res = _common.open_and_parse_test_data(self.datadir, "9ce41d09-40e4-4d33-af0c-7fed1e558dba-recordings.xml")
medium = res["release"]["medium-list"][0]
self.assertTrue("data-track-list" in medium)
self.assertEqual(198, len(medium["data-track-list"]))
示例15: testListFromBrowse
def testListFromBrowse(self):
filename = "browse-area-74e50e58-5deb-4b99-93a2-decbb365c07f-annotation.xml"
res = _common.open_and_parse_test_data(self.datadir, filename)
self.assertEqual(395, res["place-count"])
self.assertEqual(25, len(res["place-list"]))
self.assertTrue(res["place-list"][13]["annotation"]["text"].startswith("was later renamed"))